first commit
This commit is contained in:
18
frontend/node_modules/rc-field-form/es/utils/NameMap.d.ts
generated
vendored
Normal file
18
frontend/node_modules/rc-field-form/es/utils/NameMap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { InternalNamePath } from '../interface';
|
||||
interface KV<T> {
|
||||
key: InternalNamePath;
|
||||
value: T;
|
||||
}
|
||||
/**
|
||||
* NameMap like a `Map` but accepts `string[]` as key.
|
||||
*/
|
||||
declare class NameMap<T> {
|
||||
private kvs;
|
||||
set(key: InternalNamePath, value: T): void;
|
||||
get(key: InternalNamePath): T;
|
||||
update(key: InternalNamePath, updater: (origin: T) => T | null): void;
|
||||
delete(key: InternalNamePath): void;
|
||||
map<U>(callback: (kv: KV<T>) => U): U[];
|
||||
toJSON(): Record<string, T>;
|
||||
}
|
||||
export default NameMap;
|
||||
91
frontend/node_modules/rc-field-form/es/utils/NameMap.js
generated
vendored
Normal file
91
frontend/node_modules/rc-field-form/es/utils/NameMap.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
var SPLIT = '__@field_split__';
|
||||
|
||||
/**
|
||||
* Convert name path into string to fast the fetch speed of Map.
|
||||
*/
|
||||
function normalize(namePath) {
|
||||
return namePath.map(function (cell) {
|
||||
return "".concat(_typeof(cell), ":").concat(cell);
|
||||
})
|
||||
// Magic split
|
||||
.join(SPLIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* NameMap like a `Map` but accepts `string[]` as key.
|
||||
*/
|
||||
var NameMap = /*#__PURE__*/function () {
|
||||
function NameMap() {
|
||||
_classCallCheck(this, NameMap);
|
||||
_defineProperty(this, "kvs", new Map());
|
||||
}
|
||||
_createClass(NameMap, [{
|
||||
key: "set",
|
||||
value: function set(key, value) {
|
||||
this.kvs.set(normalize(key), value);
|
||||
}
|
||||
}, {
|
||||
key: "get",
|
||||
value: function get(key) {
|
||||
return this.kvs.get(normalize(key));
|
||||
}
|
||||
}, {
|
||||
key: "update",
|
||||
value: function update(key, updater) {
|
||||
var origin = this.get(key);
|
||||
var next = updater(origin);
|
||||
if (!next) {
|
||||
this.delete(key);
|
||||
} else {
|
||||
this.set(key, next);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "delete",
|
||||
value: function _delete(key) {
|
||||
this.kvs.delete(normalize(key));
|
||||
}
|
||||
|
||||
// Since we only use this in test, let simply realize this
|
||||
}, {
|
||||
key: "map",
|
||||
value: function map(callback) {
|
||||
return _toConsumableArray(this.kvs.entries()).map(function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 2),
|
||||
key = _ref2[0],
|
||||
value = _ref2[1];
|
||||
var cells = key.split(SPLIT);
|
||||
return callback({
|
||||
key: cells.map(function (cell) {
|
||||
var _cell$match = cell.match(/^([^:]*):(.*)$/),
|
||||
_cell$match2 = _slicedToArray(_cell$match, 3),
|
||||
type = _cell$match2[1],
|
||||
unit = _cell$match2[2];
|
||||
return type === 'number' ? Number(unit) : unit;
|
||||
}),
|
||||
value: value
|
||||
});
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "toJSON",
|
||||
value: function toJSON() {
|
||||
var json = {};
|
||||
this.map(function (_ref3) {
|
||||
var key = _ref3.key,
|
||||
value = _ref3.value;
|
||||
json[key.join('.')] = value;
|
||||
return null;
|
||||
});
|
||||
return json;
|
||||
}
|
||||
}]);
|
||||
return NameMap;
|
||||
}();
|
||||
export default NameMap;
|
||||
2
frontend/node_modules/rc-field-form/es/utils/asyncUtil.d.ts
generated
vendored
Normal file
2
frontend/node_modules/rc-field-form/es/utils/asyncUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { FieldError } from '../interface';
|
||||
export declare function allPromiseFinish(promiseList: Promise<FieldError>[]): Promise<FieldError[]>;
|
||||
26
frontend/node_modules/rc-field-form/es/utils/asyncUtil.js
generated
vendored
Normal file
26
frontend/node_modules/rc-field-form/es/utils/asyncUtil.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
export function allPromiseFinish(promiseList) {
|
||||
var hasError = false;
|
||||
var count = promiseList.length;
|
||||
var results = [];
|
||||
if (!promiseList.length) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
return new Promise(function (resolve, reject) {
|
||||
promiseList.forEach(function (promise, index) {
|
||||
promise.catch(function (e) {
|
||||
hasError = true;
|
||||
return e;
|
||||
}).then(function (result) {
|
||||
count -= 1;
|
||||
results[index] = result;
|
||||
if (count > 0) {
|
||||
return;
|
||||
}
|
||||
if (hasError) {
|
||||
reject(results);
|
||||
}
|
||||
resolve(results);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
47
frontend/node_modules/rc-field-form/es/utils/messages.d.ts
generated
vendored
Normal file
47
frontend/node_modules/rc-field-form/es/utils/messages.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
export declare const defaultValidateMessages: {
|
||||
default: string;
|
||||
required: string;
|
||||
enum: string;
|
||||
whitespace: string;
|
||||
date: {
|
||||
format: string;
|
||||
parse: string;
|
||||
invalid: string;
|
||||
};
|
||||
types: {
|
||||
string: string;
|
||||
method: string;
|
||||
array: string;
|
||||
object: string;
|
||||
number: string;
|
||||
date: string;
|
||||
boolean: string;
|
||||
integer: string;
|
||||
float: string;
|
||||
regexp: string;
|
||||
email: string;
|
||||
url: string;
|
||||
hex: string;
|
||||
};
|
||||
string: {
|
||||
len: string;
|
||||
min: string;
|
||||
max: string;
|
||||
range: string;
|
||||
};
|
||||
number: {
|
||||
len: string;
|
||||
min: string;
|
||||
max: string;
|
||||
range: string;
|
||||
};
|
||||
array: {
|
||||
len: string;
|
||||
min: string;
|
||||
max: string;
|
||||
range: string;
|
||||
};
|
||||
pattern: {
|
||||
mismatch: string;
|
||||
};
|
||||
};
|
||||
48
frontend/node_modules/rc-field-form/es/utils/messages.js
generated
vendored
Normal file
48
frontend/node_modules/rc-field-form/es/utils/messages.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
var typeTemplate = "'${name}' is not a valid ${type}";
|
||||
export var defaultValidateMessages = {
|
||||
default: "Validation error on field '${name}'",
|
||||
required: "'${name}' is required",
|
||||
enum: "'${name}' must be one of [${enum}]",
|
||||
whitespace: "'${name}' cannot be empty",
|
||||
date: {
|
||||
format: "'${name}' is invalid for format date",
|
||||
parse: "'${name}' could not be parsed as date",
|
||||
invalid: "'${name}' is invalid date"
|
||||
},
|
||||
types: {
|
||||
string: typeTemplate,
|
||||
method: typeTemplate,
|
||||
array: typeTemplate,
|
||||
object: typeTemplate,
|
||||
number: typeTemplate,
|
||||
date: typeTemplate,
|
||||
boolean: typeTemplate,
|
||||
integer: typeTemplate,
|
||||
float: typeTemplate,
|
||||
regexp: typeTemplate,
|
||||
email: typeTemplate,
|
||||
url: typeTemplate,
|
||||
hex: typeTemplate
|
||||
},
|
||||
string: {
|
||||
len: "'${name}' must be exactly ${len} characters",
|
||||
min: "'${name}' must be at least ${min} characters",
|
||||
max: "'${name}' cannot be longer than ${max} characters",
|
||||
range: "'${name}' must be between ${min} and ${max} characters"
|
||||
},
|
||||
number: {
|
||||
len: "'${name}' must equal ${len}",
|
||||
min: "'${name}' cannot be less than ${min}",
|
||||
max: "'${name}' cannot be greater than ${max}",
|
||||
range: "'${name}' must be between ${min} and ${max}"
|
||||
},
|
||||
array: {
|
||||
len: "'${name}' must be exactly ${len} in length",
|
||||
min: "'${name}' cannot be less than ${min} in length",
|
||||
max: "'${name}' cannot be greater than ${max} in length",
|
||||
range: "'${name}' must be between ${min} and ${max} in length"
|
||||
},
|
||||
pattern: {
|
||||
mismatch: "'${name}' does not match pattern ${pattern}"
|
||||
}
|
||||
};
|
||||
3
frontend/node_modules/rc-field-form/es/utils/typeUtil.d.ts
generated
vendored
Normal file
3
frontend/node_modules/rc-field-form/es/utils/typeUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { FormInstance } from '../interface';
|
||||
export declare function toArray<T>(value?: T | T[] | null): T[];
|
||||
export declare function isFormInstance<T>(form: T | FormInstance): form is FormInstance;
|
||||
9
frontend/node_modules/rc-field-form/es/utils/typeUtil.js
generated
vendored
Normal file
9
frontend/node_modules/rc-field-form/es/utils/typeUtil.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export function toArray(value) {
|
||||
if (value === undefined || value === null) {
|
||||
return [];
|
||||
}
|
||||
return Array.isArray(value) ? value : [value];
|
||||
}
|
||||
export function isFormInstance(form) {
|
||||
return form && !!form._init;
|
||||
}
|
||||
6
frontend/node_modules/rc-field-form/es/utils/validateUtil.d.ts
generated
vendored
Normal file
6
frontend/node_modules/rc-field-form/es/utils/validateUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { InternalNamePath, InternalValidateOptions, RuleObject, StoreValue, RuleError } from '../interface';
|
||||
/**
|
||||
* We use `async-validator` to validate the value.
|
||||
* But only check one value in a time to avoid namePath validate issue.
|
||||
*/
|
||||
export declare function validateRules(namePath: InternalNamePath, value: StoreValue, rules: RuleObject[], options: InternalValidateOptions, validateFirst: boolean | 'parallel', messageVariables?: Record<string, string>): Promise<RuleError[]>;
|
||||
313
frontend/node_modules/rc-field-form/es/utils/validateUtil.js
generated
vendored
Normal file
313
frontend/node_modules/rc-field-form/es/utils/validateUtil.js
generated
vendored
Normal file
@@ -0,0 +1,313 @@
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
||||
import RawAsyncValidator from '@rc-component/async-validator';
|
||||
import * as React from 'react';
|
||||
import warning from "rc-util/es/warning";
|
||||
import { defaultValidateMessages } from "./messages";
|
||||
import { merge } from "rc-util/es/utils/set";
|
||||
|
||||
// Remove incorrect original ts define
|
||||
var AsyncValidator = RawAsyncValidator;
|
||||
|
||||
/**
|
||||
* Replace with template.
|
||||
* `I'm ${name}` + { name: 'bamboo' } = I'm bamboo
|
||||
*/
|
||||
function replaceMessage(template, kv) {
|
||||
return template.replace(/\\?\$\{\w+\}/g, function (str) {
|
||||
if (str.startsWith('\\')) {
|
||||
return str.slice(1);
|
||||
}
|
||||
var key = str.slice(2, -1);
|
||||
return kv[key];
|
||||
});
|
||||
}
|
||||
var CODE_LOGIC_ERROR = 'CODE_LOGIC_ERROR';
|
||||
function validateRule(_x, _x2, _x3, _x4, _x5) {
|
||||
return _validateRule.apply(this, arguments);
|
||||
}
|
||||
/**
|
||||
* We use `async-validator` to validate the value.
|
||||
* But only check one value in a time to avoid namePath validate issue.
|
||||
*/
|
||||
function _validateRule() {
|
||||
_validateRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(name, value, rule, options, messageVariables) {
|
||||
var cloneRule, originValidator, subRuleField, validator, messages, result, subResults, kv, fillVariableResult;
|
||||
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
||||
while (1) switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
cloneRule = _objectSpread({}, rule); // Bug of `async-validator`
|
||||
// https://github.com/react-component/field-form/issues/316
|
||||
// https://github.com/react-component/field-form/issues/313
|
||||
delete cloneRule.ruleIndex;
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/40497#issuecomment-1422282378
|
||||
AsyncValidator.warning = function () {
|
||||
return void 0;
|
||||
};
|
||||
if (cloneRule.validator) {
|
||||
originValidator = cloneRule.validator;
|
||||
cloneRule.validator = function () {
|
||||
try {
|
||||
return originValidator.apply(void 0, arguments);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Promise.reject(CODE_LOGIC_ERROR);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// We should special handle array validate
|
||||
subRuleField = null;
|
||||
if (cloneRule && cloneRule.type === 'array' && cloneRule.defaultField) {
|
||||
subRuleField = cloneRule.defaultField;
|
||||
delete cloneRule.defaultField;
|
||||
}
|
||||
validator = new AsyncValidator(_defineProperty({}, name, [cloneRule]));
|
||||
messages = merge(defaultValidateMessages, options.validateMessages);
|
||||
validator.messages(messages);
|
||||
result = [];
|
||||
_context2.prev = 10;
|
||||
_context2.next = 13;
|
||||
return Promise.resolve(validator.validate(_defineProperty({}, name, value), _objectSpread({}, options)));
|
||||
case 13:
|
||||
_context2.next = 18;
|
||||
break;
|
||||
case 15:
|
||||
_context2.prev = 15;
|
||||
_context2.t0 = _context2["catch"](10);
|
||||
if (_context2.t0.errors) {
|
||||
result = _context2.t0.errors.map(function (_ref4, index) {
|
||||
var message = _ref4.message;
|
||||
var mergedMessage = message === CODE_LOGIC_ERROR ? messages.default : message;
|
||||
return /*#__PURE__*/React.isValidElement(mergedMessage) ?
|
||||
/*#__PURE__*/
|
||||
// Wrap ReactNode with `key`
|
||||
React.cloneElement(mergedMessage, {
|
||||
key: "error_".concat(index)
|
||||
}) : mergedMessage;
|
||||
});
|
||||
}
|
||||
case 18:
|
||||
if (!(!result.length && subRuleField && Array.isArray(value) && value.length > 0)) {
|
||||
_context2.next = 23;
|
||||
break;
|
||||
}
|
||||
_context2.next = 21;
|
||||
return Promise.all(value.map(function (subValue, i) {
|
||||
return validateRule("".concat(name, ".").concat(i), subValue, subRuleField, options, messageVariables);
|
||||
}));
|
||||
case 21:
|
||||
subResults = _context2.sent;
|
||||
return _context2.abrupt("return", subResults.reduce(function (prev, errors) {
|
||||
return [].concat(_toConsumableArray(prev), _toConsumableArray(errors));
|
||||
}, []));
|
||||
case 23:
|
||||
// Replace message with variables
|
||||
kv = _objectSpread(_objectSpread({}, rule), {}, {
|
||||
name: name,
|
||||
enum: (rule.enum || []).join(', ')
|
||||
}, messageVariables);
|
||||
fillVariableResult = result.map(function (error) {
|
||||
if (typeof error === 'string') {
|
||||
return replaceMessage(error, kv);
|
||||
}
|
||||
return error;
|
||||
});
|
||||
return _context2.abrupt("return", fillVariableResult);
|
||||
case 26:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
}, _callee2, null, [[10, 15]]);
|
||||
}));
|
||||
return _validateRule.apply(this, arguments);
|
||||
}
|
||||
export function validateRules(namePath, value, rules, options, validateFirst, messageVariables) {
|
||||
var name = namePath.join('.');
|
||||
|
||||
// Fill rule with context
|
||||
var filledRules = rules.map(function (currentRule, ruleIndex) {
|
||||
var originValidatorFunc = currentRule.validator;
|
||||
var cloneRule = _objectSpread(_objectSpread({}, currentRule), {}, {
|
||||
ruleIndex: ruleIndex
|
||||
});
|
||||
|
||||
// Replace validator if needed
|
||||
if (originValidatorFunc) {
|
||||
cloneRule.validator = function (rule, val, callback) {
|
||||
var hasPromise = false;
|
||||
|
||||
// Wrap callback only accept when promise not provided
|
||||
var wrappedCallback = function wrappedCallback() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
// Wait a tick to make sure return type is a promise
|
||||
Promise.resolve().then(function () {
|
||||
warning(!hasPromise, 'Your validator function has already return a promise. `callback` will be ignored.');
|
||||
if (!hasPromise) {
|
||||
callback.apply(void 0, args);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Get promise
|
||||
var promise = originValidatorFunc(rule, val, wrappedCallback);
|
||||
hasPromise = promise && typeof promise.then === 'function' && typeof promise.catch === 'function';
|
||||
|
||||
/**
|
||||
* 1. Use promise as the first priority.
|
||||
* 2. If promise not exist, use callback with warning instead
|
||||
*/
|
||||
warning(hasPromise, '`callback` is deprecated. Please return a promise instead.');
|
||||
if (hasPromise) {
|
||||
promise.then(function () {
|
||||
callback();
|
||||
}).catch(function (err) {
|
||||
callback(err || ' ');
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
return cloneRule;
|
||||
}).sort(function (_ref, _ref2) {
|
||||
var w1 = _ref.warningOnly,
|
||||
i1 = _ref.ruleIndex;
|
||||
var w2 = _ref2.warningOnly,
|
||||
i2 = _ref2.ruleIndex;
|
||||
if (!!w1 === !!w2) {
|
||||
// Let keep origin order
|
||||
return i1 - i2;
|
||||
}
|
||||
if (w1) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
|
||||
// Do validate rules
|
||||
var summaryPromise;
|
||||
if (validateFirst === true) {
|
||||
// >>>>> Validate by serialization
|
||||
summaryPromise = new Promise( /*#__PURE__*/function () {
|
||||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
|
||||
var i, rule, errors;
|
||||
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
||||
while (1) switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
i = 0;
|
||||
case 1:
|
||||
if (!(i < filledRules.length)) {
|
||||
_context.next = 12;
|
||||
break;
|
||||
}
|
||||
rule = filledRules[i];
|
||||
_context.next = 5;
|
||||
return validateRule(name, value, rule, options, messageVariables);
|
||||
case 5:
|
||||
errors = _context.sent;
|
||||
if (!errors.length) {
|
||||
_context.next = 9;
|
||||
break;
|
||||
}
|
||||
reject([{
|
||||
errors: errors,
|
||||
rule: rule
|
||||
}]);
|
||||
return _context.abrupt("return");
|
||||
case 9:
|
||||
i += 1;
|
||||
_context.next = 1;
|
||||
break;
|
||||
case 12:
|
||||
/* eslint-enable */
|
||||
|
||||
resolve([]);
|
||||
case 13:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
return function (_x6, _x7) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
} else {
|
||||
// >>>>> Validate by parallel
|
||||
var rulePromises = filledRules.map(function (rule) {
|
||||
return validateRule(name, value, rule, options, messageVariables).then(function (errors) {
|
||||
return {
|
||||
errors: errors,
|
||||
rule: rule
|
||||
};
|
||||
});
|
||||
});
|
||||
summaryPromise = (validateFirst ? finishOnFirstFailed(rulePromises) : finishOnAllFailed(rulePromises)).then(function (errors) {
|
||||
// Always change to rejection for Field to catch
|
||||
return Promise.reject(errors);
|
||||
});
|
||||
}
|
||||
|
||||
// Internal catch error to avoid console error log.
|
||||
summaryPromise.catch(function (e) {
|
||||
return e;
|
||||
});
|
||||
return summaryPromise;
|
||||
}
|
||||
function finishOnAllFailed(_x8) {
|
||||
return _finishOnAllFailed.apply(this, arguments);
|
||||
}
|
||||
function _finishOnAllFailed() {
|
||||
_finishOnAllFailed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(rulePromises) {
|
||||
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
||||
while (1) switch (_context3.prev = _context3.next) {
|
||||
case 0:
|
||||
return _context3.abrupt("return", Promise.all(rulePromises).then(function (errorsList) {
|
||||
var _ref5;
|
||||
var errors = (_ref5 = []).concat.apply(_ref5, _toConsumableArray(errorsList));
|
||||
return errors;
|
||||
}));
|
||||
case 1:
|
||||
case "end":
|
||||
return _context3.stop();
|
||||
}
|
||||
}, _callee3);
|
||||
}));
|
||||
return _finishOnAllFailed.apply(this, arguments);
|
||||
}
|
||||
function finishOnFirstFailed(_x9) {
|
||||
return _finishOnFirstFailed.apply(this, arguments);
|
||||
}
|
||||
function _finishOnFirstFailed() {
|
||||
_finishOnFirstFailed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(rulePromises) {
|
||||
var count;
|
||||
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
||||
while (1) switch (_context4.prev = _context4.next) {
|
||||
case 0:
|
||||
count = 0;
|
||||
return _context4.abrupt("return", new Promise(function (resolve) {
|
||||
rulePromises.forEach(function (promise) {
|
||||
promise.then(function (ruleError) {
|
||||
if (ruleError.errors.length) {
|
||||
resolve([ruleError]);
|
||||
}
|
||||
count += 1;
|
||||
if (count === rulePromises.length) {
|
||||
resolve([]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
||||
case 2:
|
||||
case "end":
|
||||
return _context4.stop();
|
||||
}
|
||||
}, _callee4);
|
||||
}));
|
||||
return _finishOnFirstFailed.apply(this, arguments);
|
||||
}
|
||||
41
frontend/node_modules/rc-field-form/es/utils/valueUtil.d.ts
generated
vendored
Normal file
41
frontend/node_modules/rc-field-form/es/utils/valueUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import getValue from 'rc-util/lib/utils/get';
|
||||
import setValue from 'rc-util/lib/utils/set';
|
||||
import type { InternalNamePath, NamePath, Store, EventArgs } from '../interface';
|
||||
export { getValue, setValue };
|
||||
/**
|
||||
* Convert name to internal supported format.
|
||||
* This function should keep since we still thinking if need support like `a.b.c` format.
|
||||
* 'a' => ['a']
|
||||
* 123 => [123]
|
||||
* ['a', 123] => ['a', 123]
|
||||
*/
|
||||
export declare function getNamePath(path: NamePath | null): InternalNamePath;
|
||||
export declare function cloneByNamePathList(store: Store, namePathList: InternalNamePath[]): Store;
|
||||
/**
|
||||
* Check if `namePathList` includes `namePath`.
|
||||
* @param namePathList A list of `InternalNamePath[]`
|
||||
* @param namePath Compare `InternalNamePath`
|
||||
* @param partialMatch True will make `[a, b]` match `[a, b, c]`
|
||||
*/
|
||||
export declare function containsNamePath(namePathList: InternalNamePath[], namePath: InternalNamePath, partialMatch?: boolean): boolean;
|
||||
/**
|
||||
* Check if `namePath` is super set or equal of `subNamePath`.
|
||||
* @param namePath A list of `InternalNamePath[]`
|
||||
* @param subNamePath Compare `InternalNamePath`
|
||||
* @param partialMatch True will make `[a, b]` match `[a, b, c]`
|
||||
*/
|
||||
export declare function matchNamePath(namePath: InternalNamePath, subNamePath: InternalNamePath | null, partialMatch?: boolean): boolean;
|
||||
type SimilarObject = string | number | object;
|
||||
export declare function isSimilar(source: SimilarObject, target: SimilarObject): boolean;
|
||||
export declare function defaultGetValueFromEvent(valuePropName: string, ...args: EventArgs): any;
|
||||
/**
|
||||
* Moves an array item from one position in an array to another.
|
||||
*
|
||||
* Note: This is a pure function so a new array will be returned, instead
|
||||
* of altering the array argument.
|
||||
*
|
||||
* @param array Array in which to move an item. (required)
|
||||
* @param moveIndex The index of the item to move. (required)
|
||||
* @param toIndex The index to move item at moveIndex to. (required)
|
||||
*/
|
||||
export declare function move<T>(array: T[], moveIndex: number, toIndex: number): T[];
|
||||
117
frontend/node_modules/rc-field-form/es/utils/valueUtil.js
generated
vendored
Normal file
117
frontend/node_modules/rc-field-form/es/utils/valueUtil.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import getValue from "rc-util/es/utils/get";
|
||||
import setValue from "rc-util/es/utils/set";
|
||||
import { toArray } from "./typeUtil";
|
||||
export { getValue, setValue };
|
||||
|
||||
/**
|
||||
* Convert name to internal supported format.
|
||||
* This function should keep since we still thinking if need support like `a.b.c` format.
|
||||
* 'a' => ['a']
|
||||
* 123 => [123]
|
||||
* ['a', 123] => ['a', 123]
|
||||
*/
|
||||
export function getNamePath(path) {
|
||||
return toArray(path);
|
||||
}
|
||||
export function cloneByNamePathList(store, namePathList) {
|
||||
var newStore = {};
|
||||
namePathList.forEach(function (namePath) {
|
||||
var value = getValue(store, namePath);
|
||||
newStore = setValue(newStore, namePath, value);
|
||||
});
|
||||
return newStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if `namePathList` includes `namePath`.
|
||||
* @param namePathList A list of `InternalNamePath[]`
|
||||
* @param namePath Compare `InternalNamePath`
|
||||
* @param partialMatch True will make `[a, b]` match `[a, b, c]`
|
||||
*/
|
||||
export function containsNamePath(namePathList, namePath) {
|
||||
var partialMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
||||
return namePathList && namePathList.some(function (path) {
|
||||
return matchNamePath(namePath, path, partialMatch);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if `namePath` is super set or equal of `subNamePath`.
|
||||
* @param namePath A list of `InternalNamePath[]`
|
||||
* @param subNamePath Compare `InternalNamePath`
|
||||
* @param partialMatch True will make `[a, b]` match `[a, b, c]`
|
||||
*/
|
||||
export function matchNamePath(namePath, subNamePath) {
|
||||
var partialMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
||||
if (!namePath || !subNamePath) {
|
||||
return false;
|
||||
}
|
||||
if (!partialMatch && namePath.length !== subNamePath.length) {
|
||||
return false;
|
||||
}
|
||||
return subNamePath.every(function (nameUnit, i) {
|
||||
return namePath[i] === nameUnit;
|
||||
});
|
||||
}
|
||||
|
||||
// Like `shallowEqual`, but we not check the data which may cause re-render
|
||||
|
||||
export function isSimilar(source, target) {
|
||||
if (source === target) {
|
||||
return true;
|
||||
}
|
||||
if (!source && target || source && !target) {
|
||||
return false;
|
||||
}
|
||||
if (!source || !target || _typeof(source) !== 'object' || _typeof(target) !== 'object') {
|
||||
return false;
|
||||
}
|
||||
var sourceKeys = Object.keys(source);
|
||||
var targetKeys = Object.keys(target);
|
||||
var keys = new Set([].concat(sourceKeys, targetKeys));
|
||||
return _toConsumableArray(keys).every(function (key) {
|
||||
var sourceValue = source[key];
|
||||
var targetValue = target[key];
|
||||
if (typeof sourceValue === 'function' && typeof targetValue === 'function') {
|
||||
return true;
|
||||
}
|
||||
return sourceValue === targetValue;
|
||||
});
|
||||
}
|
||||
export function defaultGetValueFromEvent(valuePropName) {
|
||||
var event = arguments.length <= 1 ? undefined : arguments[1];
|
||||
if (event && event.target && _typeof(event.target) === 'object' && valuePropName in event.target) {
|
||||
return event.target[valuePropName];
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves an array item from one position in an array to another.
|
||||
*
|
||||
* Note: This is a pure function so a new array will be returned, instead
|
||||
* of altering the array argument.
|
||||
*
|
||||
* @param array Array in which to move an item. (required)
|
||||
* @param moveIndex The index of the item to move. (required)
|
||||
* @param toIndex The index to move item at moveIndex to. (required)
|
||||
*/
|
||||
export function move(array, moveIndex, toIndex) {
|
||||
var length = array.length;
|
||||
if (moveIndex < 0 || moveIndex >= length || toIndex < 0 || toIndex >= length) {
|
||||
return array;
|
||||
}
|
||||
var item = array[moveIndex];
|
||||
var diff = moveIndex - toIndex;
|
||||
if (diff > 0) {
|
||||
// move left
|
||||
return [].concat(_toConsumableArray(array.slice(0, toIndex)), [item], _toConsumableArray(array.slice(toIndex, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, length)));
|
||||
}
|
||||
if (diff < 0) {
|
||||
// move right
|
||||
return [].concat(_toConsumableArray(array.slice(0, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, toIndex + 1)), [item], _toConsumableArray(array.slice(toIndex + 1, length)));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
Reference in New Issue
Block a user