iglooform 2.4.9 → 2.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/admin-upload/index.d.ts +2 -0
- package/es/admin-upload/index.js +25 -11
- package/es/admin-upload/job-list.js +2 -2
- package/es/alert-message/index.js +2 -2
- package/es/amount/index.js +2 -2
- package/es/back-top/index.js +2 -2
- package/es/button/index.js +2 -2
- package/es/button/style/index.less +23 -19
- package/es/card-detail/card-item.js +1 -1
- package/es/card-detail/card.js +2 -2
- package/es/card-detail/utils.js +3 -3
- package/es/checkbox/index.js +2 -2
- package/es/claim-list/index.js +2 -2
- package/es/confirmation/index.js +2 -2
- package/es/date-picker/buddhist.js +2 -2
- package/es/date-picker/index.js +2 -2
- package/es/declaration/index.js +2 -2
- package/es/detail-panel/index.js +2 -2
- package/es/example/index.js +6 -7
- package/es/filter/index.d.ts +1 -0
- package/es/filter/index.js +10 -6
- 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 +2 -2
- package/es/form/element/index.js +30 -11
- package/es/form/element/style/index.less +5 -0
- package/es/form/index.js +7 -5
- package/es/form/login/index.js +1 -1
- package/es/form/page/index.js +1 -1
- package/es/form/page/style/index.less +1 -1
- package/es/form/pages/index.js +2 -3
- package/es/form/pages/style/index.less +3 -1
- package/es/form/render/index.js +1 -1
- package/es/form/section/index.js +4 -4
- package/es/form/step/index.js +1 -1
- package/es/form/steps/index.js +2 -3
- 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 +22 -14
- package/es/free-form/element/style/index.less +8 -2
- package/es/free-form/index.d.ts +5 -1
- package/es/free-form/index.js +8 -5
- package/es/free-form/page/index.js +8 -7
- package/es/free-form/page/style/index.less +3 -1
- package/es/free-form/pages/index.js +2 -2
- package/es/free-form/section/index.js +10 -9
- package/es/free-form/section/style/index.less +4 -0
- package/es/free-form/step/index.js +7 -6
- package/es/free-form/steps/index.js +2 -2
- package/es/global-message/index.js +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/input/amount.js +2 -2
- package/es/input/credit-card.js +2 -2
- package/es/input/email.js +2 -2
- package/es/input/expiry-date.js +2 -2
- package/es/input/input-number.js +2 -2
- package/es/input/input.js +2 -2
- package/es/input/otp.js +2 -2
- package/es/input/password.js +2 -2
- package/es/input/style/index.less +9 -1
- package/es/input/text-area.js +2 -2
- package/es/layout/header.js +3 -3
- package/es/layout/index.js +2 -2
- package/es/locale/en-US/messages.json +2 -0
- package/es/locale/id-ID/messages.json +2 -0
- package/es/locale/locale-provider.js +2 -2
- 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/media/preview.js +2 -2
- package/es/mobile-insurer-detail/index.js +2 -2
- package/es/mobile-insurer-list/index.js +2 -2
- package/es/modal/index.d.ts +4 -3
- package/es/modal/index.js +6 -3
- package/es/modal/style/index.less +24 -5
- package/es/policy-list/index.js +2 -2
- package/es/policy-list/policy-card.js +2 -2
- package/es/radio/index.js +2 -2
- package/es/select/attached-select.js +2 -2
- package/es/select/select.js +2 -2
- package/es/select/style/index.less +1 -1
- package/es/status-box/index.js +2 -2
- package/es/table/index.js +3 -3
- package/es/tabs/index.js +2 -2
- package/es/tabs/style/index.less +1 -1
- package/es/types.d.ts +5 -2
- package/es/upload/index.d.ts +2 -1
- package/es/upload/index.js +121 -77
- package/es/upload-photo/index.d.ts +2 -1
- package/es/upload-photo/index.js +123 -79
- package/es/utils/form-utils.d.ts +1 -0
- package/es/utils/form-utils.js +34 -12
- package/lib/admin-upload/index.d.ts +2 -0
- package/lib/admin-upload/index.js +25 -11
- package/lib/admin-upload/job-list.js +2 -2
- package/lib/alert-message/index.js +2 -2
- package/lib/amount/index.js +2 -2
- package/lib/back-top/index.js +2 -2
- package/lib/button/index.js +2 -2
- package/lib/button/style/index.less +23 -19
- package/lib/card-detail/card-item.js +1 -1
- package/lib/card-detail/card.js +2 -2
- package/lib/card-detail/utils.js +3 -3
- package/lib/checkbox/index.js +2 -2
- package/lib/claim-list/index.js +2 -2
- package/lib/confirmation/index.js +2 -2
- package/lib/date-picker/buddhist.js +2 -2
- package/lib/date-picker/index.js +2 -2
- package/lib/declaration/index.js +2 -2
- package/lib/detail-panel/index.js +2 -2
- package/lib/example/index.js +7 -8
- package/lib/filter/index.d.ts +1 -0
- package/lib/filter/index.js +10 -6
- 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 +2 -2
- package/lib/form/element/index.js +32 -12
- package/lib/form/element/style/index.less +5 -0
- package/lib/form/elements.js +1 -1
- package/lib/form/index.js +8 -6
- package/lib/form/login/index.js +2 -2
- package/lib/form/page/index.js +2 -2
- package/lib/form/page/style/index.less +1 -1
- package/lib/form/pages/index.js +3 -4
- package/lib/form/pages/style/index.less +3 -1
- package/lib/form/render/index.js +2 -2
- package/lib/form/section/index.js +5 -5
- package/lib/form/step/index.js +2 -2
- package/lib/form/steps/index.js +3 -4
- 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 +23 -15
- package/lib/free-form/element/style/index.less +8 -2
- package/lib/free-form/index.d.ts +5 -1
- package/lib/free-form/index.js +9 -6
- package/lib/free-form/page/index.js +9 -8
- package/lib/free-form/page/style/index.less +3 -1
- package/lib/free-form/pages/index.js +2 -2
- package/lib/free-form/section/index.js +11 -10
- package/lib/free-form/section/style/index.less +4 -0
- package/lib/free-form/step/index.js +8 -7
- package/lib/free-form/steps/index.js +3 -3
- package/lib/global-message/index.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +11 -2
- package/lib/input/amount.js +2 -2
- package/lib/input/credit-card.js +2 -2
- package/lib/input/email.js +2 -2
- package/lib/input/expiry-date.js +2 -2
- package/lib/input/input-number.js +2 -2
- package/lib/input/input.js +2 -2
- package/lib/input/otp.js +2 -2
- package/lib/input/password.js +2 -2
- package/lib/input/style/index.less +9 -1
- package/lib/input/text-area.js +2 -2
- package/lib/layout/header.js +3 -3
- package/lib/layout/index.js +2 -2
- package/lib/locale/en-US/messages.json +2 -0
- package/lib/locale/id-ID/messages.json +2 -0
- package/lib/locale/locale-provider.js +2 -2
- 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/media/preview.js +2 -2
- package/lib/mobile-insurer-detail/index.js +2 -2
- package/lib/mobile-insurer-list/index.js +2 -2
- package/lib/modal/index.d.ts +4 -3
- package/lib/modal/index.js +6 -3
- package/lib/modal/style/index.less +24 -5
- package/lib/policy-list/index.js +2 -2
- package/lib/policy-list/policy-card.js +2 -2
- package/lib/radio/index.js +2 -2
- package/lib/select/attached-select.js +2 -2
- package/lib/select/select.js +2 -2
- package/lib/select/style/index.less +1 -1
- package/lib/status-box/index.js +2 -2
- package/lib/table/index.js +3 -3
- package/lib/tabs/index.js +2 -2
- package/lib/tabs/style/index.less +1 -1
- package/lib/types.d.ts +5 -2
- package/lib/upload/index.d.ts +2 -1
- package/lib/upload/index.js +122 -77
- package/lib/upload-photo/index.d.ts +2 -1
- package/lib/upload-photo/index.js +124 -79
- package/lib/utils/form-utils.d.ts +1 -0
- package/lib/utils/form-utils.js +33 -12
- 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/es/upload-photo/index.js
CHANGED
|
@@ -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";
|
|
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);
|
|
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]
|
|
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(
|
|
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(
|
|
84
|
-
|
|
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
|
|
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
|
|
238
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
195
239
|
while (1) {
|
|
196
|
-
switch (
|
|
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
|
-
|
|
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
|
|
257
|
+
return _context2.abrupt("return", Promise.reject(errorMsg));
|
|
214
258
|
|
|
215
259
|
case 9:
|
|
216
260
|
if (!(limit && currentIndex > limit)) {
|
|
217
|
-
|
|
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
|
|
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
|
|
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
|
|
351
|
+
return _context2.stop();
|
|
308
352
|
}
|
|
309
353
|
}
|
|
310
|
-
},
|
|
354
|
+
}, _callee2);
|
|
311
355
|
}));
|
|
312
356
|
|
|
313
|
-
return function uploadFile(
|
|
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
|
|
363
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(file, onSuccess, onFailed) {
|
|
320
364
|
var rst, errorMsg;
|
|
321
|
-
return regeneratorRuntime.wrap(function
|
|
365
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
322
366
|
while (1) {
|
|
323
|
-
switch (
|
|
367
|
+
switch (_context3.prev = _context3.next) {
|
|
324
368
|
case 0:
|
|
325
|
-
|
|
326
|
-
|
|
369
|
+
_context3.prev = 0;
|
|
370
|
+
_context3.next = 3;
|
|
327
371
|
return handleUpload(file);
|
|
328
372
|
|
|
329
373
|
case 3:
|
|
330
|
-
rst =
|
|
374
|
+
rst = _context3.sent;
|
|
331
375
|
onSuccess(rst);
|
|
332
|
-
return
|
|
376
|
+
return _context3.abrupt("return", Promise.resolve(rst));
|
|
333
377
|
|
|
334
378
|
case 8:
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
errorMsg = _typeof(
|
|
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
|
|
383
|
+
return _context3.abrupt("return", Promise.reject(errorMsg));
|
|
340
384
|
|
|
341
385
|
case 13:
|
|
342
386
|
case "end":
|
|
343
|
-
return
|
|
387
|
+
return _context3.stop();
|
|
344
388
|
}
|
|
345
389
|
}
|
|
346
|
-
},
|
|
390
|
+
}, _callee3, null, [[0, 8]]);
|
|
347
391
|
}));
|
|
348
392
|
|
|
349
|
-
return function handleUploadPromise(
|
|
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
|
|
399
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(index) {
|
|
356
400
|
var arr, hasError, rst;
|
|
357
|
-
return regeneratorRuntime.wrap(function
|
|
401
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
358
402
|
while (1) {
|
|
359
|
-
switch (
|
|
403
|
+
switch (_context4.prev = _context4.next) {
|
|
360
404
|
case 0:
|
|
361
405
|
limitNumError.current = null;
|
|
362
406
|
arr = files;
|
|
363
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
454
|
+
return _context4.stop();
|
|
411
455
|
}
|
|
412
456
|
}
|
|
413
|
-
},
|
|
457
|
+
}, _callee4);
|
|
414
458
|
}));
|
|
415
459
|
|
|
416
|
-
return function handleDelete(
|
|
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
|
|
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
|
|
469
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
426
470
|
while (1) {
|
|
427
|
-
switch (
|
|
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
|
-
|
|
476
|
+
_context5.next = 3;
|
|
433
477
|
break;
|
|
434
478
|
}
|
|
435
479
|
|
|
436
|
-
return
|
|
480
|
+
return _context5.abrupt("return");
|
|
437
481
|
|
|
438
482
|
case 3:
|
|
439
|
-
|
|
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
|
-
|
|
449
|
-
|
|
492
|
+
_context5.prev = 5;
|
|
493
|
+
_context5.next = 8;
|
|
450
494
|
return handleUpload(originFile);
|
|
451
495
|
|
|
452
496
|
case 8:
|
|
453
|
-
rst =
|
|
497
|
+
rst = _context5.sent;
|
|
454
498
|
latestFiles = [];
|
|
455
|
-
|
|
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
|
-
|
|
527
|
+
_context5.next = 23;
|
|
484
528
|
break;
|
|
485
529
|
|
|
486
530
|
case 16:
|
|
487
|
-
|
|
488
|
-
|
|
531
|
+
_context5.prev = 16;
|
|
532
|
+
_context5.t0 = _context5["catch"](5);
|
|
489
533
|
newList = [];
|
|
490
|
-
|
|
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 =
|
|
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
|
|
570
|
+
return _context5.stop();
|
|
527
571
|
}
|
|
528
572
|
}
|
|
529
|
-
},
|
|
573
|
+
}, _callee5, null, [[5, 16]]);
|
|
530
574
|
}));
|
|
531
575
|
|
|
532
|
-
return function handleReUpload(
|
|
576
|
+
return function handleReUpload(_x8) {
|
|
533
577
|
return _ref7.apply(this, arguments);
|
|
534
578
|
};
|
|
535
579
|
}();
|
package/es/utils/form-utils.d.ts
CHANGED
package/es/utils/form-utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var _excluded = ["type", "name", "required", "showOptional", "rules", "initialValue", "normalize", "mergeRules", "getValueFromEvent", "getValueProps", "extra", "help", "label", "previewLabel", "extraLabel", "copyValue", "selectValue", "span", "halfRow", "fullRow", "valuePropName", "dependencies", "asserts", "messageVariables", "requiredMessage", "previewFormater", "disabled", "ignore", "shouldRender", "valueFormater"],
|
|
1
|
+
var _excluded = ["type", "name", "required", "requiredAsserts", "showOptional", "rules", "initialValue", "normalize", "mergeRules", "getValueFromEvent", "getValueProps", "extra", "help", "label", "previewLabel", "extraLabel", "copyValue", "selectValue", "span", "halfRow", "fullRow", "valuePropName", "dependencies", "asserts", "messageVariables", "requiredMessage", "previewFormater", "disabled", "ignore", "shouldRender", "valueFormater", "antdDependencies"],
|
|
2
2
|
_excluded2 = ["initialValue", "normalize", "rules", "extra", "help", "getValueFromEvent", "span", "valuePropName", "fullRow", "halfRow", "messageVariables", "requiredMessage", "previewFormater", "valueFormater", "required", "requiredMark", "className"];
|
|
3
3
|
|
|
4
4
|
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(_e) { throw _e; }, 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(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
5
5
|
|
|
6
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
6
|
+
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; }
|
|
7
7
|
|
|
8
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
8
|
+
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; }
|
|
9
9
|
|
|
10
10
|
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; }
|
|
11
11
|
|
|
@@ -36,7 +36,7 @@ export var calcNamePath = function calcNamePath(parentName, name) {
|
|
|
36
36
|
names.push(parentName);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
if (name) {
|
|
39
|
+
if (name !== undefined) {
|
|
40
40
|
names.push(name);
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -45,9 +45,8 @@ export var calcNamePath = function calcNamePath(parentName, name) {
|
|
|
45
45
|
export var testAssert = function testAssert(form, assert) {
|
|
46
46
|
var field = assert.field,
|
|
47
47
|
value = assert.value,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var v = form.getFieldValue(field);
|
|
48
|
+
operation = assert.operation;
|
|
49
|
+
var v = form.getFieldValue(typeof field === 'string' ? field.split('.') : field);
|
|
51
50
|
|
|
52
51
|
switch (operation) {
|
|
53
52
|
case 'ne':
|
|
@@ -86,18 +85,39 @@ export var testAssert = function testAssert(form, assert) {
|
|
|
86
85
|
if (v === undefined || v < value) return false;
|
|
87
86
|
break;
|
|
88
87
|
|
|
88
|
+
case 'filled':
|
|
89
|
+
return v !== undefined;
|
|
90
|
+
|
|
89
91
|
case 'eq':
|
|
92
|
+
return v === value;
|
|
93
|
+
|
|
90
94
|
default:
|
|
91
|
-
if (
|
|
95
|
+
if (value !== undefined) return v === value;
|
|
96
|
+
return v !== undefined;
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
return true;
|
|
95
100
|
};
|
|
101
|
+
|
|
102
|
+
var calcRequired = function calcRequired() {
|
|
103
|
+
var required = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
104
|
+
var form = arguments.length > 1 ? arguments[1] : undefined;
|
|
105
|
+
var requiredAsserts = arguments.length > 2 ? arguments[2] : undefined;
|
|
106
|
+
|
|
107
|
+
if (Array.isArray(requiredAsserts)) {
|
|
108
|
+
return requiredAsserts.every(function (assert) {
|
|
109
|
+
return form && testAssert(form, assert);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return required;
|
|
114
|
+
};
|
|
115
|
+
|
|
96
116
|
export var calcFormItemProps = function calcFormItemProps(config, extraProps, form, parentName) {
|
|
97
117
|
var type = config.type,
|
|
98
118
|
nameProp = config.name,
|
|
99
|
-
|
|
100
|
-
|
|
119
|
+
required = config.required,
|
|
120
|
+
requiredAsserts = config.requiredAsserts,
|
|
101
121
|
_config$showOptional = config.showOptional,
|
|
102
122
|
showOptional = _config$showOptional === void 0 ? false : _config$showOptional,
|
|
103
123
|
_config$rules = config.rules,
|
|
@@ -130,6 +150,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
|
|
|
130
150
|
ignore = config.ignore,
|
|
131
151
|
shouldRender = config.shouldRender,
|
|
132
152
|
valueFormater = config.valueFormater,
|
|
153
|
+
antdDependencies = config.antdDependencies,
|
|
133
154
|
rest = _objectWithoutProperties(config, _excluded);
|
|
134
155
|
|
|
135
156
|
invariant(nameProp || type === 'Divider' || type === 'Section' || !type, "name property is required for form item config (type: ".concat(type, ")"));
|
|
@@ -161,7 +182,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
|
|
|
161
182
|
className = extraProps.className,
|
|
162
183
|
extraRest = _objectWithoutProperties(extraProps, _excluded2);
|
|
163
184
|
|
|
164
|
-
var rules = required
|
|
185
|
+
var rules = calcRequired(required, form, requiredAsserts) ? [{
|
|
165
186
|
required: true,
|
|
166
187
|
message: requiredMessage || extraRequiredMessage
|
|
167
188
|
}].concat(_toConsumableArray(propsRules)) : _toConsumableArray(propsRules);
|
|
@@ -237,7 +258,8 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
|
|
|
237
258
|
valuePropName: valuePropName || extraValuePropName,
|
|
238
259
|
messageVariables: _objectSpread({
|
|
239
260
|
label: label
|
|
240
|
-
}, messageVariables || extraMessageVariables)
|
|
261
|
+
}, messageVariables || extraMessageVariables),
|
|
262
|
+
dependencies: antdDependencies
|
|
241
263
|
},
|
|
242
264
|
elementProps: elementProps,
|
|
243
265
|
display: !ignore && calcShouldRender(dependencies, asserts, shouldRender, form),
|
|
@@ -2,6 +2,7 @@ import { FC } from 'react';
|
|
|
2
2
|
import { RequestMethod } from 'umi-request';
|
|
3
3
|
import { IglooButtonProps } from '../button';
|
|
4
4
|
import { UploadProps } from 'antd/es/upload';
|
|
5
|
+
import { Job } from './job-list';
|
|
5
6
|
import './style';
|
|
6
7
|
export interface AdminUploadProps {
|
|
7
8
|
dataSource: string | {
|
|
@@ -29,6 +30,7 @@ export interface AdminUploadProps {
|
|
|
29
30
|
done: number;
|
|
30
31
|
}) => string;
|
|
31
32
|
selectPlaceholder?: string;
|
|
33
|
+
onFinish?: (jobs: Job[]) => any;
|
|
32
34
|
}
|
|
33
35
|
declare const AdminUpload: FC<AdminUploadProps>;
|
|
34
36
|
export default AdminUpload;
|