2d249cbbc64dfcc32f2bf20a72cae60f.json
77.2 KB
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport * as React from 'react';\nimport warning from \"rc-util/es/warning\";\nimport { HOOK_MARK } from './FieldContext';\nimport { allPromiseFinish } from './utils/asyncUtil';\nimport NameMap from './utils/NameMap';\nimport { defaultValidateMessages } from './utils/messages';\nimport { cloneByNamePathList, containsNamePath, getNamePath, getValue, setValue, setValues } from './utils/valueUtil';\nexport var FormStore = function FormStore(forceRootUpdate) {\n var _this = this;\n\n _classCallCheck(this, FormStore);\n\n this.formHooked = false;\n this.subscribable = true;\n this.store = {};\n this.fieldEntities = [];\n this.initialValues = {};\n this.callbacks = {};\n this.validateMessages = null;\n this.preserve = null;\n this.lastValidatePromise = null;\n\n this.getForm = function () {\n return {\n getFieldValue: _this.getFieldValue,\n getFieldsValue: _this.getFieldsValue,\n getFieldError: _this.getFieldError,\n getFieldsError: _this.getFieldsError,\n isFieldsTouched: _this.isFieldsTouched,\n isFieldTouched: _this.isFieldTouched,\n isFieldValidating: _this.isFieldValidating,\n isFieldsValidating: _this.isFieldsValidating,\n resetFields: _this.resetFields,\n setFields: _this.setFields,\n setFieldsValue: _this.setFieldsValue,\n validateFields: _this.validateFields,\n submit: _this.submit,\n getInternalHooks: _this.getInternalHooks\n };\n }; // ======================== Internal Hooks ========================\n\n\n this.getInternalHooks = function (key) {\n if (key === HOOK_MARK) {\n _this.formHooked = true;\n return {\n dispatch: _this.dispatch,\n initEntityValue: _this.initEntityValue,\n registerField: _this.registerField,\n useSubscribe: _this.useSubscribe,\n setInitialValues: _this.setInitialValues,\n setCallbacks: _this.setCallbacks,\n setValidateMessages: _this.setValidateMessages,\n getFields: _this.getFields,\n setPreserve: _this.setPreserve\n };\n }\n\n warning(false, '`getInternalHooks` is internal usage. Should not call directly.');\n return null;\n };\n\n this.useSubscribe = function (subscribable) {\n _this.subscribable = subscribable;\n };\n /**\n * First time `setInitialValues` should update store with initial value\n */\n\n\n this.setInitialValues = function (initialValues, init) {\n _this.initialValues = initialValues || {};\n\n if (init) {\n _this.store = setValues({}, initialValues, _this.store);\n }\n };\n\n this.getInitialValue = function (namePath) {\n return getValue(_this.initialValues, namePath);\n };\n\n this.setCallbacks = function (callbacks) {\n _this.callbacks = callbacks;\n };\n\n this.setValidateMessages = function (validateMessages) {\n _this.validateMessages = validateMessages;\n };\n\n this.setPreserve = function (preserve) {\n _this.preserve = preserve;\n }; // ========================== Dev Warning =========================\n\n\n this.timeoutId = null;\n\n this.warningUnhooked = function () {\n if (process.env.NODE_ENV !== 'production' && !_this.timeoutId && typeof window !== 'undefined') {\n _this.timeoutId = window.setTimeout(function () {\n _this.timeoutId = null;\n\n if (!_this.formHooked) {\n warning(false, 'Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?');\n }\n });\n }\n }; // ============================ Fields ============================\n\n /**\n * Get registered field entities.\n * @param pure Only return field which has a `name`. Default: false\n */\n\n\n this.getFieldEntities = function () {\n var pure = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n\n if (!pure) {\n return _this.fieldEntities;\n }\n\n return _this.fieldEntities.filter(function (field) {\n return field.getNamePath().length;\n });\n };\n\n this.getFieldsMap = function () {\n var pure = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n var cache = new NameMap();\n\n _this.getFieldEntities(pure).forEach(function (field) {\n var namePath = field.getNamePath();\n cache.set(namePath, field);\n });\n\n return cache;\n };\n\n this.getFieldEntitiesForNamePathList = function (nameList) {\n if (!nameList) {\n return _this.getFieldEntities(true);\n }\n\n var cache = _this.getFieldsMap(true);\n\n return nameList.map(function (name) {\n var namePath = getNamePath(name);\n return cache.get(namePath) || {\n INVALIDATE_NAME_PATH: getNamePath(name)\n };\n });\n };\n\n this.getFieldsValue = function (nameList, filterFunc) {\n _this.warningUnhooked();\n\n if (nameList === true && !filterFunc) {\n return _this.store;\n }\n\n var fieldEntities = _this.getFieldEntitiesForNamePathList(Array.isArray(nameList) ? nameList : null);\n\n var filteredNameList = [];\n fieldEntities.forEach(function (entity) {\n var _entity$isListField;\n\n var namePath = 'INVALIDATE_NAME_PATH' in entity ? entity.INVALIDATE_NAME_PATH : entity.getNamePath(); // Ignore when it's a list item and not specific the namePath,\n // since parent field is already take in count\n\n if (!nameList && ((_entity$isListField = entity.isListField) === null || _entity$isListField === void 0 ? void 0 : _entity$isListField.call(entity))) {\n return;\n }\n\n if (!filterFunc) {\n filteredNameList.push(namePath);\n } else {\n var meta = 'getMeta' in entity ? entity.getMeta() : null;\n\n if (filterFunc(meta)) {\n filteredNameList.push(namePath);\n }\n }\n });\n return cloneByNamePathList(_this.store, filteredNameList.map(getNamePath));\n };\n\n this.getFieldValue = function (name) {\n _this.warningUnhooked();\n\n var namePath = getNamePath(name);\n return getValue(_this.store, namePath);\n };\n\n this.getFieldsError = function (nameList) {\n _this.warningUnhooked();\n\n var fieldEntities = _this.getFieldEntitiesForNamePathList(nameList);\n\n return fieldEntities.map(function (entity, index) {\n if (entity && !('INVALIDATE_NAME_PATH' in entity)) {\n return {\n name: entity.getNamePath(),\n errors: entity.getErrors()\n };\n }\n\n return {\n name: getNamePath(nameList[index]),\n errors: []\n };\n });\n };\n\n this.getFieldError = function (name) {\n _this.warningUnhooked();\n\n var namePath = getNamePath(name);\n\n var fieldError = _this.getFieldsError([namePath])[0];\n\n return fieldError.errors;\n };\n\n this.isFieldsTouched = function () {\n _this.warningUnhooked();\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var arg0 = args[0],\n arg1 = args[1];\n var namePathList;\n var isAllFieldsTouched = false;\n\n if (args.length === 0) {\n namePathList = null;\n } else if (args.length === 1) {\n if (Array.isArray(arg0)) {\n namePathList = arg0.map(getNamePath);\n isAllFieldsTouched = false;\n } else {\n namePathList = null;\n isAllFieldsTouched = arg0;\n }\n } else {\n namePathList = arg0.map(getNamePath);\n isAllFieldsTouched = arg1;\n }\n\n var fieldEntities = _this.getFieldEntities(true);\n\n var isFieldTouched = function isFieldTouched(field) {\n return field.isFieldTouched();\n }; // ===== Will get fully compare when not config namePathList =====\n\n\n if (!namePathList) {\n return isAllFieldsTouched ? fieldEntities.every(isFieldTouched) : fieldEntities.some(isFieldTouched);\n } // Generate a nest tree for validate\n\n\n var map = new NameMap();\n namePathList.forEach(function (shortNamePath) {\n map.set(shortNamePath, []);\n });\n fieldEntities.forEach(function (field) {\n var fieldNamePath = field.getNamePath(); // Find matched entity and put into list\n\n namePathList.forEach(function (shortNamePath) {\n if (shortNamePath.every(function (nameUnit, i) {\n return fieldNamePath[i] === nameUnit;\n })) {\n map.update(shortNamePath, function (list) {\n return [].concat(_toConsumableArray(list), [field]);\n });\n }\n });\n }); // Check if NameMap value is touched\n\n var isNamePathListTouched = function isNamePathListTouched(entities) {\n return entities.some(isFieldTouched);\n };\n\n var namePathListEntities = map.map(function (_ref) {\n var value = _ref.value;\n return value;\n });\n return isAllFieldsTouched ? namePathListEntities.every(isNamePathListTouched) : namePathListEntities.some(isNamePathListTouched);\n };\n\n this.isFieldTouched = function (name) {\n _this.warningUnhooked();\n\n return _this.isFieldsTouched([name]);\n };\n\n this.isFieldsValidating = function (nameList) {\n _this.warningUnhooked();\n\n var fieldEntities = _this.getFieldEntities();\n\n if (!nameList) {\n return fieldEntities.some(function (testField) {\n return testField.isFieldValidating();\n });\n }\n\n var namePathList = nameList.map(getNamePath);\n return fieldEntities.some(function (testField) {\n var fieldNamePath = testField.getNamePath();\n return containsNamePath(namePathList, fieldNamePath) && testField.isFieldValidating();\n });\n };\n\n this.isFieldValidating = function (name) {\n _this.warningUnhooked();\n\n return _this.isFieldsValidating([name]);\n };\n /**\n * Reset Field with field `initialValue` prop.\n * Can pass `entities` or `namePathList` or just nothing.\n */\n\n\n this.resetWithFieldInitialValue = function () {\n var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; // Create cache\n\n var cache = new NameMap();\n\n var fieldEntities = _this.getFieldEntities(true);\n\n fieldEntities.forEach(function (field) {\n var initialValue = field.props.initialValue;\n var namePath = field.getNamePath(); // Record only if has `initialValue`\n\n if (initialValue !== undefined) {\n var records = cache.get(namePath) || new Set();\n records.add({\n entity: field,\n value: initialValue\n });\n cache.set(namePath, records);\n }\n }); // Reset\n\n var resetWithFields = function resetWithFields(entities) {\n entities.forEach(function (field) {\n var initialValue = field.props.initialValue;\n\n if (initialValue !== undefined) {\n var namePath = field.getNamePath();\n\n var formInitialValue = _this.getInitialValue(namePath);\n\n if (formInitialValue !== undefined) {\n // Warning if conflict with form initialValues and do not modify value\n warning(false, \"Form already set 'initialValues' with path '\".concat(namePath.join('.'), \"'. Field can not overwrite it.\"));\n } else {\n var records = cache.get(namePath);\n\n if (records && records.size > 1) {\n // Warning if multiple field set `initialValue`and do not modify value\n warning(false, \"Multiple Field with path '\".concat(namePath.join('.'), \"' set 'initialValue'. Can not decide which one to pick.\"));\n } else if (records) {\n var originValue = _this.getFieldValue(namePath); // Set `initialValue`\n\n\n if (!info.skipExist || originValue === undefined) {\n _this.store = setValue(_this.store, namePath, _toConsumableArray(records)[0].value);\n }\n }\n }\n }\n });\n };\n\n var requiredFieldEntities;\n\n if (info.entities) {\n requiredFieldEntities = info.entities;\n } else if (info.namePathList) {\n requiredFieldEntities = [];\n info.namePathList.forEach(function (namePath) {\n var records = cache.get(namePath);\n\n if (records) {\n var _requiredFieldEntitie;\n\n (_requiredFieldEntitie = requiredFieldEntities).push.apply(_requiredFieldEntitie, _toConsumableArray(_toConsumableArray(records).map(function (r) {\n return r.entity;\n })));\n }\n });\n } else {\n requiredFieldEntities = fieldEntities;\n }\n\n resetWithFields(requiredFieldEntities);\n };\n\n this.resetFields = function (nameList) {\n _this.warningUnhooked();\n\n var prevStore = _this.store;\n\n if (!nameList) {\n _this.store = setValues({}, _this.initialValues);\n\n _this.resetWithFieldInitialValue();\n\n _this.notifyObservers(prevStore, null, {\n type: 'reset'\n });\n\n return;\n } // Reset by `nameList`\n\n\n var namePathList = nameList.map(getNamePath);\n namePathList.forEach(function (namePath) {\n var initialValue = _this.getInitialValue(namePath);\n\n _this.store = setValue(_this.store, namePath, initialValue);\n });\n\n _this.resetWithFieldInitialValue({\n namePathList: namePathList\n });\n\n _this.notifyObservers(prevStore, namePathList, {\n type: 'reset'\n });\n };\n\n this.setFields = function (fields) {\n _this.warningUnhooked();\n\n var prevStore = _this.store;\n fields.forEach(function (fieldData) {\n var name = fieldData.name,\n errors = fieldData.errors,\n data = _objectWithoutProperties(fieldData, [\"name\", \"errors\"]);\n\n var namePath = getNamePath(name); // Value\n\n if ('value' in data) {\n _this.store = setValue(_this.store, namePath, data.value);\n }\n\n _this.notifyObservers(prevStore, [namePath], {\n type: 'setField',\n data: fieldData\n });\n });\n };\n\n this.getFields = function () {\n var entities = _this.getFieldEntities(true);\n\n var fields = entities.map(function (field) {\n var namePath = field.getNamePath();\n var meta = field.getMeta();\n\n var fieldData = _objectSpread(_objectSpread({}, meta), {}, {\n name: namePath,\n value: _this.getFieldValue(namePath)\n });\n\n Object.defineProperty(fieldData, 'originRCField', {\n value: true\n });\n return fieldData;\n });\n return fields;\n }; // =========================== Observer ===========================\n\n /**\n * This only trigger when a field is on constructor to avoid we get initialValue too late\n */\n\n\n this.initEntityValue = function (entity) {\n var initialValue = entity.props.initialValue;\n\n if (initialValue !== undefined) {\n var namePath = entity.getNamePath();\n var prevValue = getValue(_this.store, namePath);\n\n if (prevValue === undefined) {\n _this.store = setValue(_this.store, namePath, initialValue);\n }\n }\n };\n\n this.registerField = function (entity) {\n _this.fieldEntities.push(entity); // Set initial values\n\n\n if (entity.props.initialValue !== undefined) {\n var prevStore = _this.store;\n\n _this.resetWithFieldInitialValue({\n entities: [entity],\n skipExist: true\n });\n\n _this.notifyObservers(prevStore, [entity.getNamePath()], {\n type: 'valueUpdate',\n source: 'internal'\n });\n } // un-register field callback\n\n\n return function (isListField, preserve) {\n _this.fieldEntities = _this.fieldEntities.filter(function (item) {\n return item !== entity;\n }); // Clean up store value if preserve\n\n var mergedPreserve = preserve !== undefined ? preserve : _this.preserve;\n\n if (mergedPreserve === false && !isListField) {\n var namePath = entity.getNamePath();\n\n if (namePath.length && _this.getFieldValue(namePath) !== undefined) {\n _this.store = setValue(_this.store, namePath, undefined);\n }\n }\n };\n };\n\n this.dispatch = function (action) {\n switch (action.type) {\n case 'updateValue':\n {\n var namePath = action.namePath,\n value = action.value;\n\n _this.updateValue(namePath, value);\n\n break;\n }\n\n case 'validateField':\n {\n var _namePath = action.namePath,\n triggerName = action.triggerName;\n\n _this.validateFields([_namePath], {\n triggerName: triggerName\n });\n\n break;\n }\n\n default: // Currently we don't have other action. Do nothing.\n\n }\n };\n\n this.notifyObservers = function (prevStore, namePathList, info) {\n if (_this.subscribable) {\n var mergedInfo = _objectSpread(_objectSpread({}, info), {}, {\n store: _this.getFieldsValue(true)\n });\n\n _this.getFieldEntities().forEach(function (_ref2) {\n var onStoreChange = _ref2.onStoreChange;\n onStoreChange(prevStore, namePathList, mergedInfo);\n });\n } else {\n _this.forceRootUpdate();\n }\n };\n\n this.updateValue = function (name, value) {\n var namePath = getNamePath(name);\n var prevStore = _this.store;\n _this.store = setValue(_this.store, namePath, value);\n\n _this.notifyObservers(prevStore, [namePath], {\n type: 'valueUpdate',\n source: 'internal'\n }); // Notify dependencies children with parent update\n // We need delay to trigger validate in case Field is under render props\n\n\n var childrenFields = _this.getDependencyChildrenFields(namePath);\n\n if (childrenFields.length) {\n _this.validateFields(childrenFields);\n }\n\n _this.notifyObservers(prevStore, childrenFields, {\n type: 'dependenciesUpdate',\n relatedFields: [namePath].concat(_toConsumableArray(childrenFields))\n }); // trigger callback function\n\n\n var onValuesChange = _this.callbacks.onValuesChange;\n\n if (onValuesChange) {\n var changedValues = cloneByNamePathList(_this.store, [namePath]);\n onValuesChange(changedValues, _this.getFieldsValue());\n }\n\n _this.triggerOnFieldsChange([namePath].concat(_toConsumableArray(childrenFields)));\n }; // Let all child Field get update.\n\n\n this.setFieldsValue = function (store) {\n _this.warningUnhooked();\n\n var prevStore = _this.store;\n\n if (store) {\n _this.store = setValues(_this.store, store);\n }\n\n _this.notifyObservers(prevStore, null, {\n type: 'valueUpdate',\n source: 'external'\n });\n };\n\n this.getDependencyChildrenFields = function (rootNamePath) {\n var children = new Set();\n var childrenFields = [];\n var dependencies2fields = new NameMap();\n /**\n * Generate maps\n * Can use cache to save perf if user report performance issue with this\n */\n\n _this.getFieldEntities().forEach(function (field) {\n var dependencies = field.props.dependencies;\n (dependencies || []).forEach(function (dependency) {\n var dependencyNamePath = getNamePath(dependency);\n dependencies2fields.update(dependencyNamePath, function () {\n var fields = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Set();\n fields.add(field);\n return fields;\n });\n });\n });\n\n var fillChildren = function fillChildren(namePath) {\n var fields = dependencies2fields.get(namePath) || new Set();\n fields.forEach(function (field) {\n if (!children.has(field)) {\n children.add(field);\n var fieldNamePath = field.getNamePath();\n\n if (field.isFieldDirty() && fieldNamePath.length) {\n childrenFields.push(fieldNamePath);\n fillChildren(fieldNamePath);\n }\n }\n });\n };\n\n fillChildren(rootNamePath);\n return childrenFields;\n };\n\n this.triggerOnFieldsChange = function (namePathList, filedErrors) {\n var onFieldsChange = _this.callbacks.onFieldsChange;\n\n if (onFieldsChange) {\n var fields = _this.getFields();\n /**\n * Fill errors since `fields` may be replaced by controlled fields\n */\n\n\n if (filedErrors) {\n var cache = new NameMap();\n filedErrors.forEach(function (_ref3) {\n var name = _ref3.name,\n errors = _ref3.errors;\n cache.set(name, errors);\n });\n fields.forEach(function (field) {\n // eslint-disable-next-line no-param-reassign\n field.errors = cache.get(field.name) || field.errors;\n });\n }\n\n var changedFields = fields.filter(function (_ref4) {\n var fieldName = _ref4.name;\n return containsNamePath(namePathList, fieldName);\n });\n onFieldsChange(changedFields, fields);\n }\n }; // =========================== Validate ===========================\n\n\n this.validateFields = function (nameList, options) {\n _this.warningUnhooked();\n\n var provideNameList = !!nameList;\n var namePathList = provideNameList ? nameList.map(getNamePath) : []; // Collect result in promise list\n\n var promiseList = [];\n\n _this.getFieldEntities(true).forEach(function (field) {\n // Add field if not provide `nameList`\n if (!provideNameList) {\n namePathList.push(field.getNamePath());\n }\n /**\n * Recursive validate if configured.\n * TODO: perf improvement @zombieJ\n */\n\n\n if ((options === null || options === void 0 ? void 0 : options.recursive) && provideNameList) {\n var namePath = field.getNamePath();\n\n if ( // nameList[i] === undefined 说明是以 nameList 开头的\n // ['name'] -> ['name','list']\n namePath.every(function (nameUnit, i) {\n return nameList[i] === nameUnit || nameList[i] === undefined;\n })) {\n namePathList.push(namePath);\n }\n } // Skip if without rule\n\n\n if (!field.props.rules || !field.props.rules.length) {\n return;\n }\n\n var fieldNamePath = field.getNamePath(); // Add field validate rule in to promise list\n\n if (!provideNameList || containsNamePath(namePathList, fieldNamePath)) {\n var promise = field.validateRules(_objectSpread({\n validateMessages: _objectSpread(_objectSpread({}, defaultValidateMessages), _this.validateMessages)\n }, options)); // Wrap promise with field\n\n promiseList.push(promise.then(function () {\n return {\n name: fieldNamePath,\n errors: []\n };\n }).catch(function (errors) {\n return Promise.reject({\n name: fieldNamePath,\n errors: errors\n });\n }));\n }\n });\n\n var summaryPromise = allPromiseFinish(promiseList);\n _this.lastValidatePromise = summaryPromise; // Notify fields with rule that validate has finished and need update\n\n summaryPromise.catch(function (results) {\n return results;\n }).then(function (results) {\n var resultNamePathList = results.map(function (_ref5) {\n var name = _ref5.name;\n return name;\n });\n\n _this.notifyObservers(_this.store, resultNamePathList, {\n type: 'validateFinish'\n });\n\n _this.triggerOnFieldsChange(resultNamePathList, results);\n });\n var returnPromise = summaryPromise.then(function () {\n if (_this.lastValidatePromise === summaryPromise) {\n return Promise.resolve(_this.getFieldsValue(namePathList));\n }\n\n return Promise.reject([]);\n }).catch(function (results) {\n var errorList = results.filter(function (result) {\n return result && result.errors.length;\n });\n return Promise.reject({\n values: _this.getFieldsValue(namePathList),\n errorFields: errorList,\n outOfDate: _this.lastValidatePromise !== summaryPromise\n });\n }); // Do not throw in console\n\n returnPromise.catch(function (e) {\n return e;\n });\n return returnPromise;\n }; // ============================ Submit ============================\n\n\n this.submit = function () {\n _this.warningUnhooked();\n\n _this.validateFields().then(function (values) {\n var onFinish = _this.callbacks.onFinish;\n\n if (onFinish) {\n try {\n onFinish(values);\n } catch (err) {\n // Should print error if user `onFinish` callback failed\n console.error(err);\n }\n }\n }).catch(function (e) {\n var onFinishFailed = _this.callbacks.onFinishFailed;\n\n if (onFinishFailed) {\n onFinishFailed(e);\n }\n });\n };\n\n this.forceRootUpdate = forceRootUpdate;\n};\n\nfunction useForm(form) {\n var formRef = React.useRef();\n\n var _React$useState = React.useState({}),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n forceUpdate = _React$useState2[1];\n\n if (!formRef.current) {\n if (form) {\n formRef.current = form;\n } else {\n // Create a new FormStore if not provided\n var forceReRender = function forceReRender() {\n forceUpdate({});\n };\n\n var formStore = new FormStore(forceReRender);\n formRef.current = formStore.getForm();\n }\n }\n\n return [formRef.current];\n}\n\nexport default useForm;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-field-form/es/useForm.js"],"names":["_slicedToArray","_objectSpread","_objectWithoutProperties","_toConsumableArray","_classCallCheck","React","warning","HOOK_MARK","allPromiseFinish","NameMap","defaultValidateMessages","cloneByNamePathList","containsNamePath","getNamePath","getValue","setValue","setValues","FormStore","forceRootUpdate","_this","formHooked","subscribable","store","fieldEntities","initialValues","callbacks","validateMessages","preserve","lastValidatePromise","getForm","getFieldValue","getFieldsValue","getFieldError","getFieldsError","isFieldsTouched","isFieldTouched","isFieldValidating","isFieldsValidating","resetFields","setFields","setFieldsValue","validateFields","submit","getInternalHooks","key","dispatch","initEntityValue","registerField","useSubscribe","setInitialValues","setCallbacks","setValidateMessages","getFields","setPreserve","init","getInitialValue","namePath","timeoutId","warningUnhooked","process","env","NODE_ENV","window","setTimeout","getFieldEntities","pure","arguments","length","undefined","filter","field","getFieldsMap","cache","forEach","set","getFieldEntitiesForNamePathList","nameList","map","name","get","INVALIDATE_NAME_PATH","filterFunc","Array","isArray","filteredNameList","entity","_entity$isListField","isListField","call","push","meta","getMeta","index","errors","getErrors","fieldError","_len","args","_key","arg0","arg1","namePathList","isAllFieldsTouched","every","some","shortNamePath","fieldNamePath","nameUnit","i","update","list","concat","isNamePathListTouched","entities","namePathListEntities","_ref","value","testField","resetWithFieldInitialValue","info","initialValue","props","records","Set","add","resetWithFields","formInitialValue","join","size","originValue","skipExist","requiredFieldEntities","_requiredFieldEntitie","apply","r","prevStore","notifyObservers","type","fields","fieldData","data","Object","defineProperty","prevValue","source","item","mergedPreserve","action","updateValue","_namePath","triggerName","mergedInfo","_ref2","onStoreChange","childrenFields","getDependencyChildrenFields","relatedFields","onValuesChange","changedValues","triggerOnFieldsChange","rootNamePath","children","dependencies2fields","dependencies","dependency","dependencyNamePath","fillChildren","has","isFieldDirty","filedErrors","onFieldsChange","_ref3","changedFields","_ref4","fieldName","options","provideNameList","promiseList","recursive","rules","promise","validateRules","then","catch","Promise","reject","summaryPromise","results","resultNamePathList","_ref5","returnPromise","resolve","errorList","result","values","errorFields","outOfDate","e","onFinish","err","console","error","onFinishFailed","useForm","form","formRef","useRef","_React$useState","useState","_React$useState2","forceUpdate","current","forceReRender","formStore"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,0CAA3B;AACA,OAAOC,aAAP,MAA0B,0CAA1B;AACA,OAAOC,wBAAP,MAAqC,oDAArC;AACA,OAAOC,kBAAP,MAA+B,8CAA/B;AACA,OAAOC,eAAP,MAA4B,2CAA5B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC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F;AACF,KAXD,EAWGhB,KAXH,CAWS,UAAUc,CAAV,EAAa;AACpB,UAAIK,cAAc,GAAGvL,KAAK,CAACM,SAAN,CAAgBiL,cAArC;;AAEA,UAAIA,cAAJ,EAAoB;AAClBA,QAAAA,cAAc,CAACL,CAAD,CAAd;AACD;AACF,KAjBD;AAkBD,GArBD;;AAuBA,OAAKnL,eAAL,GAAuBA,eAAvB;AACD,CA9yBM;;AAgzBP,SAASyL,OAAT,CAAiBC,IAAjB,EAAuB;AACrB,MAAIC,OAAO,GAAGxM,KAAK,CAACyM,MAAN,EAAd;;AAEA,MAAIC,eAAe,GAAG1M,KAAK,CAAC2M,QAAN,CAAe,EAAf,CAAtB;AAAA,MACIC,gBAAgB,GAAGjN,cAAc,CAAC+M,eAAD,EAAkB,CAAlB,CADrC;AAAA,MAEIG,WAAW,GAAGD,gBAAgB,CAAC,CAAD,CAFlC;;AAIA,MAAI,CAACJ,OAAO,CAACM,OAAb,EAAsB;AACpB,QAAIP,IAAJ,EAAU;AACRC,MAAAA,OAAO,CAACM,OAAR,GAAkBP,IAAlB;AACD,KAFD,MAEO;AACL;AACA,UAAIQ,aAAa,GAAG,SAASA,aAAT,GAAyB;AAC3CF,QAAAA,WAAW,CAAC,EAAD,CAAX;AACD,OAFD;;AAIA,UAAIG,SAAS,GAAG,IAAIpM,SAAJ,CAAcmM,aAAd,CAAhB;AACAP,MAAAA,OAAO,CAACM,OAAR,GAAkBE,SAAS,CAACxL,OAAV,EAAlB;AACD;AACF;;AAED,SAAO,CAACgL,OAAO,CAACM,OAAT,CAAP;AACD;;AAED,eAAeR,OAAf","sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport * as React from 'react';\nimport warning from \"rc-util/es/warning\";\nimport { HOOK_MARK } from './FieldContext';\nimport { allPromiseFinish } from './utils/asyncUtil';\nimport NameMap from './utils/NameMap';\nimport { defaultValidateMessages } from './utils/messages';\nimport { cloneByNamePathList, containsNamePath, getNamePath, getValue, setValue, setValues } from './utils/valueUtil';\nexport var FormStore = function FormStore(forceRootUpdate) {\n var _this = this;\n\n _classCallCheck(this, FormStore);\n\n this.formHooked = false;\n this.subscribable = true;\n this.store = {};\n this.fieldEntities = [];\n this.initialValues = {};\n this.callbacks = {};\n this.validateMessages = null;\n this.preserve = null;\n this.lastValidatePromise = null;\n\n this.getForm = function () {\n return {\n getFieldValue: _this.getFieldValue,\n getFieldsValue: _this.getFieldsValue,\n getFieldError: _this.getFieldError,\n getFieldsError: _this.getFieldsError,\n isFieldsTouched: _this.isFieldsTouched,\n isFieldTouched: _this.isFieldTouched,\n isFieldValidating: _this.isFieldValidating,\n isFieldsValidating: _this.isFieldsValidating,\n resetFields: _this.resetFields,\n setFields: _this.setFields,\n setFieldsValue: _this.setFieldsValue,\n validateFields: _this.validateFields,\n submit: _this.submit,\n getInternalHooks: _this.getInternalHooks\n };\n }; // ======================== Internal Hooks ========================\n\n\n this.getInternalHooks = function (key) {\n if (key === HOOK_MARK) {\n _this.formHooked = true;\n return {\n dispatch: _this.dispatch,\n initEntityValue: _this.initEntityValue,\n registerField: _this.registerField,\n useSubscribe: _this.useSubscribe,\n setInitialValues: _this.setInitialValues,\n setCallbacks: _this.setCallbacks,\n setValidateMessages: _this.setValidateMessages,\n getFields: _this.getFields,\n setPreserve: _this.setPreserve\n };\n }\n\n warning(false, '`getInternalHooks` is internal usage. Should not call directly.');\n return null;\n };\n\n this.useSubscribe = function (subscribable) {\n _this.subscribable = subscribable;\n };\n /**\n * First time `setInitialValues` should update store with initial value\n */\n\n\n this.setInitialValues = function (initialValues, init) {\n _this.initialValues = initialValues || {};\n\n if (init) {\n _this.store = setValues({}, initialValues, _this.store);\n }\n };\n\n this.getInitialValue = function (namePath) {\n return getValue(_this.initialValues, namePath);\n };\n\n this.setCallbacks = function (callbacks) {\n _this.callbacks = callbacks;\n };\n\n this.setValidateMessages = function (validateMessages) {\n _this.validateMessages = validateMessages;\n };\n\n this.setPreserve = function (preserve) {\n _this.preserve = preserve;\n }; // ========================== Dev Warning =========================\n\n\n this.timeoutId = null;\n\n this.warningUnhooked = function () {\n if (process.env.NODE_ENV !== 'production' && !_this.timeoutId && typeof window !== 'undefined') {\n _this.timeoutId = window.setTimeout(function () {\n _this.timeoutId = null;\n\n if (!_this.formHooked) {\n warning(false, 'Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?');\n }\n });\n }\n }; // ============================ Fields ============================\n\n /**\n * Get registered field entities.\n * @param pure Only return field which has a `name`. Default: false\n */\n\n\n this.getFieldEntities = function () {\n var pure = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n\n if (!pure) {\n return _this.fieldEntities;\n }\n\n return _this.fieldEntities.filter(function (field) {\n return field.getNamePath().length;\n });\n };\n\n this.getFieldsMap = function () {\n var pure = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n var cache = new NameMap();\n\n _this.getFieldEntities(pure).forEach(function (field) {\n var namePath = field.getNamePath();\n cache.set(namePath, field);\n });\n\n return cache;\n };\n\n this.getFieldEntitiesForNamePathList = function (nameList) {\n if (!nameList) {\n return _this.getFieldEntities(true);\n }\n\n var cache = _this.getFieldsMap(true);\n\n return nameList.map(function (name) {\n var namePath = getNamePath(name);\n return cache.get(namePath) || {\n INVALIDATE_NAME_PATH: getNamePath(name)\n };\n });\n };\n\n this.getFieldsValue = function (nameList, filterFunc) {\n _this.warningUnhooked();\n\n if (nameList === true && !filterFunc) {\n return _this.store;\n }\n\n var fieldEntities = _this.getFieldEntitiesForNamePathList(Array.isArray(nameList) ? nameList : null);\n\n var filteredNameList = [];\n fieldEntities.forEach(function (entity) {\n var _entity$isListField;\n\n var namePath = 'INVALIDATE_NAME_PATH' in entity ? entity.INVALIDATE_NAME_PATH : entity.getNamePath(); // Ignore when it's a list item and not specific the namePath,\n // since parent field is already take in count\n\n if (!nameList && ((_entity$isListField = entity.isListField) === null || _entity$isListField === void 0 ? void 0 : _entity$isListField.call(entity))) {\n return;\n }\n\n if (!filterFunc) {\n filteredNameList.push(namePath);\n } else {\n var meta = 'getMeta' in entity ? entity.getMeta() : null;\n\n if (filterFunc(meta)) {\n filteredNameList.push(namePath);\n }\n }\n });\n return cloneByNamePathList(_this.store, filteredNameList.map(getNamePath));\n };\n\n this.getFieldValue = function (name) {\n _this.warningUnhooked();\n\n var namePath = getNamePath(name);\n return getValue(_this.store, namePath);\n };\n\n this.getFieldsError = function (nameList) {\n _this.warningUnhooked();\n\n var fieldEntities = _this.getFieldEntitiesForNamePathList(nameList);\n\n return fieldEntities.map(function (entity, index) {\n if (entity && !('INVALIDATE_NAME_PATH' in entity)) {\n return {\n name: entity.getNamePath(),\n errors: entity.getErrors()\n };\n }\n\n return {\n name: getNamePath(nameList[index]),\n errors: []\n };\n });\n };\n\n this.getFieldError = function (name) {\n _this.warningUnhooked();\n\n var namePath = getNamePath(name);\n\n var fieldError = _this.getFieldsError([namePath])[0];\n\n return fieldError.errors;\n };\n\n this.isFieldsTouched = function () {\n _this.warningUnhooked();\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var arg0 = args[0],\n arg1 = args[1];\n var namePathList;\n var isAllFieldsTouched = false;\n\n if (args.length === 0) {\n namePathList = null;\n } else if (args.length === 1) {\n if (Array.isArray(arg0)) {\n namePathList = arg0.map(getNamePath);\n isAllFieldsTouched = false;\n } else {\n namePathList = null;\n isAllFieldsTouched = arg0;\n }\n } else {\n namePathList = arg0.map(getNamePath);\n isAllFieldsTouched = arg1;\n }\n\n var fieldEntities = _this.getFieldEntities(true);\n\n var isFieldTouched = function isFieldTouched(field) {\n return field.isFieldTouched();\n }; // ===== Will get fully compare when not config namePathList =====\n\n\n if (!namePathList) {\n return isAllFieldsTouched ? fieldEntities.every(isFieldTouched) : fieldEntities.some(isFieldTouched);\n } // Generate a nest tree for validate\n\n\n var map = new NameMap();\n namePathList.forEach(function (shortNamePath) {\n map.set(shortNamePath, []);\n });\n fieldEntities.forEach(function (field) {\n var fieldNamePath = field.getNamePath(); // Find matched entity and put into list\n\n namePathList.forEach(function (shortNamePath) {\n if (shortNamePath.every(function (nameUnit, i) {\n return fieldNamePath[i] === nameUnit;\n })) {\n map.update(shortNamePath, function (list) {\n return [].concat(_toConsumableArray(list), [field]);\n });\n }\n });\n }); // Check if NameMap value is touched\n\n var isNamePathListTouched = function isNamePathListTouched(entities) {\n return entities.some(isFieldTouched);\n };\n\n var namePathListEntities = map.map(function (_ref) {\n var value = _ref.value;\n return value;\n });\n return isAllFieldsTouched ? namePathListEntities.every(isNamePathListTouched) : namePathListEntities.some(isNamePathListTouched);\n };\n\n this.isFieldTouched = function (name) {\n _this.warningUnhooked();\n\n return _this.isFieldsTouched([name]);\n };\n\n this.isFieldsValidating = function (nameList) {\n _this.warningUnhooked();\n\n var fieldEntities = _this.getFieldEntities();\n\n if (!nameList) {\n return fieldEntities.some(function (testField) {\n return testField.isFieldValidating();\n });\n }\n\n var namePathList = nameList.map(getNamePath);\n return fieldEntities.some(function (testField) {\n var fieldNamePath = testField.getNamePath();\n return containsNamePath(namePathList, fieldNamePath) && testField.isFieldValidating();\n });\n };\n\n this.isFieldValidating = function (name) {\n _this.warningUnhooked();\n\n return _this.isFieldsValidating([name]);\n };\n /**\n * Reset Field with field `initialValue` prop.\n * Can pass `entities` or `namePathList` or just nothing.\n */\n\n\n this.resetWithFieldInitialValue = function () {\n var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n // Create cache\n var cache = new NameMap();\n\n var fieldEntities = _this.getFieldEntities(true);\n\n fieldEntities.forEach(function (field) {\n var initialValue = field.props.initialValue;\n var namePath = field.getNamePath(); // Record only if has `initialValue`\n\n if (initialValue !== undefined) {\n var records = cache.get(namePath) || new Set();\n records.add({\n entity: field,\n value: initialValue\n });\n cache.set(namePath, records);\n }\n }); // Reset\n\n var resetWithFields = function resetWithFields(entities) {\n entities.forEach(function (field) {\n var initialValue = field.props.initialValue;\n\n if (initialValue !== undefined) {\n var namePath = field.getNamePath();\n\n var formInitialValue = _this.getInitialValue(namePath);\n\n if (formInitialValue !== undefined) {\n // Warning if conflict with form initialValues and do not modify value\n warning(false, \"Form already set 'initialValues' with path '\".concat(namePath.join('.'), \"'. Field can not overwrite it.\"));\n } else {\n var records = cache.get(namePath);\n\n if (records && records.size > 1) {\n // Warning if multiple field set `initialValue`and do not modify value\n warning(false, \"Multiple Field with path '\".concat(namePath.join('.'), \"' set 'initialValue'. Can not decide which one to pick.\"));\n } else if (records) {\n var originValue = _this.getFieldValue(namePath); // Set `initialValue`\n\n\n if (!info.skipExist || originValue === undefined) {\n _this.store = setValue(_this.store, namePath, _toConsumableArray(records)[0].value);\n }\n }\n }\n }\n });\n };\n\n var requiredFieldEntities;\n\n if (info.entities) {\n requiredFieldEntities = info.entities;\n } else if (info.namePathList) {\n requiredFieldEntities = [];\n info.namePathList.forEach(function (namePath) {\n var records = cache.get(namePath);\n\n if (records) {\n var _requiredFieldEntitie;\n\n (_requiredFieldEntitie = requiredFieldEntities).push.apply(_requiredFieldEntitie, _toConsumableArray(_toConsumableArray(records).map(function (r) {\n return r.entity;\n })));\n }\n });\n } else {\n requiredFieldEntities = fieldEntities;\n }\n\n resetWithFields(requiredFieldEntities);\n };\n\n this.resetFields = function (nameList) {\n _this.warningUnhooked();\n\n var prevStore = _this.store;\n\n if (!nameList) {\n _this.store = setValues({}, _this.initialValues);\n\n _this.resetWithFieldInitialValue();\n\n _this.notifyObservers(prevStore, null, {\n type: 'reset'\n });\n\n return;\n } // Reset by `nameList`\n\n\n var namePathList = nameList.map(getNamePath);\n namePathList.forEach(function (namePath) {\n var initialValue = _this.getInitialValue(namePath);\n\n _this.store = setValue(_this.store, namePath, initialValue);\n });\n\n _this.resetWithFieldInitialValue({\n namePathList: namePathList\n });\n\n _this.notifyObservers(prevStore, namePathList, {\n type: 'reset'\n });\n };\n\n this.setFields = function (fields) {\n _this.warningUnhooked();\n\n var prevStore = _this.store;\n fields.forEach(function (fieldData) {\n var name = fieldData.name,\n errors = fieldData.errors,\n data = _objectWithoutProperties(fieldData, [\"name\", \"errors\"]);\n\n var namePath = getNamePath(name); // Value\n\n if ('value' in data) {\n _this.store = setValue(_this.store, namePath, data.value);\n }\n\n _this.notifyObservers(prevStore, [namePath], {\n type: 'setField',\n data: fieldData\n });\n });\n };\n\n this.getFields = function () {\n var entities = _this.getFieldEntities(true);\n\n var fields = entities.map(function (field) {\n var namePath = field.getNamePath();\n var meta = field.getMeta();\n\n var fieldData = _objectSpread(_objectSpread({}, meta), {}, {\n name: namePath,\n value: _this.getFieldValue(namePath)\n });\n\n Object.defineProperty(fieldData, 'originRCField', {\n value: true\n });\n return fieldData;\n });\n return fields;\n }; // =========================== Observer ===========================\n\n /**\n * This only trigger when a field is on constructor to avoid we get initialValue too late\n */\n\n\n this.initEntityValue = function (entity) {\n var initialValue = entity.props.initialValue;\n\n if (initialValue !== undefined) {\n var namePath = entity.getNamePath();\n var prevValue = getValue(_this.store, namePath);\n\n if (prevValue === undefined) {\n _this.store = setValue(_this.store, namePath, initialValue);\n }\n }\n };\n\n this.registerField = function (entity) {\n _this.fieldEntities.push(entity); // Set initial values\n\n\n if (entity.props.initialValue !== undefined) {\n var prevStore = _this.store;\n\n _this.resetWithFieldInitialValue({\n entities: [entity],\n skipExist: true\n });\n\n _this.notifyObservers(prevStore, [entity.getNamePath()], {\n type: 'valueUpdate',\n source: 'internal'\n });\n } // un-register field callback\n\n\n return function (isListField, preserve) {\n _this.fieldEntities = _this.fieldEntities.filter(function (item) {\n return item !== entity;\n }); // Clean up store value if preserve\n\n var mergedPreserve = preserve !== undefined ? preserve : _this.preserve;\n\n if (mergedPreserve === false && !isListField) {\n var namePath = entity.getNamePath();\n\n if (namePath.length && _this.getFieldValue(namePath) !== undefined) {\n _this.store = setValue(_this.store, namePath, undefined);\n }\n }\n };\n };\n\n this.dispatch = function (action) {\n switch (action.type) {\n case 'updateValue':\n {\n var namePath = action.namePath,\n value = action.value;\n\n _this.updateValue(namePath, value);\n\n break;\n }\n\n case 'validateField':\n {\n var _namePath = action.namePath,\n triggerName = action.triggerName;\n\n _this.validateFields([_namePath], {\n triggerName: triggerName\n });\n\n break;\n }\n\n default: // Currently we don't have other action. Do nothing.\n\n }\n };\n\n this.notifyObservers = function (prevStore, namePathList, info) {\n if (_this.subscribable) {\n var mergedInfo = _objectSpread(_objectSpread({}, info), {}, {\n store: _this.getFieldsValue(true)\n });\n\n _this.getFieldEntities().forEach(function (_ref2) {\n var onStoreChange = _ref2.onStoreChange;\n onStoreChange(prevStore, namePathList, mergedInfo);\n });\n } else {\n _this.forceRootUpdate();\n }\n };\n\n this.updateValue = function (name, value) {\n var namePath = getNamePath(name);\n var prevStore = _this.store;\n _this.store = setValue(_this.store, namePath, value);\n\n _this.notifyObservers(prevStore, [namePath], {\n type: 'valueUpdate',\n source: 'internal'\n }); // Notify dependencies children with parent update\n // We need delay to trigger validate in case Field is under render props\n\n\n var childrenFields = _this.getDependencyChildrenFields(namePath);\n\n if (childrenFields.length) {\n _this.validateFields(childrenFields);\n }\n\n _this.notifyObservers(prevStore, childrenFields, {\n type: 'dependenciesUpdate',\n relatedFields: [namePath].concat(_toConsumableArray(childrenFields))\n }); // trigger callback function\n\n\n var onValuesChange = _this.callbacks.onValuesChange;\n\n if (onValuesChange) {\n var changedValues = cloneByNamePathList(_this.store, [namePath]);\n onValuesChange(changedValues, _this.getFieldsValue());\n }\n\n _this.triggerOnFieldsChange([namePath].concat(_toConsumableArray(childrenFields)));\n }; // Let all child Field get update.\n\n\n this.setFieldsValue = function (store) {\n _this.warningUnhooked();\n\n var prevStore = _this.store;\n\n if (store) {\n _this.store = setValues(_this.store, store);\n }\n\n _this.notifyObservers(prevStore, null, {\n type: 'valueUpdate',\n source: 'external'\n });\n };\n\n this.getDependencyChildrenFields = function (rootNamePath) {\n var children = new Set();\n var childrenFields = [];\n var dependencies2fields = new NameMap();\n /**\n * Generate maps\n * Can use cache to save perf if user report performance issue with this\n */\n\n _this.getFieldEntities().forEach(function (field) {\n var dependencies = field.props.dependencies;\n (dependencies || []).forEach(function (dependency) {\n var dependencyNamePath = getNamePath(dependency);\n dependencies2fields.update(dependencyNamePath, function () {\n var fields = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Set();\n fields.add(field);\n return fields;\n });\n });\n });\n\n var fillChildren = function fillChildren(namePath) {\n var fields = dependencies2fields.get(namePath) || new Set();\n fields.forEach(function (field) {\n if (!children.has(field)) {\n children.add(field);\n var fieldNamePath = field.getNamePath();\n\n if (field.isFieldDirty() && fieldNamePath.length) {\n childrenFields.push(fieldNamePath);\n fillChildren(fieldNamePath);\n }\n }\n });\n };\n\n fillChildren(rootNamePath);\n return childrenFields;\n };\n\n this.triggerOnFieldsChange = function (namePathList, filedErrors) {\n var onFieldsChange = _this.callbacks.onFieldsChange;\n\n if (onFieldsChange) {\n var fields = _this.getFields();\n /**\n * Fill errors since `fields` may be replaced by controlled fields\n */\n\n\n if (filedErrors) {\n var cache = new NameMap();\n filedErrors.forEach(function (_ref3) {\n var name = _ref3.name,\n errors = _ref3.errors;\n cache.set(name, errors);\n });\n fields.forEach(function (field) {\n // eslint-disable-next-line no-param-reassign\n field.errors = cache.get(field.name) || field.errors;\n });\n }\n\n var changedFields = fields.filter(function (_ref4) {\n var fieldName = _ref4.name;\n return containsNamePath(namePathList, fieldName);\n });\n onFieldsChange(changedFields, fields);\n }\n }; // =========================== Validate ===========================\n\n\n this.validateFields = function (nameList, options) {\n _this.warningUnhooked();\n\n var provideNameList = !!nameList;\n var namePathList = provideNameList ? nameList.map(getNamePath) : []; // Collect result in promise list\n\n var promiseList = [];\n\n _this.getFieldEntities(true).forEach(function (field) {\n // Add field if not provide `nameList`\n if (!provideNameList) {\n namePathList.push(field.getNamePath());\n }\n /**\n * Recursive validate if configured.\n * TODO: perf improvement @zombieJ\n */\n\n\n if ((options === null || options === void 0 ? void 0 : options.recursive) && provideNameList) {\n var namePath = field.getNamePath();\n\n if ( // nameList[i] === undefined 说明是以 nameList 开头的\n // ['name'] -> ['name','list']\n namePath.every(function (nameUnit, i) {\n return nameList[i] === nameUnit || nameList[i] === undefined;\n })) {\n namePathList.push(namePath);\n }\n } // Skip if without rule\n\n\n if (!field.props.rules || !field.props.rules.length) {\n return;\n }\n\n var fieldNamePath = field.getNamePath(); // Add field validate rule in to promise list\n\n if (!provideNameList || containsNamePath(namePathList, fieldNamePath)) {\n var promise = field.validateRules(_objectSpread({\n validateMessages: _objectSpread(_objectSpread({}, defaultValidateMessages), _this.validateMessages)\n }, options)); // Wrap promise with field\n\n promiseList.push(promise.then(function () {\n return {\n name: fieldNamePath,\n errors: []\n };\n }).catch(function (errors) {\n return Promise.reject({\n name: fieldNamePath,\n errors: errors\n });\n }));\n }\n });\n\n var summaryPromise = allPromiseFinish(promiseList);\n _this.lastValidatePromise = summaryPromise; // Notify fields with rule that validate has finished and need update\n\n summaryPromise.catch(function (results) {\n return results;\n }).then(function (results) {\n var resultNamePathList = results.map(function (_ref5) {\n var name = _ref5.name;\n return name;\n });\n\n _this.notifyObservers(_this.store, resultNamePathList, {\n type: 'validateFinish'\n });\n\n _this.triggerOnFieldsChange(resultNamePathList, results);\n });\n var returnPromise = summaryPromise.then(function () {\n if (_this.lastValidatePromise === summaryPromise) {\n return Promise.resolve(_this.getFieldsValue(namePathList));\n }\n\n return Promise.reject([]);\n }).catch(function (results) {\n var errorList = results.filter(function (result) {\n return result && result.errors.length;\n });\n return Promise.reject({\n values: _this.getFieldsValue(namePathList),\n errorFields: errorList,\n outOfDate: _this.lastValidatePromise !== summaryPromise\n });\n }); // Do not throw in console\n\n returnPromise.catch(function (e) {\n return e;\n });\n return returnPromise;\n }; // ============================ Submit ============================\n\n\n this.submit = function () {\n _this.warningUnhooked();\n\n _this.validateFields().then(function (values) {\n var onFinish = _this.callbacks.onFinish;\n\n if (onFinish) {\n try {\n onFinish(values);\n } catch (err) {\n // Should print error if user `onFinish` callback failed\n console.error(err);\n }\n }\n }).catch(function (e) {\n var onFinishFailed = _this.callbacks.onFinishFailed;\n\n if (onFinishFailed) {\n onFinishFailed(e);\n }\n });\n };\n\n this.forceRootUpdate = forceRootUpdate;\n};\n\nfunction useForm(form) {\n var formRef = React.useRef();\n\n var _React$useState = React.useState({}),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n forceUpdate = _React$useState2[1];\n\n if (!formRef.current) {\n if (form) {\n formRef.current = form;\n } else {\n // Create a new FormStore if not provided\n var forceReRender = function forceReRender() {\n forceUpdate({});\n };\n\n var formStore = new FormStore(forceReRender);\n formRef.current = formStore.getForm();\n }\n }\n\n return [formRef.current];\n}\n\nexport default useForm;"]},"metadata":{},"sourceType":"module"}