iglooform 2.4.8 → 2.4.12

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 (258) hide show
  1. package/es/admin-upload/float.js +25 -35
  2. package/es/admin-upload/index.d.ts +2 -0
  3. package/es/admin-upload/index.js +43 -36
  4. package/es/admin-upload/job-list.js +85 -115
  5. package/es/admin-upload/modal.js +19 -26
  6. package/es/alert-message/index.js +11 -9
  7. package/es/amount/index.js +10 -5
  8. package/es/back-top/index.js +14 -10
  9. package/es/button/index.js +23 -28
  10. package/es/button/style/index.less +23 -19
  11. package/es/card-detail/card-group.js +16 -22
  12. package/es/card-detail/card-item.js +16 -21
  13. package/es/card-detail/card-page.js +11 -15
  14. package/es/card-detail/card.js +24 -24
  15. package/es/card-detail/utils.js +6 -7
  16. package/es/checkbox/index.js +23 -22
  17. package/es/claim-list/index.js +53 -70
  18. package/es/confirmation/index.js +7 -9
  19. package/es/date-picker/buddhist.js +3 -3
  20. package/es/date-picker/index.js +10 -4
  21. package/es/declaration/index.js +16 -13
  22. package/es/detail-panel/index.js +67 -83
  23. package/es/documents/index.js +6 -8
  24. package/es/example/index.js +9 -11
  25. package/es/filter/checkBox.js +33 -45
  26. package/es/filter/customize.js +3 -4
  27. package/es/filter/index.d.ts +1 -0
  28. package/es/filter/index.js +88 -112
  29. package/es/filter/radioBox.js +23 -31
  30. package/es/filter/rangePicker.js +43 -59
  31. package/es/form/addable-section/index.d.ts +19 -0
  32. package/es/form/addable-section/index.js +211 -0
  33. package/es/form/addable-section/style/index.d.ts +1 -0
  34. package/es/form/addable-section/style/index.js +1 -0
  35. package/es/form/addable-section/style/index.less +22 -0
  36. package/es/form/divider/index.js +7 -1
  37. package/es/form/element/index.js +58 -47
  38. package/es/form/element/style/index.less +9 -0
  39. package/es/form/index.js +16 -17
  40. package/es/form/login/index.js +15 -20
  41. package/es/form/page/index.js +18 -24
  42. package/es/form/page/style/index.less +1 -1
  43. package/es/form/pages/index.js +23 -32
  44. package/es/form/pages/style/index.less +3 -1
  45. package/es/form/render/index.js +1 -1
  46. package/es/form/section/index.js +14 -17
  47. package/es/form/step/index.js +31 -42
  48. package/es/form/steps/index.js +8 -11
  49. package/es/{form/context.d.ts → form-context.d.ts} +1 -0
  50. package/es/{form/context.js → form-context.js} +0 -0
  51. package/es/free-form/addable-section/index.d.ts +18 -0
  52. package/es/free-form/addable-section/index.js +286 -0
  53. package/es/free-form/addable-section/style/index.d.ts +1 -0
  54. package/es/free-form/addable-section/style/index.js +1 -0
  55. package/es/free-form/addable-section/style/index.less +22 -0
  56. package/es/free-form/element/index.js +43 -41
  57. package/es/free-form/element/style/index.less +12 -2
  58. package/es/free-form/index.d.ts +5 -1
  59. package/es/free-form/index.js +17 -17
  60. package/es/free-form/page/index.js +36 -46
  61. package/es/free-form/page/style/index.less +3 -1
  62. package/es/free-form/pages/index.js +8 -10
  63. package/es/free-form/section/index.js +20 -22
  64. package/es/free-form/section/style/index.less +4 -0
  65. package/es/free-form/step/index.js +37 -47
  66. package/es/free-form/steps/index.js +8 -10
  67. package/es/global-message/index.js +1 -1
  68. package/es/home-menu/index.js +52 -71
  69. package/es/index.d.ts +1 -0
  70. package/es/index.js +2 -1
  71. package/es/input/amount.js +10 -5
  72. package/es/input/credit-card.js +7 -1
  73. package/es/input/email.js +8 -1
  74. package/es/input/expiry-date.js +14 -18
  75. package/es/input/input-date.js +12 -16
  76. package/es/input/input-number.js +9 -2
  77. package/es/input/input.js +9 -2
  78. package/es/input/otp.js +17 -15
  79. package/es/input/password.js +12 -6
  80. package/es/input/phone-number.js +6 -8
  81. package/es/input/style/index.less +9 -1
  82. package/es/input/text-area.js +14 -10
  83. package/es/layout/defaultFooter.js +60 -82
  84. package/es/layout/defaultHeader.js +11 -15
  85. package/es/layout/footer.js +108 -148
  86. package/es/layout/header.js +51 -60
  87. package/es/layout/index.js +16 -12
  88. package/es/locale/en-US/messages.json +2 -0
  89. package/es/locale/id-ID/messages.json +2 -0
  90. package/es/locale/locale-provider.js +8 -10
  91. package/es/locale/th-TH/messages.json +2 -0
  92. package/es/locale/vi-VN/messages.json +2 -0
  93. package/es/locale/zh-CN/messages.json +2 -0
  94. package/es/login-page/index.js +30 -42
  95. package/es/media/index.js +20 -27
  96. package/es/media/media.js +9 -12
  97. package/es/media/preview.js +8 -10
  98. package/es/mobile-insurer-detail/index.js +74 -91
  99. package/es/mobile-insurer-list/index.js +34 -38
  100. package/es/modal/index.d.ts +4 -3
  101. package/es/modal/index.js +25 -27
  102. package/es/modal/style/index.less +24 -5
  103. package/es/platform/platform-card/index.js +9 -12
  104. package/es/platform/switch-platform/index.js +24 -32
  105. package/es/policy-list/index.js +11 -14
  106. package/es/policy-list/policy-card.js +119 -153
  107. package/es/radio/index.js +33 -35
  108. package/es/select/attached-select.js +31 -34
  109. package/es/select/select.js +12 -8
  110. package/es/select/style/index.less +1 -1
  111. package/es/select/time-select.js +12 -16
  112. package/es/status-box/index.js +8 -10
  113. package/es/table/index.js +72 -96
  114. package/es/tabs/index.js +7 -1
  115. package/es/types.d.ts +4 -2
  116. package/es/typography/index.js +6 -8
  117. package/es/upload/index.d.ts +2 -1
  118. package/es/upload/index.js +169 -143
  119. package/es/upload-photo/index.d.ts +2 -1
  120. package/es/upload-photo/index.js +170 -142
  121. package/es/upload-photo/media.js +3 -4
  122. package/es/upload-preview/index.js +9 -12
  123. package/es/upload-preview/media.js +12 -16
  124. package/es/utils/form-utils.js +49 -36
  125. package/lib/admin-upload/float.js +25 -35
  126. package/lib/admin-upload/index.d.ts +2 -0
  127. package/lib/admin-upload/index.js +43 -36
  128. package/lib/admin-upload/job-list.js +85 -115
  129. package/lib/admin-upload/modal.js +19 -26
  130. package/lib/alert-message/index.js +11 -9
  131. package/lib/amount/index.js +10 -5
  132. package/lib/back-top/index.js +14 -10
  133. package/lib/button/index.js +24 -29
  134. package/lib/button/style/index.less +23 -19
  135. package/lib/card-detail/card-group.js +16 -22
  136. package/lib/card-detail/card-item.js +16 -21
  137. package/lib/card-detail/card-page.js +11 -15
  138. package/lib/card-detail/card.js +24 -24
  139. package/lib/card-detail/index.js +6 -6
  140. package/lib/card-detail/utils.js +7 -8
  141. package/lib/checkbox/index.js +24 -23
  142. package/lib/claim-list/index.js +53 -70
  143. package/lib/confirmation/index.js +7 -9
  144. package/lib/date-picker/buddhist.js +3 -3
  145. package/lib/date-picker/index.js +11 -5
  146. package/lib/declaration/index.js +16 -13
  147. package/lib/detail-panel/index.js +67 -83
  148. package/lib/documents/index.js +6 -8
  149. package/lib/example/index.js +10 -12
  150. package/lib/filter/checkBox.js +33 -45
  151. package/lib/filter/customize.js +3 -4
  152. package/lib/filter/index.d.ts +1 -0
  153. package/lib/filter/index.js +88 -112
  154. package/lib/filter/radioBox.js +23 -31
  155. package/lib/filter/rangePicker.js +43 -59
  156. package/lib/form/addable-section/index.d.ts +19 -0
  157. package/lib/form/addable-section/index.js +232 -0
  158. package/lib/form/addable-section/style/index.d.ts +1 -0
  159. package/lib/form/addable-section/style/index.js +3 -0
  160. package/lib/form/addable-section/style/index.less +22 -0
  161. package/lib/form/divider/index.js +7 -1
  162. package/lib/form/element/index.js +60 -48
  163. package/lib/form/element/style/index.less +9 -0
  164. package/lib/form/elements.js +1 -1
  165. package/lib/form/index.js +16 -17
  166. package/lib/form/login/index.js +16 -21
  167. package/lib/form/page/index.js +19 -25
  168. package/lib/form/page/style/index.less +1 -1
  169. package/lib/form/pages/index.js +24 -33
  170. package/lib/form/pages/style/index.less +3 -1
  171. package/lib/form/render/index.js +2 -2
  172. package/lib/form/section/index.js +15 -18
  173. package/lib/form/step/index.js +32 -43
  174. package/lib/form/steps/index.js +9 -12
  175. package/lib/{form/context.d.ts → form-context.d.ts} +1 -0
  176. package/lib/{form/context.js → form-context.js} +0 -0
  177. package/lib/free-form/addable-section/index.d.ts +18 -0
  178. package/lib/free-form/addable-section/index.js +306 -0
  179. package/lib/free-form/addable-section/style/index.d.ts +1 -0
  180. package/lib/free-form/addable-section/style/index.js +3 -0
  181. package/lib/free-form/addable-section/style/index.less +22 -0
  182. package/lib/free-form/element/index.js +44 -42
  183. package/lib/free-form/element/style/index.less +12 -2
  184. package/lib/free-form/index.d.ts +5 -1
  185. package/lib/free-form/index.js +17 -17
  186. package/lib/free-form/page/index.js +37 -47
  187. package/lib/free-form/page/style/index.less +3 -1
  188. package/lib/free-form/pages/index.js +8 -10
  189. package/lib/free-form/section/index.js +21 -23
  190. package/lib/free-form/section/style/index.less +4 -0
  191. package/lib/free-form/step/index.js +38 -48
  192. package/lib/free-form/steps/index.js +9 -11
  193. package/lib/global-message/index.js +1 -1
  194. package/lib/home-menu/index.js +52 -71
  195. package/lib/index.d.ts +1 -0
  196. package/lib/index.js +141 -132
  197. package/lib/input/amount.js +10 -5
  198. package/lib/input/credit-card.js +7 -1
  199. package/lib/input/email.js +7 -1
  200. package/lib/input/expiry-date.js +14 -18
  201. package/lib/input/index.js +18 -18
  202. package/lib/input/input-date.js +12 -16
  203. package/lib/input/input-number.js +8 -2
  204. package/lib/input/input.js +8 -2
  205. package/lib/input/otp.js +17 -15
  206. package/lib/input/password.js +11 -6
  207. package/lib/input/phone-number.js +6 -8
  208. package/lib/input/style/index.less +9 -1
  209. package/lib/input/text-area.js +14 -10
  210. package/lib/layout/defaultFooter.js +60 -82
  211. package/lib/layout/defaultHeader.js +11 -15
  212. package/lib/layout/footer.js +108 -148
  213. package/lib/layout/header.js +51 -60
  214. package/lib/layout/index.js +15 -12
  215. package/lib/locale/en-US/messages.json +2 -0
  216. package/lib/locale/format-message.js +1 -1
  217. package/lib/locale/id-ID/messages.json +2 -0
  218. package/lib/locale/index.js +4 -4
  219. package/lib/locale/locale-provider.js +9 -11
  220. package/lib/locale/th-TH/messages.json +2 -0
  221. package/lib/locale/vi-VN/messages.json +2 -0
  222. package/lib/locale/zh-CN/messages.json +2 -0
  223. package/lib/login-page/index.js +30 -42
  224. package/lib/media/index.js +20 -27
  225. package/lib/media/media.js +9 -12
  226. package/lib/media/preview.js +8 -10
  227. package/lib/mobile-insurer-detail/index.js +74 -91
  228. package/lib/mobile-insurer-list/index.js +34 -38
  229. package/lib/modal/index.d.ts +4 -3
  230. package/lib/modal/index.js +25 -27
  231. package/lib/modal/style/index.less +24 -5
  232. package/lib/platform/platform-card/index.js +9 -12
  233. package/lib/platform/switch-platform/index.js +24 -32
  234. package/lib/policy-list/index.js +11 -14
  235. package/lib/policy-list/policy-card.js +119 -153
  236. package/lib/radio/index.js +33 -35
  237. package/lib/select/attached-select.js +32 -35
  238. package/lib/select/select.js +13 -9
  239. package/lib/select/style/index.less +1 -1
  240. package/lib/select/time-select.js +12 -16
  241. package/lib/status-box/index.js +8 -10
  242. package/lib/table/index.js +72 -96
  243. package/lib/tabs/index.js +8 -2
  244. package/lib/types.d.ts +4 -2
  245. package/lib/typography/index.js +6 -8
  246. package/lib/upload/index.d.ts +2 -1
  247. package/lib/upload/index.js +170 -143
  248. package/lib/upload-photo/index.d.ts +2 -1
  249. package/lib/upload-photo/index.js +171 -142
  250. package/lib/upload-photo/media.js +3 -4
  251. package/lib/upload-preview/index.js +9 -12
  252. package/lib/upload-preview/media.js +12 -16
  253. package/lib/utils/form-utils.js +49 -37
  254. package/package.json +1 -1
  255. package/es/free-form/context.d.ts +0 -19
  256. package/es/free-form/context.js +0 -7
  257. package/lib/free-form/context.d.ts +0 -19
  258. package/lib/free-form/context.js +0 -19
@@ -53,13 +53,15 @@ var _tools = require("../utils/tools");
53
53
 
54
54
  var _media2 = _interopRequireDefault(require("./media"));
55
55
 
56
+ var _formContext = _interopRequireDefault(require("../form-context"));
57
+
56
58
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
57
59
 
58
- 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); }
60
+ 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); }
59
61
 
60
- 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; }
62
+ 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; }
61
63
 
62
- 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; }
64
+ 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; }
63
65
 
64
66
  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; }
65
67
 
@@ -71,10 +73,6 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
71
73
 
72
74
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
73
75
 
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
-
78
76
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
79
77
 
80
78
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -89,31 +87,79 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
89
87
 
90
88
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
91
89
 
90
+ 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); } }
91
+
92
+ 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); }); }; }
93
+
92
94
  var useBreakpoint = _grid.default.useBreakpoint;
93
95
  var prefix = 'igloo-upload-photo';
94
96
 
95
- var UploadPhoto = function UploadPhoto(_ref) {
97
+ var UploadPhoto = function UploadPhoto(props) {
96
98
  var _classnames3, _classnames4;
97
99
 
98
- var _ref$value = _ref.value,
99
- value = _ref$value === void 0 ? [] : _ref$value,
100
- limit = _ref.limit,
101
- limitErrorMessage = _ref.limitErrorMessage,
102
- descriptions = _ref.descriptions,
103
- buttonText = _ref.buttonText,
104
- _ref$samples = _ref.samples,
105
- samples = _ref$samples === void 0 ? [] : _ref$samples,
106
- onChange = _ref.onChange,
107
- handleUpload = _ref.handleUpload,
108
- setFieldError = _ref.setFieldError,
109
- className = _ref.className,
110
- id = _ref.id,
111
- validateField = _ref.validateField;
112
100
  var limitNumError = (0, _react.useRef)();
113
101
  var DomRef = (0, _react.useRef)();
114
102
 
115
- var _useContext = (0, _react.useContext)(_locale.LocaleContext),
116
- formatMessage = _useContext.formatMessage;
103
+ var _useContext = (0, _react.useContext)(_formContext.default),
104
+ uploadApi = _useContext.uploadApi;
105
+
106
+ (0, _invariant.default)(typeof props.handleUpload === 'function' || uploadApi, '"handleUpload" should be a function. Or uploadApi should be set at Form/FreeForm');
107
+ (0, _invariant.default)(!uploadApi || props.bizKey, '"bizKey" should be set if Upload is used with uploadApi');
108
+ var _props$value = props.value,
109
+ value = _props$value === void 0 ? [] : _props$value,
110
+ limit = props.limit,
111
+ limitErrorMessage = props.limitErrorMessage,
112
+ descriptions = props.descriptions,
113
+ buttonText = props.buttonText,
114
+ _props$samples = props.samples,
115
+ samples = _props$samples === void 0 ? [] : _props$samples,
116
+ onChange = props.onChange,
117
+ bizKey = props.bizKey,
118
+ _props$handleUpload = props.handleUpload,
119
+ handleUpload = _props$handleUpload === void 0 ? /*#__PURE__*/function () {
120
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(file) {
121
+ var formData, response, rst;
122
+ return regeneratorRuntime.wrap(function _callee$(_context) {
123
+ while (1) {
124
+ switch (_context.prev = _context.next) {
125
+ case 0:
126
+ formData = new FormData();
127
+ formData.append('file', file);
128
+ formData.append('biz_key', bizKey);
129
+ _context.next = 5;
130
+ return fetch(uploadApi, {
131
+ method: 'post',
132
+ body: formData
133
+ });
134
+
135
+ case 5:
136
+ response = _context.sent;
137
+ _context.next = 8;
138
+ return response.json();
139
+
140
+ case 8:
141
+ rst = _context.sent;
142
+ return _context.abrupt("return", rst.url);
143
+
144
+ case 10:
145
+ case "end":
146
+ return _context.stop();
147
+ }
148
+ }
149
+ }, _callee);
150
+ }));
151
+
152
+ return function (_x) {
153
+ return _ref.apply(this, arguments);
154
+ };
155
+ }() : _props$handleUpload,
156
+ setFieldError = props.setFieldError,
157
+ className = props.className,
158
+ id = props.id,
159
+ validateField = props.validateField;
160
+
161
+ var _useContext2 = (0, _react.useContext)(_locale.LocaleContext),
162
+ formatMessage = _useContext2.formatMessage;
117
163
 
118
164
  var _useState = (0, _react.useState)((0, _agentDetect.isMobileAgent)()),
119
165
  _useState2 = _slicedToArray(_useState, 1),
@@ -156,7 +202,7 @@ var UploadPhoto = function UploadPhoto(_ref) {
156
202
  }, []);
157
203
  (0, _react.useEffect)(function () {
158
204
  var removeLimitMsg = function removeLimitMsg(e) {
159
- if (!DomRef.current.contains(e.target) && limitNumError.current) {
205
+ if (DomRef.current && !DomRef.current.contains(e.target) && limitNumError.current) {
160
206
  limitNumError.current = undefined;
161
207
 
162
208
  if (files && files.length) {
@@ -197,7 +243,6 @@ var UploadPhoto = function UploadPhoto(_ref) {
197
243
  sampleSpan = _useMemo.sampleSpan,
198
244
  descriptionSpan = _useMemo.descriptionSpan;
199
245
 
200
- (0, _invariant.default)(typeof handleUpload === 'function', '"handleUpload" should be a function.');
201
246
  (0, _invariant.default)(limit === undefined || limit > 0, "\"limit\" should be a pasitive number.");
202
247
 
203
248
  var onUpload = function onUpload(e) {
@@ -220,12 +265,12 @@ var UploadPhoto = function UploadPhoto(_ref) {
220
265
  };
221
266
 
222
267
  var uploadFile = /*#__PURE__*/function () {
223
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(file, currentIndex) {
268
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(file, currentIndex) {
224
269
  var uid, dataUrl, name, size, mimeType, type, errorMsg, _errorMsg;
225
270
 
226
- return regeneratorRuntime.wrap(function _callee$(_context) {
271
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
227
272
  while (1) {
228
- switch (_context.prev = _context.next) {
273
+ switch (_context2.prev = _context2.next) {
229
274
  case 0:
230
275
  uid = ++uploadIndex.current;
231
276
  dataUrl = URL.createObjectURL(file);
@@ -233,7 +278,7 @@ var UploadPhoto = function UploadPhoto(_ref) {
233
278
  type = (0, _tools.classifyType)(mimeType);
234
279
 
235
280
  if (!(type === 'unknown')) {
236
- _context.next = 9;
281
+ _context2.next = 9;
237
282
  break;
238
283
  }
239
284
 
@@ -242,11 +287,11 @@ var UploadPhoto = function UploadPhoto(_ref) {
242
287
  });
243
288
  limitNumError.current = errorMsg;
244
289
  setFieldError && setFieldError(errorMsg);
245
- return _context.abrupt("return", Promise.reject(errorMsg));
290
+ return _context2.abrupt("return", Promise.reject(errorMsg));
246
291
 
247
292
  case 9:
248
293
  if (!(limit && currentIndex > limit)) {
249
- _context.next = 14;
294
+ _context2.next = 14;
250
295
  break;
251
296
  }
252
297
 
@@ -258,7 +303,7 @@ var UploadPhoto = function UploadPhoto(_ref) {
258
303
  });
259
304
  limitNumError.current = _errorMsg;
260
305
  setFieldError && setFieldError(_errorMsg);
261
- return _context.abrupt("return", Promise.reject(_errorMsg));
306
+ return _context2.abrupt("return", Promise.reject(_errorMsg));
262
307
 
263
308
  case 14:
264
309
  limitNumError.current = undefined;
@@ -273,7 +318,7 @@ var UploadPhoto = function UploadPhoto(_ref) {
273
318
  uid: uid
274
319
  }]);
275
320
  });
276
- return _context.abrupt("return", handleUploadPromise(file, function (url) {
321
+ return _context2.abrupt("return", handleUploadPromise(file, function (url) {
277
322
  var urls = [];
278
323
  setFiles(function (files) {
279
324
  return files.map(function (f) {
@@ -336,63 +381,63 @@ var UploadPhoto = function UploadPhoto(_ref) {
336
381
 
337
382
  case 17:
338
383
  case "end":
339
- return _context.stop();
384
+ return _context2.stop();
340
385
  }
341
386
  }
342
- }, _callee);
387
+ }, _callee2);
343
388
  }));
344
389
 
345
- return function uploadFile(_x, _x2) {
390
+ return function uploadFile(_x2, _x3) {
346
391
  return _ref3.apply(this, arguments);
347
392
  };
348
393
  }();
349
394
 
350
395
  var handleUploadPromise = /*#__PURE__*/function () {
351
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(file, onSuccess, onFailed) {
396
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(file, onSuccess, onFailed) {
352
397
  var rst, errorMsg;
353
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
398
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
354
399
  while (1) {
355
- switch (_context2.prev = _context2.next) {
400
+ switch (_context3.prev = _context3.next) {
356
401
  case 0:
357
- _context2.prev = 0;
358
- _context2.next = 3;
402
+ _context3.prev = 0;
403
+ _context3.next = 3;
359
404
  return handleUpload(file);
360
405
 
361
406
  case 3:
362
- rst = _context2.sent;
407
+ rst = _context3.sent;
363
408
  onSuccess(rst);
364
- return _context2.abrupt("return", Promise.resolve(rst));
409
+ return _context3.abrupt("return", Promise.resolve(rst));
365
410
 
366
411
  case 8:
367
- _context2.prev = 8;
368
- _context2.t0 = _context2["catch"](0);
369
- errorMsg = _typeof(_context2.t0) === 'object' ? _context2.t0.message : _context2.t0;
412
+ _context3.prev = 8;
413
+ _context3.t0 = _context3["catch"](0);
414
+ errorMsg = _typeof(_context3.t0) === 'object' ? _context3.t0.message : _context3.t0;
370
415
  onFailed(errorMsg);
371
- return _context2.abrupt("return", Promise.reject(errorMsg));
416
+ return _context3.abrupt("return", Promise.reject(errorMsg));
372
417
 
373
418
  case 13:
374
419
  case "end":
375
- return _context2.stop();
420
+ return _context3.stop();
376
421
  }
377
422
  }
378
- }, _callee2, null, [[0, 8]]);
423
+ }, _callee3, null, [[0, 8]]);
379
424
  }));
380
425
 
381
- return function handleUploadPromise(_x3, _x4, _x5) {
426
+ return function handleUploadPromise(_x4, _x5, _x6) {
382
427
  return _ref4.apply(this, arguments);
383
428
  };
384
429
  }();
385
430
 
386
431
  var handleDelete = /*#__PURE__*/function () {
387
- var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(index) {
432
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(index) {
388
433
  var arr, hasError, rst;
389
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
434
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
390
435
  while (1) {
391
- switch (_context3.prev = _context3.next) {
436
+ switch (_context4.prev = _context4.next) {
392
437
  case 0:
393
438
  limitNumError.current = null;
394
439
  arr = files;
395
- _context3.next = 4;
440
+ _context4.next = 4;
396
441
  return setFiles(function (files) {
397
442
  var newArr = files.filter(function (_, i) {
398
443
  return i !== index;
@@ -402,7 +447,7 @@ var UploadPhoto = function UploadPhoto(_ref) {
402
447
  });
403
448
 
404
449
  case 4:
405
- _context3.next = 6;
450
+ _context4.next = 6;
406
451
  return setMasks(function (masks) {
407
452
  return masks.filter(function (_, i) {
408
453
  return i !== index;
@@ -416,7 +461,7 @@ var UploadPhoto = function UploadPhoto(_ref) {
416
461
  });
417
462
 
418
463
  if (!hasError) {
419
- _context3.next = 10;
464
+ _context4.next = 10;
420
465
  break;
421
466
  }
422
467
 
@@ -429,7 +474,7 @@ var UploadPhoto = function UploadPhoto(_ref) {
429
474
 
430
475
  return f.url;
431
476
  });
432
- return _context3.abrupt("return", typeof onChange === 'function' && onChange(rst));
477
+ return _context4.abrupt("return", typeof onChange === 'function' && onChange(rst));
433
478
 
434
479
  case 10:
435
480
  typeof onChange === 'function' && onChange(arr.map(function (_ref6) {
@@ -439,36 +484,36 @@ var UploadPhoto = function UploadPhoto(_ref) {
439
484
 
440
485
  case 11:
441
486
  case "end":
442
- return _context3.stop();
487
+ return _context4.stop();
443
488
  }
444
489
  }
445
- }, _callee3);
490
+ }, _callee4);
446
491
  }));
447
492
 
448
- return function handleDelete(_x6) {
493
+ return function handleDelete(_x7) {
449
494
  return _ref5.apply(this, arguments);
450
495
  };
451
496
  }();
452
497
 
453
498
  var handleReUpload = /*#__PURE__*/function () {
454
- var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(index) {
499
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(index) {
455
500
  var _files$index, originFile, reUpUid, rst, latestFiles, fileListWithError, newList, _rst;
456
501
 
457
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
502
+ return regeneratorRuntime.wrap(function _callee5$(_context5) {
458
503
  while (1) {
459
- switch (_context4.prev = _context4.next) {
504
+ switch (_context5.prev = _context5.next) {
460
505
  case 0:
461
506
  _files$index = files[index], originFile = _files$index.originFile, reUpUid = _files$index.uid;
462
507
 
463
508
  if (originFile) {
464
- _context4.next = 3;
509
+ _context5.next = 3;
465
510
  break;
466
511
  }
467
512
 
468
- return _context4.abrupt("return");
513
+ return _context5.abrupt("return");
469
514
 
470
515
  case 3:
471
- _context4.next = 5;
516
+ _context5.next = 5;
472
517
  return setFiles(function (files) {
473
518
  var newFiles = _toConsumableArray(files);
474
519
 
@@ -477,14 +522,14 @@ var UploadPhoto = function UploadPhoto(_ref) {
477
522
  });
478
523
 
479
524
  case 5:
480
- _context4.prev = 5;
481
- _context4.next = 8;
525
+ _context5.prev = 5;
526
+ _context5.next = 8;
482
527
  return handleUpload(originFile);
483
528
 
484
529
  case 8:
485
- rst = _context4.sent;
530
+ rst = _context5.sent;
486
531
  latestFiles = [];
487
- _context4.next = 12;
532
+ _context5.next = 12;
488
533
  return setFiles(function (files) {
489
534
  var newFiles = _toConsumableArray(files);
490
535
 
@@ -512,19 +557,19 @@ var UploadPhoto = function UploadPhoto(_ref) {
512
557
  return url;
513
558
  });
514
559
  onChange && onChange(fileListWithError);
515
- _context4.next = 23;
560
+ _context5.next = 23;
516
561
  break;
517
562
 
518
563
  case 16:
519
- _context4.prev = 16;
520
- _context4.t0 = _context4["catch"](5);
564
+ _context5.prev = 16;
565
+ _context5.t0 = _context5["catch"](5);
521
566
  newList = [];
522
- _context4.next = 21;
567
+ _context5.next = 21;
523
568
  return setFiles(function (files) {
524
569
  var newFiles = _toConsumableArray(files);
525
570
 
526
571
  newFiles[index].status = 'failed';
527
- newFiles[index].errorMsg = _context4.t0;
572
+ newFiles[index].errorMsg = _context5.t0;
528
573
  newList = newFiles;
529
574
  return newFiles;
530
575
  });
@@ -555,13 +600,13 @@ var UploadPhoto = function UploadPhoto(_ref) {
555
600
 
556
601
  case 24:
557
602
  case "end":
558
- return _context4.stop();
603
+ return _context5.stop();
559
604
  }
560
605
  }
561
- }, _callee4, null, [[5, 16]]);
606
+ }, _callee5, null, [[5, 16]]);
562
607
  }));
563
608
 
564
- return function handleReUpload(_x7) {
609
+ return function handleReUpload(_x8) {
565
610
  return _ref7.apply(this, arguments);
566
611
  };
567
612
  }();
@@ -647,55 +692,47 @@ var UploadPhoto = function UploadPhoto(_ref) {
647
692
  }, void 0);
648
693
  };
649
694
 
650
- return (0, _jsxRuntime.jsxs)("div", Object.assign({
695
+ return (0, _jsxRuntime.jsxs)("div", {
651
696
  className: (0, _classnames6.default)(prefix, className),
652
697
  id: id,
653
- ref: DomRef
654
- }, {
655
- children: [Boolean(descriptions || samples.length) && (0, _jsxRuntime.jsx)("div", Object.assign({
656
- className: "".concat(prefix, "-sample")
657
- }, {
658
- children: (0, _jsxRuntime.jsxs)(_row.default, Object.assign({
698
+ ref: DomRef,
699
+ children: [Boolean(descriptions || samples.length) && (0, _jsxRuntime.jsx)("div", {
700
+ className: "".concat(prefix, "-sample"),
701
+ children: (0, _jsxRuntime.jsxs)(_row.default, {
659
702
  gutter: [isMobile ? 16 : 32, 16],
660
- wrap: true
661
- }, {
703
+ wrap: true,
662
704
  children: [Boolean(samples === null || samples === void 0 ? void 0 : samples.length) && samples.map(function (_ref8, index) {
663
705
  var _classnames, _classnames2;
664
706
 
665
707
  var src = _ref8.src,
666
708
  label = _ref8.label,
667
709
  type = _ref8.type;
668
- return (0, _jsxRuntime.jsxs)(_col.default, Object.assign({
669
- span: sampleSpan
670
- }, {
710
+ return (0, _jsxRuntime.jsxs)(_col.default, {
711
+ span: sampleSpan,
671
712
  children: [(0, _jsxRuntime.jsx)("img", {
672
713
  src: src,
673
714
  alt: "",
674
715
  className: "".concat(prefix, "-sample-photos-photo")
675
716
  }, void 0), (0, _jsxRuntime.jsx)("div", {
676
717
  className: (0, _classnames6.default)((_classnames = {}, _defineProperty(_classnames, "".concat(prefix, "-sample-photos-good"), type === 'good'), _defineProperty(_classnames, "".concat(prefix, "-sample-photos-bad"), type === 'bad'), _classnames))
677
- }, void 0), label && (0, _jsxRuntime.jsx)("div", Object.assign({
678
- className: (0, _classnames6.default)((_classnames2 = {}, _defineProperty(_classnames2, "".concat(prefix, "-sample-photos-label"), true), _defineProperty(_classnames2, "".concat(prefix, "-sample-photos-label-good"), type === 'good'), _defineProperty(_classnames2, "".concat(prefix, "-sample-photos-label-bad"), type === 'bad'), _classnames2))
679
- }, {
680
- children: (0, _jsxRuntime.jsx)(_typography.default, Object.assign({
681
- level: "body2"
682
- }, {
718
+ }, void 0), label && (0, _jsxRuntime.jsx)("div", {
719
+ className: (0, _classnames6.default)((_classnames2 = {}, _defineProperty(_classnames2, "".concat(prefix, "-sample-photos-label"), true), _defineProperty(_classnames2, "".concat(prefix, "-sample-photos-label-good"), type === 'good'), _defineProperty(_classnames2, "".concat(prefix, "-sample-photos-label-bad"), type === 'bad'), _classnames2)),
720
+ children: (0, _jsxRuntime.jsx)(_typography.default, {
721
+ level: "body2",
683
722
  children: label
684
- }), void 0)
685
- }), void 0)]
686
- }), index);
687
- }), (0, _jsxRuntime.jsx)(_col.default, Object.assign({
723
+ }, void 0)
724
+ }, void 0)]
725
+ }, index);
726
+ }), (0, _jsxRuntime.jsx)(_col.default, {
688
727
  className: (0, _classnames6.default)((_classnames3 = {}, _defineProperty(_classnames3, "".concat(prefix, "-sample-descriptions"), true), _defineProperty(_classnames3, "".concat(prefix, "-sample-descriptions-center"), !!md), _classnames3)),
689
- span: descriptionSpan
690
- }, {
691
- children: (0, _jsxRuntime.jsx)(_typography.default, Object.assign({
692
- level: "caption2"
693
- }, {
728
+ span: descriptionSpan,
729
+ children: (0, _jsxRuntime.jsx)(_typography.default, {
730
+ level: "caption2",
694
731
  children: descriptions
695
- }), void 0)
696
- }), void 0)]
697
- }), void 0)
698
- }), void 0), (0, _jsxRuntime.jsx)("input", {
732
+ }, void 0)
733
+ }, void 0)]
734
+ }, void 0)
735
+ }, void 0), (0, _jsxRuntime.jsx)("input", {
699
736
  id: uploadId,
700
737
  type: "file",
701
738
  style: {
@@ -706,44 +743,39 @@ var UploadPhoto = function UploadPhoto(_ref) {
706
743
  value: [],
707
744
  multiple: true,
708
745
  capture: true
709
- }, void 0), (0, _jsxRuntime.jsxs)(_space.default, Object.assign({
746
+ }, void 0), (0, _jsxRuntime.jsxs)(_space.default, {
710
747
  className: "".concat(prefix, "-content"),
711
748
  size: [16, 16],
712
- wrap: true
713
- }, {
714
- children: [(0, _jsxRuntime.jsxs)("label", Object.assign({
749
+ wrap: true,
750
+ children: [(0, _jsxRuntime.jsxs)("label", {
715
751
  htmlFor: uploadId,
716
752
  className: (0, _classnames6.default)((_classnames4 = {}, _defineProperty(_classnames4, "".concat(prefix, "-content-button"), true), _defineProperty(_classnames4, 'dont-show-error-status', Array.isArray(value) && value.some(function (file) {
717
753
  return typeof file !== 'string' && file.status === 'failed';
718
- })), _classnames4))
719
- }, {
754
+ })), _classnames4)),
720
755
  children: [(0, _jsxRuntime.jsx)(_iglooicon.UploadOutlined, {
721
756
  style: {
722
757
  fontSize: 24,
723
758
  color: '#666666'
724
759
  }
725
- }, void 0), (0, _jsxRuntime.jsx)("span", Object.assign({
760
+ }, void 0), (0, _jsxRuntime.jsx)("span", {
726
761
  style: {
727
762
  marginTop: 6
728
- }
729
- }, {
730
- children: (0, _jsxRuntime.jsx)(_typography.default, Object.assign({
731
- level: "body1"
732
- }, {
763
+ },
764
+ children: (0, _jsxRuntime.jsx)(_typography.default, {
765
+ level: "body1",
733
766
  children: buttonText || 'Upload'
734
- }), void 0)
735
- }), void 0)]
736
- }), void 0), files.map(function (_ref9, index) {
767
+ }, void 0)
768
+ }, void 0)]
769
+ }, void 0), files.map(function (_ref9, index) {
737
770
  var _classnames5;
738
771
 
739
772
  var dataUrl = _ref9.dataUrl,
740
773
  status = _ref9.status,
741
774
  type = _ref9.type,
742
775
  uid = _ref9.uid;
743
- return (0, _jsxRuntime.jsx)(_badge.default, Object.assign({
744
- count: getBadge(status, index, limit)
745
- }, {
746
- children: (0, _jsxRuntime.jsxs)("div", Object.assign({
776
+ return (0, _jsxRuntime.jsx)(_badge.default, {
777
+ count: getBadge(status, index, limit),
778
+ children: (0, _jsxRuntime.jsxs)("div", {
747
779
  className: (0, _classnames6.default)((_classnames5 = {}, _defineProperty(_classnames5, "".concat(prefix, "-content-container"), true), _defineProperty(_classnames5, "".concat(prefix, "-content-error"), status === 'failed'), _classnames5)),
748
780
  onMouseEnter: function onMouseEnter() {
749
781
  return handleMouseEnter(index);
@@ -754,44 +786,41 @@ var UploadPhoto = function UploadPhoto(_ref) {
754
786
  onClick: function onClick(e) {
755
787
  e.stopPropagation();
756
788
  handleTouchEnd(index);
757
- }
758
- }, {
789
+ },
759
790
  children: [(0, _jsxRuntime.jsx)(_media2.default, {
760
791
  type: type,
761
792
  src: dataUrl,
762
793
  className: "".concat(prefix, "-content-preview")
763
794
  }, void 0), (!limit || index < limit) && masks[index] && (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
764
- children: [status === 'failed' && (0, _jsxRuntime.jsx)("div", Object.assign({
795
+ children: [status === 'failed' && (0, _jsxRuntime.jsx)("div", {
765
796
  className: "".concat(prefix, "-content-mask"),
766
797
  onClick: function onClick(e) {
767
798
  e.stopPropagation();
768
799
  handleReUpload(index);
769
- }
770
- }, {
800
+ },
771
801
  children: (0, _jsxRuntime.jsx)(_iglooicon.RefreshOutlined, {
772
802
  style: {
773
803
  fontSize: 24
774
804
  }
775
805
  }, void 0)
776
- }), void 0), status === 'success' && (0, _jsxRuntime.jsx)("div", Object.assign({
806
+ }, void 0), status === 'success' && (0, _jsxRuntime.jsx)("div", {
777
807
  className: "".concat(prefix, "-content-mask"),
778
808
  onClick: function onClick(e) {
779
809
  e.stopPropagation();
780
810
  handlePreview(index);
781
- }
782
- }, {
811
+ },
783
812
  children: (0, _jsxRuntime.jsx)(_iglooicon.ShowOutlined, {
784
813
  style: {
785
814
  fontSize: 24
786
815
  }
787
816
  }, void 0)
788
- }), void 0)]
817
+ }, void 0)]
789
818
  }, void 0)]
790
- }), void 0)
791
- }), uid);
819
+ }, void 0)
820
+ }, uid);
792
821
  })]
793
- }), void 0)]
794
- }), void 0);
822
+ }, void 0)]
823
+ }, void 0);
795
824
  };
796
825
 
797
826
  function checkFileList(value) {
@@ -29,9 +29,8 @@ var MediaItem = function MediaItem(_ref) {
29
29
  }, void 0);
30
30
 
31
31
  case 'pdf':
32
- return (0, _jsxRuntime.jsx)("div", Object.assign({
33
- className: className
34
- }, {
32
+ return (0, _jsxRuntime.jsx)("div", {
33
+ className: className,
35
34
  children: (0, _jsxRuntime.jsx)(_reactPdf.default, {
36
35
  file: src,
37
36
  scale: 0.1,
@@ -40,7 +39,7 @@ var MediaItem = function MediaItem(_ref) {
40
39
  maxHeight: 96
41
40
  }
42
41
  }, void 0)
43
- }), void 0);
42
+ }, void 0);
44
43
 
45
44
  default:
46
45
  return (0, _jsxRuntime.jsx)("img", {