@mantine/form
Advanced tools
Comparing version
@@ -46,7 +46,7 @@ 'use strict'; | ||
}); | ||
const setFieldValue = (field, value) => { | ||
const setFieldValue = (field, value, errorPath) => { | ||
setValues((currentValues) => __spreadProps(__spreadValues({}, currentValues), { [field]: value })); | ||
clearFieldError(field); | ||
clearFieldError(errorPath); | ||
}; | ||
const setListItem = (field, index, value) => { | ||
const setListItem = (field, index, value, errorPath) => { | ||
const list = values[field]; | ||
@@ -56,3 +56,3 @@ if (formList.isFormList(list) && list[index] !== void 0) { | ||
cloned[index] = value; | ||
setFieldValue(field, formList.formList(cloned)); | ||
setFieldValue(field, formList.formList(cloned), errorPath); | ||
} | ||
@@ -115,3 +115,4 @@ }; | ||
const value = listValue[listField]; | ||
const onChange = getInputOnChange.getInputOnChange((val) => setListItem(field, index, __spreadProps(__spreadValues({}, listValue), { [listField]: val }))); | ||
const listItemErrorPath = getErrorPath.getErrorPath([field, index, listField]); | ||
const onChange = getInputOnChange.getInputOnChange((val) => setListItem(field, index, __spreadProps(__spreadValues({}, listValue), { [listField]: val }), listItemErrorPath)); | ||
const payload = type === "checkbox" ? { checked: value, onChange } : { value, onChange }; | ||
@@ -118,0 +119,0 @@ const error = errors[getErrorPath.getErrorPath([field, index, listField])]; |
@@ -42,7 +42,7 @@ import { useState } from 'react'; | ||
}); | ||
const setFieldValue = (field, value) => { | ||
const setFieldValue = (field, value, errorPath) => { | ||
setValues((currentValues) => __spreadProps(__spreadValues({}, currentValues), { [field]: value })); | ||
clearFieldError(field); | ||
clearFieldError(errorPath); | ||
}; | ||
const setListItem = (field, index, value) => { | ||
const setListItem = (field, index, value, errorPath) => { | ||
const list = values[field]; | ||
@@ -52,3 +52,3 @@ if (isFormList(list) && list[index] !== void 0) { | ||
cloned[index] = value; | ||
setFieldValue(field, formList(cloned)); | ||
setFieldValue(field, formList(cloned), errorPath); | ||
} | ||
@@ -111,3 +111,4 @@ }; | ||
const value = listValue[listField]; | ||
const onChange = getInputOnChange((val) => setListItem(field, index, __spreadProps(__spreadValues({}, listValue), { [listField]: val }))); | ||
const listItemErrorPath = getErrorPath([field, index, listField]); | ||
const onChange = getInputOnChange((val) => setListItem(field, index, __spreadProps(__spreadValues({}, listValue), { [listField]: val }), listItemErrorPath)); | ||
const payload = type === "checkbox" ? { checked: value, onChange } : { value, onChange }; | ||
@@ -114,0 +115,0 @@ const error = errors[getErrorPath([field, index, listField])]; |
{ | ||
"name": "@mantine/form", | ||
"description": "Mantine form management library", | ||
"version": "4.2.4", | ||
"version": "4.2.5", | ||
"main": "cjs/index.js", | ||
@@ -6,0 +6,0 @@ "module": "esm/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
93477
0.94%778
0.26%