@rc-component/form
Advanced tools
| import { merge } from "@rc-component/util/es/utils/set"; | ||
| import { mergeWith } from '@rc-component/util'; | ||
| import warning from "@rc-component/util/es/warning"; | ||
@@ -642,10 +641,5 @@ import * as React from 'react'; | ||
| if (onValuesChange) { | ||
| const fieldEntity = this.getFieldsMap(true).get(namePath); | ||
| const changedValues = cloneByNamePathList(this.store, [namePath]); | ||
| const allValues = this.getFieldsValue(); | ||
| // Merge changedValues into allValues to ensure allValues contains the latest changes | ||
| const mergedAllValues = mergeWith([allValues, changedValues], { | ||
| // When value is array, it means trigger by Form.List which should replace directly | ||
| prepareArray: current => fieldEntity?.isList() ? [] : [...(current || [])] | ||
| }); | ||
| const mergedAllValues = setValue(allValues, namePath, getValue(changedValues, namePath)); | ||
| onValuesChange(changedValues, mergedAllValues); | ||
@@ -652,0 +646,0 @@ } |
@@ -8,3 +8,2 @@ "use strict"; | ||
| var _set = require("@rc-component/util/lib/utils/set"); | ||
| var _util = require("@rc-component/util"); | ||
| var _warning = _interopRequireDefault(require("@rc-component/util/lib/warning")); | ||
@@ -652,10 +651,5 @@ var React = _interopRequireWildcard(require("react")); | ||
| if (onValuesChange) { | ||
| const fieldEntity = this.getFieldsMap(true).get(namePath); | ||
| const changedValues = (0, _valueUtil.cloneByNamePathList)(this.store, [namePath]); | ||
| const allValues = this.getFieldsValue(); | ||
| // Merge changedValues into allValues to ensure allValues contains the latest changes | ||
| const mergedAllValues = (0, _util.mergeWith)([allValues, changedValues], { | ||
| // When value is array, it means trigger by Form.List which should replace directly | ||
| prepareArray: current => fieldEntity?.isList() ? [] : [...(current || [])] | ||
| }); | ||
| const mergedAllValues = (0, _valueUtil.setValue)(allValues, namePath, (0, _valueUtil.getValue)(changedValues, namePath)); | ||
| onValuesChange(changedValues, mergedAllValues); | ||
@@ -662,0 +656,0 @@ } |
+1
-1
| { | ||
| "name": "@rc-component/form", | ||
| "version": "1.7.2", | ||
| "version": "1.8.0", | ||
| "description": "React Form Component", | ||
@@ -5,0 +5,0 @@ "typings": "es/index.d.ts", |
250638
-0.28%6490
-0.18%