@altiore/form
Advanced tools
Comparing version 0.3.19 to 0.3.20
@@ -13,5 +13,7 @@ var __assign = (this && this.__assign) || function () { | ||
import React, { useCallback, useRef, useState, } from 'react'; | ||
import cloneDeep from 'lodash/cloneDeep'; | ||
import get from 'lodash/get'; | ||
import isEqual from 'lodash/isEqual'; | ||
import set from 'lodash/set'; | ||
import unset from 'lodash/unset'; | ||
import { FormContext } from '../@common/form-context'; | ||
@@ -80,8 +82,20 @@ /** | ||
var values = {}; | ||
formData.forEach(function (value, key) { | ||
var keyArr = key.split('.'); | ||
set(values, keyArr, value); | ||
formData.forEach(function (value, name) { | ||
set(values, name, value); | ||
}); | ||
onSubmit(values); | ||
}, [onSubmit]); | ||
var resValues = cloneDeep(values); | ||
Object.keys(fields) | ||
.reverse() | ||
.forEach(function (fieldKey) { | ||
var items = fields[fieldKey].items; | ||
if (Array.isArray(items)) { | ||
var value = items.map(function (index) { | ||
return cloneDeep(get(resValues, fieldKey))[index]; | ||
}); | ||
unset(resValues, fieldKey); | ||
set(resValues, fieldKey, value); | ||
} | ||
}); | ||
onSubmit(resValues); | ||
}, [fields, onSubmit]); | ||
return (React.createElement("form", { onSubmit: handleSubmit, ref: formRef }, | ||
@@ -88,0 +102,0 @@ React.createElement(FormContext.Provider, { value: { |
{ | ||
"name": "@altiore/form", | ||
"version": "0.3.19", | ||
"version": "0.3.20", | ||
"description": "Form helper for building powerful forms", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51671
1088