@zat-design/sisyphus-react 3.4.8-beta.2 → 3.4.8-beta.3
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/ProForm/utils/useForm.js +37 -22
- package/lib/ProForm/utils/useForm.js +36 -21
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
3
3
|
import "antd/es/form/style";
|
|
4
4
|
import _Form from "antd/es/form";
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
-
import { filterInternalFields
|
|
6
|
+
import { filterInternalFields } from './index';
|
|
7
7
|
export var useForm = function useForm(originForm) {
|
|
8
8
|
var _Form$useForm = _Form.useForm(originForm),
|
|
9
9
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
@@ -21,11 +21,15 @@ export var useForm = function useForm(originForm) {
|
|
|
21
21
|
};
|
|
22
22
|
var _validateFields = /*#__PURE__*/function () {
|
|
23
23
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(nameList) {
|
|
24
|
-
var
|
|
24
|
+
var _rest$,
|
|
25
|
+
_len,
|
|
25
26
|
rest,
|
|
26
27
|
_key,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
isRecursive,
|
|
29
|
+
validateNames,
|
|
30
|
+
_form$getInternalHook,
|
|
31
|
+
getFields,
|
|
32
|
+
fieldsList,
|
|
29
33
|
values,
|
|
30
34
|
_values,
|
|
31
35
|
_error$errorFields,
|
|
@@ -34,33 +38,44 @@ export var useForm = function useForm(originForm) {
|
|
|
34
38
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
35
39
|
while (1) switch (_context.prev = _context.next) {
|
|
36
40
|
case 0:
|
|
41
|
+
_context.prev = 0;
|
|
37
42
|
for (_len = _args.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
38
43
|
rest[_key - 1] = _args[_key];
|
|
39
44
|
}
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
hasNames.forEach(function (item) {
|
|
47
|
-
validateFields.apply(void 0, [item.name].concat(rest));
|
|
48
|
-
});
|
|
49
|
-
}
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
isRecursive = rest === null || rest === void 0 ? void 0 : (_rest$ = rest[0]) === null || _rest$ === void 0 ? void 0 : _rest$.recursive;
|
|
47
|
+
validateNames = []; // 前缀校验模式
|
|
48
|
+
if (!isRecursive) {
|
|
49
|
+
_context.next = 10;
|
|
50
|
+
break;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
_form$getInternalHook = form.getInternalHooks('RC_FORM_INTERNAL_HOOKS'), getFields = _form$getInternalHook.getFields;
|
|
54
|
+
fieldsList = getFields();
|
|
55
|
+
fieldsList.forEach(function (item) {
|
|
56
|
+
var _item$name, _item$name2, _item$name2$;
|
|
57
|
+
if (nameList[0] === ((_item$name = item.name) === null || _item$name === void 0 ? void 0 : _item$name[0]) || ((_item$name2 = item.name) === null || _item$name2 === void 0 ? void 0 : (_item$name2$ = _item$name2[0]) === null || _item$name2$ === void 0 ? void 0 : _item$name2$.startsWith("".concat(nameList[0], "_")))) {
|
|
58
|
+
validateNames.push(item.name);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
delete rest[0].recursive;
|
|
63
|
+
return _context.abrupt("return", validateFields.apply(void 0, [validateNames].concat(rest)).then(function (values) {
|
|
64
|
+
return filterInternalFields(values);
|
|
65
|
+
}));
|
|
66
|
+
case 10:
|
|
52
67
|
values = validateFields.apply(void 0, [nameList].concat(rest));
|
|
53
68
|
if (!nameList) {
|
|
54
|
-
_context.next =
|
|
69
|
+
_context.next = 13;
|
|
55
70
|
break;
|
|
56
71
|
}
|
|
57
72
|
return _context.abrupt("return", values);
|
|
58
|
-
case
|
|
73
|
+
case 13:
|
|
59
74
|
_values = _getFieldsValue();
|
|
60
75
|
return _context.abrupt("return", _values);
|
|
61
|
-
case
|
|
62
|
-
_context.prev =
|
|
63
|
-
_context.t0 = _context["catch"](
|
|
76
|
+
case 17:
|
|
77
|
+
_context.prev = 17;
|
|
78
|
+
_context.t0 = _context["catch"](0);
|
|
64
79
|
if (_context.t0 && (_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.errorFields)) {
|
|
65
80
|
form === null || form === void 0 ? void 0 : form.scrollToField(_context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$errorFields = _context.t0.errorFields) === null || _error$errorFields === void 0 ? void 0 : (_error$errorFields$ = _error$errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name, {
|
|
66
81
|
block: 'center',
|
|
@@ -68,11 +83,11 @@ export var useForm = function useForm(originForm) {
|
|
|
68
83
|
});
|
|
69
84
|
}
|
|
70
85
|
throw _context.t0;
|
|
71
|
-
case
|
|
86
|
+
case 21:
|
|
72
87
|
case "end":
|
|
73
88
|
return _context.stop();
|
|
74
89
|
}
|
|
75
|
-
}, _callee, null, [[
|
|
90
|
+
}, _callee, null, [[0, 17]]);
|
|
76
91
|
}));
|
|
77
92
|
return function _validateFields(_x) {
|
|
78
93
|
return _ref.apply(this, arguments);
|
|
@@ -27,11 +27,15 @@ var useForm = exports.useForm = function useForm(originForm) {
|
|
|
27
27
|
};
|
|
28
28
|
var _validateFields = /*#__PURE__*/function () {
|
|
29
29
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(nameList) {
|
|
30
|
-
var
|
|
30
|
+
var _rest$,
|
|
31
|
+
_len,
|
|
31
32
|
rest,
|
|
32
33
|
_key,
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
isRecursive,
|
|
35
|
+
validateNames,
|
|
36
|
+
_form$getInternalHook,
|
|
37
|
+
getFields,
|
|
38
|
+
fieldsList,
|
|
35
39
|
values,
|
|
36
40
|
_values,
|
|
37
41
|
_error$errorFields,
|
|
@@ -40,33 +44,44 @@ var useForm = exports.useForm = function useForm(originForm) {
|
|
|
40
44
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
41
45
|
while (1) switch (_context.prev = _context.next) {
|
|
42
46
|
case 0:
|
|
47
|
+
_context.prev = 0;
|
|
43
48
|
for (_len = _args.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
44
49
|
rest[_key - 1] = _args[_key];
|
|
45
50
|
}
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
hasNames.forEach(function (item) {
|
|
53
|
-
validateFields.apply(void 0, [item.name].concat(rest));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
isRecursive = rest === null || rest === void 0 ? void 0 : (_rest$ = rest[0]) === null || _rest$ === void 0 ? void 0 : _rest$.recursive;
|
|
53
|
+
validateNames = []; // 前缀校验模式
|
|
54
|
+
if (!isRecursive) {
|
|
55
|
+
_context.next = 10;
|
|
56
|
+
break;
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
_form$getInternalHook = form.getInternalHooks('RC_FORM_INTERNAL_HOOKS'), getFields = _form$getInternalHook.getFields;
|
|
60
|
+
fieldsList = getFields();
|
|
61
|
+
fieldsList.forEach(function (item) {
|
|
62
|
+
var _item$name, _item$name2, _item$name2$;
|
|
63
|
+
if (nameList[0] === ((_item$name = item.name) === null || _item$name === void 0 ? void 0 : _item$name[0]) || ((_item$name2 = item.name) === null || _item$name2 === void 0 ? void 0 : (_item$name2$ = _item$name2[0]) === null || _item$name2$ === void 0 ? void 0 : _item$name2$.startsWith("".concat(nameList[0], "_")))) {
|
|
64
|
+
validateNames.push(item.name);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
delete rest[0].recursive;
|
|
69
|
+
return _context.abrupt("return", validateFields.apply(void 0, [validateNames].concat(rest)).then(function (values) {
|
|
70
|
+
return (0, _index.filterInternalFields)(values);
|
|
71
|
+
}));
|
|
72
|
+
case 10:
|
|
58
73
|
values = validateFields.apply(void 0, [nameList].concat(rest));
|
|
59
74
|
if (!nameList) {
|
|
60
|
-
_context.next =
|
|
75
|
+
_context.next = 13;
|
|
61
76
|
break;
|
|
62
77
|
}
|
|
63
78
|
return _context.abrupt("return", values);
|
|
64
|
-
case
|
|
79
|
+
case 13:
|
|
65
80
|
_values = _getFieldsValue();
|
|
66
81
|
return _context.abrupt("return", _values);
|
|
67
|
-
case
|
|
68
|
-
_context.prev =
|
|
69
|
-
_context.t0 = _context["catch"](
|
|
82
|
+
case 17:
|
|
83
|
+
_context.prev = 17;
|
|
84
|
+
_context.t0 = _context["catch"](0);
|
|
70
85
|
if (_context.t0 && (_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.errorFields)) {
|
|
71
86
|
form === null || form === void 0 ? void 0 : form.scrollToField(_context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$errorFields = _context.t0.errorFields) === null || _error$errorFields === void 0 ? void 0 : (_error$errorFields$ = _error$errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name, {
|
|
72
87
|
block: 'center',
|
|
@@ -74,11 +89,11 @@ var useForm = exports.useForm = function useForm(originForm) {
|
|
|
74
89
|
});
|
|
75
90
|
}
|
|
76
91
|
throw _context.t0;
|
|
77
|
-
case
|
|
92
|
+
case 21:
|
|
78
93
|
case "end":
|
|
79
94
|
return _context.stop();
|
|
80
95
|
}
|
|
81
|
-
}, _callee, null, [[
|
|
96
|
+
}, _callee, null, [[0, 17]]);
|
|
82
97
|
}));
|
|
83
98
|
return function _validateFields(_x) {
|
|
84
99
|
return _ref.apply(this, arguments);
|