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.
- package/es/admin-upload/float.js +25 -35
- package/es/admin-upload/index.d.ts +2 -0
- package/es/admin-upload/index.js +43 -36
- package/es/admin-upload/job-list.js +85 -115
- package/es/admin-upload/modal.js +19 -26
- package/es/alert-message/index.js +11 -9
- package/es/amount/index.js +10 -5
- package/es/back-top/index.js +14 -10
- package/es/button/index.js +23 -28
- package/es/button/style/index.less +23 -19
- package/es/card-detail/card-group.js +16 -22
- package/es/card-detail/card-item.js +16 -21
- package/es/card-detail/card-page.js +11 -15
- package/es/card-detail/card.js +24 -24
- package/es/card-detail/style/index.less +13 -0
- package/es/card-detail/utils.js +6 -7
- package/es/checkbox/index.js +23 -22
- package/es/claim-list/index.js +53 -70
- package/es/confirmation/index.js +7 -9
- package/es/date-picker/buddhist.js +3 -3
- package/es/date-picker/index.js +10 -4
- package/es/declaration/index.js +16 -13
- package/es/detail-panel/index.js +67 -83
- package/es/documents/index.js +6 -8
- package/es/example/index.js +9 -11
- package/es/filter/checkBox.js +33 -45
- package/es/filter/customize.js +3 -4
- package/es/filter/index.d.ts +1 -0
- package/es/filter/index.js +88 -112
- package/es/filter/radioBox.js +23 -31
- package/es/filter/rangePicker.js +43 -59
- package/es/form/addable-section/index.d.ts +19 -0
- package/es/form/addable-section/index.js +211 -0
- package/es/form/addable-section/style/index.d.ts +1 -0
- package/es/form/addable-section/style/index.js +1 -0
- package/es/form/addable-section/style/index.less +22 -0
- package/es/form/divider/index.js +7 -1
- package/es/form/element/index.js +58 -47
- package/es/form/element/style/index.less +9 -0
- package/es/form/index.js +16 -17
- package/es/form/login/index.js +15 -20
- package/es/form/page/index.js +18 -24
- package/es/form/page/style/index.less +1 -1
- package/es/form/pages/index.js +23 -32
- package/es/form/pages/style/index.less +3 -1
- package/es/form/render/index.js +1 -1
- package/es/form/section/index.js +14 -17
- package/es/form/step/index.js +31 -42
- package/es/form/steps/index.js +8 -11
- package/es/{form/context.d.ts → form-context.d.ts} +1 -0
- package/es/{form/context.js → form-context.js} +0 -0
- package/es/free-form/addable-section/index.d.ts +18 -0
- package/es/free-form/addable-section/index.js +286 -0
- package/es/free-form/addable-section/style/index.d.ts +1 -0
- package/es/free-form/addable-section/style/index.js +1 -0
- package/es/free-form/addable-section/style/index.less +22 -0
- package/es/free-form/element/index.js +43 -41
- package/es/free-form/element/style/index.less +12 -2
- package/es/free-form/index.d.ts +5 -1
- package/es/free-form/index.js +17 -17
- package/es/free-form/page/index.js +36 -46
- package/es/free-form/page/style/index.less +3 -1
- package/es/free-form/pages/index.js +8 -10
- package/es/free-form/section/index.js +20 -22
- package/es/free-form/section/style/index.less +4 -0
- package/es/free-form/step/index.js +37 -47
- package/es/free-form/steps/index.js +8 -10
- package/es/global-message/index.js +1 -1
- package/es/home-menu/index.js +52 -71
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/input/amount.js +10 -5
- package/es/input/credit-card.js +7 -1
- package/es/input/email.js +8 -1
- package/es/input/expiry-date.js +14 -18
- package/es/input/input-date.js +12 -16
- package/es/input/input-number.js +9 -2
- package/es/input/input.js +9 -2
- package/es/input/otp.js +17 -15
- package/es/input/password.js +12 -6
- package/es/input/phone-number.js +6 -8
- package/es/input/style/index.less +9 -1
- package/es/input/text-area.js +14 -10
- package/es/layout/defaultFooter.js +60 -82
- package/es/layout/defaultHeader.js +11 -15
- package/es/layout/footer.js +108 -148
- package/es/layout/header.js +51 -60
- package/es/layout/index.js +16 -12
- package/es/locale/en-US/messages.json +2 -0
- package/es/locale/id-ID/messages.json +2 -0
- package/es/locale/locale-provider.js +8 -10
- package/es/locale/th-TH/messages.json +2 -0
- package/es/locale/vi-VN/messages.json +2 -0
- package/es/locale/zh-CN/messages.json +2 -0
- package/es/login-page/index.js +30 -42
- package/es/media/index.js +20 -27
- package/es/media/media.js +9 -12
- package/es/media/preview.js +8 -10
- package/es/mobile-insurer-detail/index.js +74 -91
- package/es/mobile-insurer-list/index.js +34 -38
- package/es/modal/index.d.ts +4 -3
- package/es/modal/index.js +25 -27
- package/es/modal/style/index.less +24 -5
- package/es/platform/platform-card/index.js +9 -12
- package/es/platform/switch-platform/index.js +24 -32
- package/es/policy-list/index.js +11 -14
- package/es/policy-list/policy-card.js +119 -153
- package/es/radio/index.js +33 -35
- package/es/select/attached-select.js +31 -34
- package/es/select/select.js +12 -8
- package/es/select/style/index.less +1 -1
- package/es/select/time-select.js +12 -16
- package/es/status-box/index.js +8 -10
- package/es/table/index.js +72 -96
- package/es/tabs/index.js +7 -1
- package/es/types.d.ts +4 -2
- package/es/typography/index.js +6 -8
- package/es/upload/index.d.ts +2 -1
- package/es/upload/index.js +169 -143
- package/es/upload-photo/index.d.ts +2 -1
- package/es/upload-photo/index.js +170 -142
- package/es/upload-photo/media.js +3 -4
- package/es/upload-preview/index.js +9 -12
- package/es/upload-preview/media.js +12 -16
- package/es/upload-preview/style/index.less +2 -2
- package/es/utils/form-utils.js +49 -36
- package/lib/admin-upload/float.js +25 -35
- package/lib/admin-upload/index.d.ts +2 -0
- package/lib/admin-upload/index.js +43 -36
- package/lib/admin-upload/job-list.js +85 -115
- package/lib/admin-upload/modal.js +19 -26
- package/lib/alert-message/index.js +11 -9
- package/lib/amount/index.js +10 -5
- package/lib/back-top/index.js +14 -10
- package/lib/button/index.js +24 -29
- package/lib/button/style/index.less +23 -19
- package/lib/card-detail/card-group.js +16 -22
- package/lib/card-detail/card-item.js +16 -21
- package/lib/card-detail/card-page.js +11 -15
- package/lib/card-detail/card.js +24 -24
- package/lib/card-detail/index.js +6 -6
- package/lib/card-detail/style/index.less +13 -0
- package/lib/card-detail/utils.js +7 -8
- package/lib/checkbox/index.js +24 -23
- package/lib/claim-list/index.js +53 -70
- package/lib/confirmation/index.js +7 -9
- package/lib/date-picker/buddhist.js +3 -3
- package/lib/date-picker/index.js +11 -5
- package/lib/declaration/index.js +16 -13
- package/lib/detail-panel/index.js +67 -83
- package/lib/documents/index.js +6 -8
- package/lib/example/index.js +10 -12
- package/lib/filter/checkBox.js +33 -45
- package/lib/filter/customize.js +3 -4
- package/lib/filter/index.d.ts +1 -0
- package/lib/filter/index.js +88 -112
- package/lib/filter/radioBox.js +23 -31
- package/lib/filter/rangePicker.js +43 -59
- package/lib/form/addable-section/index.d.ts +19 -0
- package/lib/form/addable-section/index.js +232 -0
- package/lib/form/addable-section/style/index.d.ts +1 -0
- package/lib/form/addable-section/style/index.js +3 -0
- package/lib/form/addable-section/style/index.less +22 -0
- package/lib/form/divider/index.js +7 -1
- package/lib/form/element/index.js +60 -48
- package/lib/form/element/style/index.less +9 -0
- package/lib/form/elements.js +1 -1
- package/lib/form/index.js +16 -17
- package/lib/form/login/index.js +16 -21
- package/lib/form/page/index.js +19 -25
- package/lib/form/page/style/index.less +1 -1
- package/lib/form/pages/index.js +24 -33
- package/lib/form/pages/style/index.less +3 -1
- package/lib/form/render/index.js +2 -2
- package/lib/form/section/index.js +15 -18
- package/lib/form/step/index.js +32 -43
- package/lib/form/steps/index.js +9 -12
- package/lib/{form/context.d.ts → form-context.d.ts} +1 -0
- package/lib/{form/context.js → form-context.js} +0 -0
- package/lib/free-form/addable-section/index.d.ts +18 -0
- package/lib/free-form/addable-section/index.js +306 -0
- package/lib/free-form/addable-section/style/index.d.ts +1 -0
- package/lib/free-form/addable-section/style/index.js +3 -0
- package/lib/free-form/addable-section/style/index.less +22 -0
- package/lib/free-form/element/index.js +44 -42
- package/lib/free-form/element/style/index.less +12 -2
- package/lib/free-form/index.d.ts +5 -1
- package/lib/free-form/index.js +17 -17
- package/lib/free-form/page/index.js +37 -47
- package/lib/free-form/page/style/index.less +3 -1
- package/lib/free-form/pages/index.js +8 -10
- package/lib/free-form/section/index.js +21 -23
- package/lib/free-form/section/style/index.less +4 -0
- package/lib/free-form/step/index.js +38 -48
- package/lib/free-form/steps/index.js +9 -11
- package/lib/global-message/index.js +1 -1
- package/lib/home-menu/index.js +52 -71
- package/lib/index.d.ts +1 -0
- package/lib/index.js +141 -132
- package/lib/input/amount.js +10 -5
- package/lib/input/credit-card.js +7 -1
- package/lib/input/email.js +7 -1
- package/lib/input/expiry-date.js +14 -18
- package/lib/input/index.js +18 -18
- package/lib/input/input-date.js +12 -16
- package/lib/input/input-number.js +8 -2
- package/lib/input/input.js +8 -2
- package/lib/input/otp.js +17 -15
- package/lib/input/password.js +11 -6
- package/lib/input/phone-number.js +6 -8
- package/lib/input/style/index.less +9 -1
- package/lib/input/text-area.js +14 -10
- package/lib/layout/defaultFooter.js +60 -82
- package/lib/layout/defaultHeader.js +11 -15
- package/lib/layout/footer.js +108 -148
- package/lib/layout/header.js +51 -60
- package/lib/layout/index.js +15 -12
- package/lib/locale/en-US/messages.json +2 -0
- package/lib/locale/format-message.js +1 -1
- package/lib/locale/id-ID/messages.json +2 -0
- package/lib/locale/index.js +4 -4
- package/lib/locale/locale-provider.js +9 -11
- package/lib/locale/th-TH/messages.json +2 -0
- package/lib/locale/vi-VN/messages.json +2 -0
- package/lib/locale/zh-CN/messages.json +2 -0
- package/lib/login-page/index.js +30 -42
- package/lib/media/index.js +20 -27
- package/lib/media/media.js +9 -12
- package/lib/media/preview.js +8 -10
- package/lib/mobile-insurer-detail/index.js +74 -91
- package/lib/mobile-insurer-list/index.js +34 -38
- package/lib/modal/index.d.ts +4 -3
- package/lib/modal/index.js +25 -27
- package/lib/modal/style/index.less +24 -5
- package/lib/platform/platform-card/index.js +9 -12
- package/lib/platform/switch-platform/index.js +24 -32
- package/lib/policy-list/index.js +11 -14
- package/lib/policy-list/policy-card.js +119 -153
- package/lib/radio/index.js +33 -35
- package/lib/select/attached-select.js +32 -35
- package/lib/select/select.js +13 -9
- package/lib/select/style/index.less +1 -1
- package/lib/select/time-select.js +12 -16
- package/lib/status-box/index.js +8 -10
- package/lib/table/index.js +72 -96
- package/lib/tabs/index.js +8 -2
- package/lib/types.d.ts +4 -2
- package/lib/typography/index.js +6 -8
- package/lib/upload/index.d.ts +2 -1
- package/lib/upload/index.js +170 -143
- package/lib/upload-photo/index.d.ts +2 -1
- package/lib/upload-photo/index.js +171 -142
- package/lib/upload-photo/media.js +3 -4
- package/lib/upload-preview/index.js +9 -12
- package/lib/upload-preview/media.js +12 -16
- package/lib/upload-preview/style/index.less +2 -2
- package/lib/utils/form-utils.js +49 -37
- package/package.json +1 -1
- package/es/free-form/context.d.ts +0 -19
- package/es/free-form/context.js +0 -7
- package/lib/free-form/context.d.ts +0 -19
- package/lib/free-form/context.js +0 -19
package/lib/upload/index.js
CHANGED
|
@@ -37,15 +37,17 @@ var _locale = require("../locale");
|
|
|
37
37
|
|
|
38
38
|
var _media = _interopRequireDefault(require("../upload-preview/media"));
|
|
39
39
|
|
|
40
|
-
var
|
|
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";
|
|
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);
|
|
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]
|
|
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(
|
|
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
|
|
141
|
-
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
|
|
199
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(file) {
|
|
155
200
|
var dataUrl, name, size, type, uid, errorMsg;
|
|
156
|
-
return regeneratorRuntime.wrap(function
|
|
201
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
157
202
|
while (1) {
|
|
158
|
-
switch (
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
302
|
+
return _context2.stop();
|
|
258
303
|
}
|
|
259
304
|
}
|
|
260
|
-
},
|
|
305
|
+
}, _callee2);
|
|
261
306
|
}));
|
|
262
307
|
|
|
263
|
-
return function onUpload(
|
|
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
|
|
314
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(file, onSuccess, onFailed) {
|
|
270
315
|
var rst, errorMsg;
|
|
271
|
-
return regeneratorRuntime.wrap(function
|
|
316
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
272
317
|
while (1) {
|
|
273
|
-
switch (
|
|
318
|
+
switch (_context3.prev = _context3.next) {
|
|
274
319
|
case 0:
|
|
275
|
-
|
|
276
|
-
|
|
320
|
+
_context3.prev = 0;
|
|
321
|
+
_context3.next = 3;
|
|
277
322
|
return handleUpload(file);
|
|
278
323
|
|
|
279
324
|
case 3:
|
|
280
|
-
rst =
|
|
325
|
+
rst = _context3.sent;
|
|
281
326
|
onSuccess(rst);
|
|
282
|
-
return
|
|
327
|
+
return _context3.abrupt("return", Promise.resolve(rst));
|
|
283
328
|
|
|
284
329
|
case 8:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
errorMsg = _typeof(
|
|
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
|
|
334
|
+
return _context3.abrupt("return", Promise.reject(errorMsg));
|
|
290
335
|
|
|
291
336
|
case 13:
|
|
292
337
|
case "end":
|
|
293
|
-
return
|
|
338
|
+
return _context3.stop();
|
|
294
339
|
}
|
|
295
340
|
}
|
|
296
|
-
},
|
|
341
|
+
}, _callee3, null, [[0, 8]]);
|
|
297
342
|
}));
|
|
298
343
|
|
|
299
|
-
return function handleUploadPromise(
|
|
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
|
|
351
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(index) {
|
|
307
352
|
var arr, hasError, rst;
|
|
308
|
-
return regeneratorRuntime.wrap(function
|
|
353
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
309
354
|
while (1) {
|
|
310
|
-
switch (
|
|
355
|
+
switch (_context4.prev = _context4.next) {
|
|
311
356
|
case 0:
|
|
312
357
|
limitNumError.current = null;
|
|
313
358
|
arr = files;
|
|
314
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
398
|
+
return _context4.stop();
|
|
354
399
|
}
|
|
355
400
|
}
|
|
356
|
-
},
|
|
401
|
+
}, _callee4);
|
|
357
402
|
}));
|
|
358
403
|
|
|
359
|
-
return function handleDelete(
|
|
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
|
|
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
|
|
413
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
369
414
|
while (1) {
|
|
370
|
-
switch (
|
|
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
|
-
|
|
420
|
+
_context5.next = 3;
|
|
376
421
|
break;
|
|
377
422
|
}
|
|
378
423
|
|
|
379
|
-
return
|
|
424
|
+
return _context5.abrupt("return");
|
|
380
425
|
|
|
381
426
|
case 3:
|
|
382
|
-
|
|
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
|
-
|
|
392
|
-
|
|
436
|
+
_context5.prev = 5;
|
|
437
|
+
_context5.next = 8;
|
|
393
438
|
return handleUpload(originFile);
|
|
394
439
|
|
|
395
440
|
case 8:
|
|
396
|
-
rst =
|
|
441
|
+
rst = _context5.sent;
|
|
397
442
|
latestFiles = [];
|
|
398
|
-
|
|
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
|
-
|
|
471
|
+
_context5.next = 23;
|
|
427
472
|
break;
|
|
428
473
|
|
|
429
474
|
case 16:
|
|
430
|
-
|
|
431
|
-
|
|
475
|
+
_context5.prev = 16;
|
|
476
|
+
_context5.t0 = _context5["catch"](5);
|
|
432
477
|
newList = [];
|
|
433
|
-
|
|
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 =
|
|
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
|
|
509
|
+
return _context5.stop();
|
|
465
510
|
}
|
|
466
511
|
}
|
|
467
|
-
},
|
|
512
|
+
}, _callee5, null, [[5, 16]]);
|
|
468
513
|
}));
|
|
469
514
|
|
|
470
|
-
return function handleReUpload(
|
|
515
|
+
return function handleReUpload(_x7) {
|
|
471
516
|
return _ref6.apply(this, arguments);
|
|
472
517
|
};
|
|
473
518
|
}();
|
|
@@ -490,65 +535,57 @@ var IglooUpload = function IglooUpload(_ref) {
|
|
|
490
535
|
});
|
|
491
536
|
};
|
|
492
537
|
|
|
493
|
-
return (0, _jsxRuntime.jsxs)("div",
|
|
538
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
494
539
|
className: (0, _classnames.default)('igloo-upload', className),
|
|
495
540
|
id: rest.id,
|
|
496
|
-
ref: DomRef
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
className: "igloo-upload-descriptions"
|
|
500
|
-
}, {
|
|
541
|
+
ref: DomRef,
|
|
542
|
+
children: [descriptions && (0, _jsxRuntime.jsx)("div", {
|
|
543
|
+
className: "igloo-upload-descriptions",
|
|
501
544
|
children: descriptions
|
|
502
|
-
}
|
|
545
|
+
}, void 0), (0, _jsxRuntime.jsx)(Dragger, _objectSpread(_objectSpread({
|
|
503
546
|
action: onUpload
|
|
504
|
-
}, rest, {
|
|
547
|
+
}, rest), {}, {
|
|
505
548
|
showUploadList: false,
|
|
506
549
|
className: "igloo-upload-box",
|
|
507
550
|
customRequest: function customRequest() {},
|
|
508
|
-
multiple: true
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
className: "igloo-upload-box-center"
|
|
512
|
-
}, {
|
|
551
|
+
multiple: true,
|
|
552
|
+
children: (0, _jsxRuntime.jsxs)("div", {
|
|
553
|
+
className: "igloo-upload-box-center",
|
|
513
554
|
children: [(0, _jsxRuntime.jsx)(_iglooicon.UploadOutlined, {
|
|
514
555
|
style: {
|
|
515
556
|
marginRight: 16,
|
|
516
557
|
fontSize: 24,
|
|
517
558
|
color: '#666666'
|
|
518
559
|
}
|
|
519
|
-
}, void 0), (0, _jsxRuntime.jsx)("span",
|
|
520
|
-
className: "igloo-upload-placeholder"
|
|
521
|
-
}, {
|
|
560
|
+
}, void 0), (0, _jsxRuntime.jsx)("span", {
|
|
561
|
+
className: "igloo-upload-placeholder",
|
|
522
562
|
children: placeholder || (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
523
|
-
children: [(0, _jsxRuntime.jsx)(_typography.default,
|
|
524
|
-
level: "body1"
|
|
525
|
-
}, {
|
|
563
|
+
children: [(0, _jsxRuntime.jsx)(_typography.default, {
|
|
564
|
+
level: "body1",
|
|
526
565
|
children: formatMessage({
|
|
527
566
|
id: 'Drag and drop a file here'
|
|
528
567
|
})
|
|
529
|
-
}
|
|
568
|
+
}, void 0), (0, _jsxRuntime.jsx)(_typography.default, {
|
|
530
569
|
level: "body1",
|
|
531
570
|
style: {
|
|
532
571
|
marginLeft: 4
|
|
533
|
-
}
|
|
534
|
-
}, {
|
|
572
|
+
},
|
|
535
573
|
children: formatMessage({
|
|
536
574
|
id: 'or'
|
|
537
575
|
})
|
|
538
|
-
}
|
|
576
|
+
}, void 0), (0, _jsxRuntime.jsx)(_typography.default, {
|
|
539
577
|
level: "body1",
|
|
540
578
|
style: {
|
|
541
579
|
color: _iglootheme.colors.purpleMain,
|
|
542
580
|
marginLeft: 4
|
|
543
|
-
}
|
|
544
|
-
}, {
|
|
581
|
+
},
|
|
545
582
|
children: formatMessage({
|
|
546
583
|
id: 'browse'
|
|
547
584
|
})
|
|
548
|
-
}
|
|
585
|
+
}, void 0)]
|
|
549
586
|
}, void 0)
|
|
550
|
-
}
|
|
551
|
-
}
|
|
587
|
+
}, void 0)]
|
|
588
|
+
}, void 0)
|
|
552
589
|
}), void 0), !!files.length && (0, _jsxRuntime.jsx)(FileList, {
|
|
553
590
|
files: files,
|
|
554
591
|
limit: limit,
|
|
@@ -557,7 +594,7 @@ var IglooUpload = function IglooUpload(_ref) {
|
|
|
557
594
|
handleDelete: handleDelete,
|
|
558
595
|
containerRef: containerRef
|
|
559
596
|
}, void 0)]
|
|
560
|
-
}
|
|
597
|
+
}, void 0);
|
|
561
598
|
};
|
|
562
599
|
|
|
563
600
|
var FileList = function FileList(_ref7) {
|
|
@@ -577,22 +614,19 @@ var FileList = function FileList(_ref7) {
|
|
|
577
614
|
return setInitDone(true);
|
|
578
615
|
}, [containerRef.current]);
|
|
579
616
|
if (!initDone) return null;
|
|
580
|
-
var children = (0, _jsxRuntime.jsx)("div",
|
|
581
|
-
className: "igloo-upload-preview-list"
|
|
582
|
-
}, {
|
|
617
|
+
var children = (0, _jsxRuntime.jsx)("div", {
|
|
618
|
+
className: "igloo-upload-preview-list",
|
|
583
619
|
children: files.map(function (_ref8, index) {
|
|
584
620
|
var type = _ref8.type,
|
|
585
621
|
name = _ref8.name,
|
|
586
622
|
size = _ref8.size,
|
|
587
623
|
status = _ref8.status;
|
|
588
|
-
return (0, _jsxRuntime.jsxs)("div",
|
|
624
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
589
625
|
className: (0, _classnames.default)('igloo-upload-preview-item', {
|
|
590
626
|
'igloo-upload-preview-item-failed': status === 'failed'
|
|
591
|
-
})
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
className: "igloo-upload-preview-item-info"
|
|
595
|
-
}, {
|
|
627
|
+
}),
|
|
628
|
+
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
629
|
+
className: "igloo-upload-preview-item-info",
|
|
596
630
|
children: [status !== 'progress' && (0, _jsxRuntime.jsx)(_iglooicon.FileOutlined, {
|
|
597
631
|
style: {
|
|
598
632
|
marginRight: 8,
|
|
@@ -607,30 +641,24 @@ var FileList = function FileList(_ref7) {
|
|
|
607
641
|
fontSize: 24,
|
|
608
642
|
color: '#999999'
|
|
609
643
|
}
|
|
610
|
-
}, void 0), (0, _jsxRuntime.jsxs)("div",
|
|
611
|
-
className: "igloo-upload-preview-item-text"
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
children: (0, _jsxRuntime.jsx)(_typography.default, Object.assign({
|
|
617
|
-
level: "h4"
|
|
618
|
-
}, {
|
|
644
|
+
}, void 0), (0, _jsxRuntime.jsxs)("div", {
|
|
645
|
+
className: "igloo-upload-preview-item-text",
|
|
646
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
647
|
+
className: "igloo-upload-preview-item-name",
|
|
648
|
+
children: (0, _jsxRuntime.jsx)(_typography.default, {
|
|
649
|
+
level: "h4",
|
|
619
650
|
children: name
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
className: "igloo-upload-preview-item-size"
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
level: "body1"
|
|
626
|
-
}, {
|
|
651
|
+
}, void 0)
|
|
652
|
+
}, void 0), Boolean(size) && (0, _jsxRuntime.jsx)("span", {
|
|
653
|
+
className: "igloo-upload-preview-item-size",
|
|
654
|
+
children: (0, _jsxRuntime.jsx)(_typography.default, {
|
|
655
|
+
level: "body1",
|
|
627
656
|
children: (0, _tools.parseFileSize)(size)
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
className: "igloo-upload-preview-item-operation"
|
|
633
|
-
}, {
|
|
657
|
+
}, void 0)
|
|
658
|
+
}, void 0)]
|
|
659
|
+
}, void 0)]
|
|
660
|
+
}, void 0), status === 'success' && (0, _jsxRuntime.jsxs)("div", {
|
|
661
|
+
className: "igloo-upload-preview-item-operation",
|
|
634
662
|
children: [type && (0, _jsxRuntime.jsx)(_iglooicon.ShowOutlined, {
|
|
635
663
|
style: {
|
|
636
664
|
fontSize: 24,
|
|
@@ -651,9 +679,8 @@ var FileList = function FileList(_ref7) {
|
|
|
651
679
|
return handleDelete(index);
|
|
652
680
|
}
|
|
653
681
|
}, void 0)]
|
|
654
|
-
}
|
|
655
|
-
className: "igloo-upload-preview-item-operation"
|
|
656
|
-
}, {
|
|
682
|
+
}, void 0), status === 'failed' && (0, _jsxRuntime.jsxs)("div", {
|
|
683
|
+
className: "igloo-upload-preview-item-operation",
|
|
657
684
|
children: [(!limit || index < limit) && (0, _jsxRuntime.jsx)(_iglooicon.RefreshOutlined, {
|
|
658
685
|
style: {
|
|
659
686
|
fontSize: 24,
|
|
@@ -674,10 +701,10 @@ var FileList = function FileList(_ref7) {
|
|
|
674
701
|
return handleDelete(index);
|
|
675
702
|
}
|
|
676
703
|
}, void 0)]
|
|
677
|
-
}
|
|
678
|
-
}
|
|
704
|
+
}, void 0)]
|
|
705
|
+
}, index);
|
|
679
706
|
})
|
|
680
|
-
}
|
|
707
|
+
}, void 0);
|
|
681
708
|
return /*#__PURE__*/_reactDom.default.createPortal(children, containerRef.current);
|
|
682
709
|
};
|
|
683
710
|
|
|
@@ -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;
|