@bombillazo/rhf-plus 7.72.0-plus.0 → 7.72.1-plus.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +62 -50
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/logic/createFormControl.d.ts.map +1 -1
- package/dist/logic/isNameInFieldArray.d.ts.map +1 -1
- package/dist/react-server.esm.mjs +19 -8
- package/dist/react-server.esm.mjs.map +1 -1
- package/dist/types/form.d.ts +1 -0
- package/dist/types/form.d.ts.map +1 -1
- package/dist/useFormContext.d.ts.map +1 -1
- package/package.json +20 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFormControl.d.ts","sourceRoot":"","sources":["../../src/logic/createFormControl.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAaV,WAAW,EACX,YAAY,EAiBZ,YAAY,EAIZ,aAAa,EAWd,MAAM,UAAU,CAAC;AA0DlB,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EACjC,SAAS,SAAS,YAAY,GAAG,GAAG,EAEpC,KAAK,GAAE,YAAY,CACjB,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,SAAS,CACL,GACL,IAAI,CACL,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,CAAC,EACpE,WAAW,CACZ,GAAG;IACF,WAAW,EAAE,IAAI,CACf,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,CAAC,EACpE,WAAW,CACZ,CAAC;CACH,
|
|
1
|
+
{"version":3,"file":"createFormControl.d.ts","sourceRoot":"","sources":["../../src/logic/createFormControl.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAaV,WAAW,EACX,YAAY,EAiBZ,YAAY,EAIZ,aAAa,EAWd,MAAM,UAAU,CAAC;AA0DlB,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EACjC,SAAS,SAAS,YAAY,GAAG,GAAG,EAEpC,KAAK,GAAE,YAAY,CACjB,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,SAAS,CACL,GACL,IAAI,CACL,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,CAAC,EACpE,WAAW,CACZ,GAAG;IACF,WAAW,EAAE,IAAI,CACf,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,CAAC,EACpE,WAAW,CACZ,CAAC;CACH,CAo7DA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isNameInFieldArray.d.ts","sourceRoot":"","sources":["../../src/logic/isNameInFieldArray.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"isNameInFieldArray.d.ts","sourceRoot":"","sources":["../../src/logic/isNameInFieldArray.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;yBAElC,OAAO,GAAG,CAAC,iBAAiB,CAAC,EAAE,MAAM,iBAAiB;AAAtE,wBAMM"}
|
|
@@ -147,8 +147,8 @@ function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
|
|
|
147
147
|
if (key !== 'ref') {
|
|
148
148
|
const val2 = object2[key];
|
|
149
149
|
if ((isDateObject(val1) && isDateObject(val2)) ||
|
|
150
|
-
(isObject(val1)
|
|
151
|
-
|
|
150
|
+
((isObject(val1) || Array.isArray(val1)) &&
|
|
151
|
+
(isObject(val2) || Array.isArray(val2)))
|
|
152
152
|
? !deepEqual(val1, val2, _internal_visited)
|
|
153
153
|
: !Object.is(val1, val2)) {
|
|
154
154
|
return false;
|
|
@@ -506,7 +506,9 @@ var hasValidation = (options) => options.mount &&
|
|
|
506
506
|
options.pattern ||
|
|
507
507
|
options.validate);
|
|
508
508
|
|
|
509
|
-
var isNameInFieldArray = (names, name) =>
|
|
509
|
+
var isNameInFieldArray = (names, name) => name
|
|
510
|
+
.split('.')
|
|
511
|
+
.some((part, index, arr) => !isNaN(Number(part)) && names.has(arr.slice(0, index).join('.')));
|
|
510
512
|
|
|
511
513
|
var isWatched = (name, _names, isBlurEvent) => !isBlurEvent &&
|
|
512
514
|
(_names.watchAll ||
|
|
@@ -896,6 +898,7 @@ function createFormControl(props = {}) {
|
|
|
896
898
|
unMount: new Set(),
|
|
897
899
|
array: new Set(),
|
|
898
900
|
watch: new Set(),
|
|
901
|
+
registerName: new Set(),
|
|
899
902
|
};
|
|
900
903
|
let delayErrorCallback;
|
|
901
904
|
let timer = 0;
|
|
@@ -975,6 +978,11 @@ function createFormControl(props = {}) {
|
|
|
975
978
|
});
|
|
976
979
|
}
|
|
977
980
|
};
|
|
981
|
+
const _updateDirtyFields = (name) => {
|
|
982
|
+
const fullDirtyFields = getDirtyFields(_defaultValues, _formValues);
|
|
983
|
+
const rootName = getNodeParentName(name);
|
|
984
|
+
set(_formState.dirtyFields, rootName, get(fullDirtyFields, rootName));
|
|
985
|
+
};
|
|
978
986
|
const _setFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
|
|
979
987
|
if (args && method && !_options.disabled) {
|
|
980
988
|
_state.action = true;
|
|
@@ -996,9 +1004,7 @@ function createFormControl(props = {}) {
|
|
|
996
1004
|
shouldSetValues && set(_formState.touchedFields, name, touchedFields);
|
|
997
1005
|
}
|
|
998
1006
|
if (_proxyFormState.dirtyFields || _proxySubscribeFormState.dirtyFields) {
|
|
999
|
-
|
|
1000
|
-
const rootName = getNodeParentName(name);
|
|
1001
|
-
set(_formState.dirtyFields, rootName, get(fullDirtyFields, rootName));
|
|
1007
|
+
_updateDirtyFields(name);
|
|
1002
1008
|
}
|
|
1003
1009
|
_subjects.state.next({
|
|
1004
1010
|
name,
|
|
@@ -1374,9 +1380,10 @@ function createFormControl(props = {}) {
|
|
|
1374
1380
|
_proxyFormState.isDirtySinceSubmit ||
|
|
1375
1381
|
_proxySubscribeFormState.isDirtySinceSubmit) &&
|
|
1376
1382
|
options.shouldDirty) {
|
|
1383
|
+
_updateDirtyFields(name);
|
|
1377
1384
|
_subjects.state.next({
|
|
1378
1385
|
name,
|
|
1379
|
-
dirtyFields:
|
|
1386
|
+
dirtyFields: _formState.dirtyFields,
|
|
1380
1387
|
isDirty: _getDirty(name, cloneValue),
|
|
1381
1388
|
...((_formState.isSubmitted || _hasBeenSubmitted) &&
|
|
1382
1389
|
!_formState.isDirtySinceSubmit
|
|
@@ -1770,6 +1777,7 @@ function createFormControl(props = {}) {
|
|
|
1770
1777
|
const disabledIsDefined = isBoolean(options.disabled) ||
|
|
1771
1778
|
isBoolean(_options.disabled) ||
|
|
1772
1779
|
Array.isArray(_options.disabled);
|
|
1780
|
+
const shouldRevalidateRemount = !_names.registerName.has(name) && field && !field._f.mount;
|
|
1773
1781
|
set(_fields, name, {
|
|
1774
1782
|
...(field || {}),
|
|
1775
1783
|
_f: {
|
|
@@ -1780,7 +1788,7 @@ function createFormControl(props = {}) {
|
|
|
1780
1788
|
},
|
|
1781
1789
|
});
|
|
1782
1790
|
_names.mount.add(name);
|
|
1783
|
-
if (field) {
|
|
1791
|
+
if (field && !shouldRevalidateRemount) {
|
|
1784
1792
|
_setDisabledField({
|
|
1785
1793
|
disabled: isBoolean(options.disabled)
|
|
1786
1794
|
? options.disabled
|
|
@@ -1819,7 +1827,9 @@ function createFormControl(props = {}) {
|
|
|
1819
1827
|
onFocus: onChange,
|
|
1820
1828
|
ref: (ref) => {
|
|
1821
1829
|
if (ref) {
|
|
1830
|
+
_names.registerName.add(name);
|
|
1822
1831
|
register(name, options);
|
|
1832
|
+
_names.registerName.delete(name);
|
|
1823
1833
|
field = get(_fields, name);
|
|
1824
1834
|
const fieldRef = isUndefined(ref.value)
|
|
1825
1835
|
? ref.querySelectorAll
|
|
@@ -2065,6 +2075,7 @@ function createFormControl(props = {}) {
|
|
|
2065
2075
|
mount: keepStateOptions.keepDirtyValues ? _names.mount : new Set(),
|
|
2066
2076
|
unMount: new Set(),
|
|
2067
2077
|
array: new Set(),
|
|
2078
|
+
registerName: new Set(),
|
|
2068
2079
|
disabled: new Set(),
|
|
2069
2080
|
readonly: new Set(),
|
|
2070
2081
|
watch: new Set(),
|