iglooform 2.4.7 → 2.4.11

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