iglooform 2.5.51 → 2.5.53
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/.idea/iglooform.iml +9 -0
- package/.idea/misc.xml +5 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/es/free-form/step/index.js +1 -1
- package/es/input/email.js +24 -4
- package/es/input/text-area.js +1 -9
- package/es/upload/index.js +59 -139
- package/es/upload-photo/index.js +59 -137
- package/es/utils/form-methods.js +1 -1
- package/lib/free-form/step/index.js +1 -1
- package/lib/input/email.js +25 -4
- package/lib/input/text-area.js +1 -9
- package/lib/upload/index.js +59 -139
- package/lib/upload-photo/index.js +59 -137
- package/lib/utils/form-methods.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
package/.idea/misc.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/iglooform.iml" filepath="$PROJECT_DIR$/.idea/iglooform.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
|
@@ -98,7 +98,7 @@ var Step = function Step(_ref) {
|
|
|
98
98
|
|
|
99
99
|
invariant(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
|
|
100
100
|
useEffect(function () {
|
|
101
|
-
if (shouldRender || getButtonDisabledState) {
|
|
101
|
+
if (shouldRender || getButtonDisabledState || shouldRenderCode) {
|
|
102
102
|
registerDependencies(Array.isArray(subscribedFields) ? subscribedFields : 'SUBSCRIBE_ALL', dispatch);
|
|
103
103
|
}
|
|
104
104
|
|
package/es/input/email.js
CHANGED
|
@@ -10,6 +10,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import omit from 'omit.js';
|
|
12
12
|
import formMethods from '../utils/form-methods';
|
|
13
|
+
import { staticFormatMessage as formatMessage } from '../locale';
|
|
13
14
|
import './style/index.less';
|
|
14
15
|
|
|
15
16
|
var Email = function Email(props) {
|
|
@@ -18,11 +19,30 @@ var Email = function Email(props) {
|
|
|
18
19
|
}, omit(props, formMethods)));
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
Email.formItemPropsHandler = function () {
|
|
22
|
+
Email.formItemPropsHandler = function (config) {
|
|
23
|
+
var maxLength = config.maxLength,
|
|
24
|
+
label = config.label;
|
|
25
|
+
var rules = [{
|
|
26
|
+
type: 'email'
|
|
27
|
+
}];
|
|
28
|
+
|
|
29
|
+
if (maxLength !== undefined) {
|
|
30
|
+
rules.push({
|
|
31
|
+
validator: function validator(_, value) {
|
|
32
|
+
if (value === undefined || value === null || value === '' || String(value).length <= maxLength) return Promise.resolve();
|
|
33
|
+
return Promise.reject(formatMessage({
|
|
34
|
+
id: '{label} must be less than {maxLength} characters.',
|
|
35
|
+
values: {
|
|
36
|
+
maxLength: maxLength,
|
|
37
|
+
label: label
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
22
44
|
return {
|
|
23
|
-
rules:
|
|
24
|
-
type: 'email'
|
|
25
|
-
}]
|
|
45
|
+
rules: rules
|
|
26
46
|
};
|
|
27
47
|
};
|
|
28
48
|
|
package/es/input/text-area.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import "antd/es/input/style";
|
|
2
2
|
import _Input from "antd/es/input";
|
|
3
3
|
|
|
4
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
-
|
|
6
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
|
|
8
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
-
|
|
10
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
-
|
|
12
4
|
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; }
|
|
13
5
|
|
|
14
6
|
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; }
|
|
@@ -82,7 +74,7 @@ var IglooTextArea = function IglooTextArea(props) {
|
|
|
82
74
|
children: [_jsx(_Input.TextArea, _objectSpread(_objectSpread({
|
|
83
75
|
className: classnames('igloo-input'),
|
|
84
76
|
rows: 3
|
|
85
|
-
}, omit(props,
|
|
77
|
+
}, omit(props, formMethods)), {}, {
|
|
86
78
|
onChange: function onChange(e) {
|
|
87
79
|
return handleOnChange(e, onChangeProps, maxLength);
|
|
88
80
|
}
|
package/es/upload/index.js
CHANGED
|
@@ -168,6 +168,31 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
168
168
|
});
|
|
169
169
|
};
|
|
170
170
|
}, []);
|
|
171
|
+
useEffect(function () {
|
|
172
|
+
if (!(value === null || value === void 0 ? void 0 : value.length) && !files.length) return;
|
|
173
|
+
|
|
174
|
+
if (files.length) {
|
|
175
|
+
var urls = files.map(function (f) {
|
|
176
|
+
var status = f.status,
|
|
177
|
+
name = f.name,
|
|
178
|
+
errorMsg = f.errorMsg;
|
|
179
|
+
|
|
180
|
+
if (status === 'failed') {
|
|
181
|
+
return {
|
|
182
|
+
name: name,
|
|
183
|
+
errorMsg: errorMsg
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (f.url || f.dataUrl) {
|
|
188
|
+
return f.url || f.dataUrl;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
onChange && onChange(urls);
|
|
192
|
+
} else {
|
|
193
|
+
onChange && onChange([]);
|
|
194
|
+
}
|
|
195
|
+
}, [files]);
|
|
171
196
|
invariant(limit === undefined || limit > 0, "\"limit\" should be a pasitive number.");
|
|
172
197
|
|
|
173
198
|
var onUpload = /*#__PURE__*/function () {
|
|
@@ -197,7 +222,8 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
197
222
|
return _context2.abrupt("return", Promise.reject(errorMsg));
|
|
198
223
|
|
|
199
224
|
case 8:
|
|
200
|
-
limitNumError.current = undefined;
|
|
225
|
+
limitNumError.current = undefined; // 上传过程中 status为‘progress’,后续通过state更新
|
|
226
|
+
|
|
201
227
|
setFiles(function (files) {
|
|
202
228
|
return [].concat(_toConsumableArray(files), [{
|
|
203
229
|
name: name,
|
|
@@ -211,39 +237,21 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
211
237
|
}); // 符合文件个数限制之后 上传时的错误处理
|
|
212
238
|
|
|
213
239
|
return _context2.abrupt("return", handleUploadPromise(file, function (url) {
|
|
214
|
-
|
|
215
|
-
setFiles(function (files) {
|
|
240
|
+
return setFiles(function (files) {
|
|
216
241
|
return files.map(function (f) {
|
|
217
|
-
// 这里不能只处理成功的文件 因为这次上传的文件是成功了 但是这次之前可能会有上传失败的 需要将错误信息提取出来 否则错误提示会丢失
|
|
218
242
|
if (f.uid === uid) {
|
|
219
|
-
urls.push(url);
|
|
220
243
|
return _objectSpread(_objectSpread({}, f), {}, {
|
|
221
244
|
url: url,
|
|
222
245
|
status: 'success'
|
|
223
246
|
});
|
|
224
247
|
}
|
|
225
248
|
|
|
226
|
-
var status = f.status,
|
|
227
|
-
name = f.name,
|
|
228
|
-
errorMsg = f.errorMsg;
|
|
229
|
-
|
|
230
|
-
if (status === 'failed') {
|
|
231
|
-
urls.push({
|
|
232
|
-
name: name,
|
|
233
|
-
errorMsg: errorMsg
|
|
234
|
-
});
|
|
235
|
-
} else {
|
|
236
|
-
f.url && urls.push(f.url);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
249
|
return f;
|
|
240
250
|
});
|
|
241
251
|
});
|
|
242
|
-
onChange && onChange(urls);
|
|
243
252
|
}, function (errorMsg) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
var newList = files.map(function (f) {
|
|
253
|
+
return setFiles(function (files) {
|
|
254
|
+
return files.map(function (f) {
|
|
247
255
|
if (f.uid === uid) {
|
|
248
256
|
return _objectSpread(_objectSpread({}, f), {}, {
|
|
249
257
|
status: 'failed',
|
|
@@ -253,23 +261,7 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
253
261
|
|
|
254
262
|
return f;
|
|
255
263
|
});
|
|
256
|
-
fileList = newList;
|
|
257
|
-
return newList;
|
|
258
264
|
});
|
|
259
|
-
var fileListWithError = fileList.map(function (f) {
|
|
260
|
-
if (f.uid === uid) {
|
|
261
|
-
return {
|
|
262
|
-
name: f.name,
|
|
263
|
-
status: 'failed',
|
|
264
|
-
errorMsg: errorMsg
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return f.url;
|
|
269
|
-
}); // 需要触发onchange 在form级别报错
|
|
270
|
-
|
|
271
|
-
// 需要触发onchange 在form级别报错
|
|
272
|
-
typeof onChange === 'function' && onChange(fileListWithError);
|
|
273
265
|
}));
|
|
274
266
|
|
|
275
267
|
case 11:
|
|
@@ -324,51 +316,19 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
324
316
|
|
|
325
317
|
var handleDelete = /*#__PURE__*/function () {
|
|
326
318
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(index) {
|
|
327
|
-
var arr, hasError, rst;
|
|
328
319
|
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
329
320
|
while (1) {
|
|
330
321
|
switch (_context4.prev = _context4.next) {
|
|
331
322
|
case 0:
|
|
332
323
|
limitNumError.current = null;
|
|
333
|
-
|
|
334
|
-
_context4.next = 4;
|
|
335
|
-
return setFiles(function (files) {
|
|
324
|
+
setFiles(function (files) {
|
|
336
325
|
var newArr = files.filter(function (_, i) {
|
|
337
326
|
return i !== index;
|
|
338
327
|
});
|
|
339
|
-
arr = newArr;
|
|
340
328
|
return newArr;
|
|
341
329
|
});
|
|
342
330
|
|
|
343
|
-
case
|
|
344
|
-
// 删除之后找一下是否存在上传过程中错误的文件
|
|
345
|
-
hasError = arr.some(function (f) {
|
|
346
|
-
return f.status === 'failed';
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
if (!hasError) {
|
|
350
|
-
_context4.next = 8;
|
|
351
|
-
break;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
rst = arr.map(function (f) {
|
|
355
|
-
if (f.status === 'failed') {
|
|
356
|
-
return {
|
|
357
|
-
errorMsg: f.errorMsg
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
return f.url;
|
|
362
|
-
});
|
|
363
|
-
return _context4.abrupt("return", typeof onChange === 'function' && onChange(rst));
|
|
364
|
-
|
|
365
|
-
case 8:
|
|
366
|
-
typeof onChange === 'function' && onChange(arr.map(function (_ref5) {
|
|
367
|
-
var url = _ref5.url;
|
|
368
|
-
return url;
|
|
369
|
-
}));
|
|
370
|
-
|
|
371
|
-
case 9:
|
|
331
|
+
case 2:
|
|
372
332
|
case "end":
|
|
373
333
|
return _context4.stop();
|
|
374
334
|
}
|
|
@@ -382,8 +342,8 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
382
342
|
}();
|
|
383
343
|
|
|
384
344
|
var handleReUpload = /*#__PURE__*/function () {
|
|
385
|
-
var
|
|
386
|
-
var _files$index, originFile, reUpUid, rst
|
|
345
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(index) {
|
|
346
|
+
var _files$index, originFile, reUpUid, rst;
|
|
387
347
|
|
|
388
348
|
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
389
349
|
while (1) {
|
|
@@ -414,81 +374,41 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
414
374
|
|
|
415
375
|
case 8:
|
|
416
376
|
rst = _context5.sent;
|
|
417
|
-
|
|
418
|
-
_context5.next = 12;
|
|
377
|
+
_context5.next = 11;
|
|
419
378
|
return setFiles(function (files) {
|
|
420
379
|
var newFiles = _toConsumableArray(files);
|
|
421
380
|
|
|
422
381
|
newFiles[index].url = rst;
|
|
423
382
|
newFiles[index].status = 'success';
|
|
424
|
-
latestFiles = newFiles;
|
|
425
383
|
return newFiles;
|
|
426
384
|
});
|
|
427
385
|
|
|
428
|
-
case
|
|
429
|
-
|
|
430
|
-
fileListWithError = latestFiles.map(function (f) {
|
|
431
|
-
var status = f.status,
|
|
432
|
-
errorMsg = f.errorMsg,
|
|
433
|
-
url = f.url,
|
|
434
|
-
name = f.name;
|
|
435
|
-
|
|
436
|
-
if (status === 'failed') {
|
|
437
|
-
return {
|
|
438
|
-
errorMsg: errorMsg,
|
|
439
|
-
name: name
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
return url;
|
|
444
|
-
});
|
|
445
|
-
onChange && onChange(fileListWithError);
|
|
446
|
-
_context5.next = 23;
|
|
386
|
+
case 11:
|
|
387
|
+
_context5.next = 17;
|
|
447
388
|
break;
|
|
448
389
|
|
|
449
|
-
case
|
|
450
|
-
_context5.prev =
|
|
390
|
+
case 13:
|
|
391
|
+
_context5.prev = 13;
|
|
451
392
|
_context5.t0 = _context5["catch"](5);
|
|
452
|
-
|
|
453
|
-
_context5.next = 21;
|
|
393
|
+
_context5.next = 17;
|
|
454
394
|
return setFiles(function (files) {
|
|
455
395
|
var newFiles = _toConsumableArray(files);
|
|
456
396
|
|
|
457
397
|
newFiles[index].status = 'failed';
|
|
458
398
|
newFiles[index].errorMsg = _context5.t0;
|
|
459
|
-
newList = newFiles;
|
|
460
399
|
return newFiles;
|
|
461
400
|
});
|
|
462
401
|
|
|
463
|
-
case
|
|
464
|
-
// 报错之后要重置报错信息
|
|
465
|
-
_rst = newList.map(function (f) {
|
|
466
|
-
var name = f.name,
|
|
467
|
-
errorMsg = f.errorMsg,
|
|
468
|
-
url = f.url,
|
|
469
|
-
uid = f.uid;
|
|
470
|
-
|
|
471
|
-
if (uid === reUpUid) {
|
|
472
|
-
return {
|
|
473
|
-
name: name,
|
|
474
|
-
errorMsg: errorMsg
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
return url;
|
|
479
|
-
});
|
|
480
|
-
typeof onChange === 'function' && onChange(_rst);
|
|
481
|
-
|
|
482
|
-
case 23:
|
|
402
|
+
case 17:
|
|
483
403
|
case "end":
|
|
484
404
|
return _context5.stop();
|
|
485
405
|
}
|
|
486
406
|
}
|
|
487
|
-
}, _callee5, null, [[5,
|
|
407
|
+
}, _callee5, null, [[5, 13]]);
|
|
488
408
|
}));
|
|
489
409
|
|
|
490
410
|
return function handleReUpload(_x7) {
|
|
491
|
-
return
|
|
411
|
+
return _ref5.apply(this, arguments);
|
|
492
412
|
};
|
|
493
413
|
}();
|
|
494
414
|
|
|
@@ -572,14 +492,14 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
572
492
|
});
|
|
573
493
|
};
|
|
574
494
|
|
|
575
|
-
var FileList = function FileList(
|
|
576
|
-
var containerRef =
|
|
577
|
-
files =
|
|
578
|
-
limit =
|
|
579
|
-
handleDelete =
|
|
580
|
-
handlePreview =
|
|
581
|
-
handleReUpload =
|
|
582
|
-
disabled =
|
|
495
|
+
var FileList = function FileList(_ref6) {
|
|
496
|
+
var containerRef = _ref6.containerRef,
|
|
497
|
+
files = _ref6.files,
|
|
498
|
+
limit = _ref6.limit,
|
|
499
|
+
handleDelete = _ref6.handleDelete,
|
|
500
|
+
handlePreview = _ref6.handlePreview,
|
|
501
|
+
handleReUpload = _ref6.handleReUpload,
|
|
502
|
+
disabled = _ref6.disabled;
|
|
583
503
|
|
|
584
504
|
var _useState3 = useState(false),
|
|
585
505
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
@@ -593,11 +513,11 @@ var FileList = function FileList(_ref7) {
|
|
|
593
513
|
|
|
594
514
|
var children = _jsx("div", {
|
|
595
515
|
className: "igloo-upload-preview-list",
|
|
596
|
-
children: files.map(function (
|
|
597
|
-
var type =
|
|
598
|
-
name =
|
|
599
|
-
size =
|
|
600
|
-
status =
|
|
516
|
+
children: files.map(function (_ref7, index) {
|
|
517
|
+
var type = _ref7.type,
|
|
518
|
+
name = _ref7.name,
|
|
519
|
+
size = _ref7.size,
|
|
520
|
+
status = _ref7.status;
|
|
601
521
|
return _jsxs("div", {
|
|
602
522
|
className: classnames('igloo-upload-preview-item', {
|
|
603
523
|
'igloo-upload-preview-item-failed': status === 'failed'
|
|
@@ -703,9 +623,9 @@ function checkFileList(value) {
|
|
|
703
623
|
return Promise.resolve();
|
|
704
624
|
}
|
|
705
625
|
|
|
706
|
-
IglooUpload.formItemPropsHandler = function (
|
|
707
|
-
var previewFormater =
|
|
708
|
-
label =
|
|
626
|
+
IglooUpload.formItemPropsHandler = function (_ref8) {
|
|
627
|
+
var previewFormater = _ref8.previewFormater,
|
|
628
|
+
label = _ref8.label;
|
|
709
629
|
return {
|
|
710
630
|
previewFormater: previewFormater || function (value) {
|
|
711
631
|
return _jsx(UploadPreview, {
|