react-f0rm 0.6.1 → 0.7.0
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/README.md +14 -0
- package/dist/form-CGRvih_c.cjs.js.map +1 -1
- package/dist/form-CfBBPz6p.mjs.map +1 -1
- package/dist/{form-D9COEt0-.d.ts → form-DHKns6j_.d.ts} +41 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +18 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +2 -2
- package/dist/index.umd.min.js.map +1 -1
- package/dist/resolvers/yup.d.ts +1 -1
- package/dist/resolvers/zod.d.ts +1 -1
- package/dist/{validate-Cu43SqhV.d.ts → validate-BoNZhOMY.d.ts} +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -228,6 +228,7 @@
|
|
|
228
228
|
errors: /* @__PURE__ */ new Map(),
|
|
229
229
|
touched: /* @__PURE__ */ new Set(),
|
|
230
230
|
validators: /* @__PURE__ */ new Map(),
|
|
231
|
+
changeHandlers: /* @__PURE__ */ new Map(),
|
|
231
232
|
validating: /* @__PURE__ */ new Set(),
|
|
232
233
|
parsedValues: void 0,
|
|
233
234
|
isSubmitting: false,
|
|
@@ -267,6 +268,14 @@
|
|
|
267
268
|
if (options?.shouldValidate) form.validators.get(path.key)?.();
|
|
268
269
|
emit(emitter, "change", path);
|
|
269
270
|
}
|
|
271
|
+
function changeValue(form, name, value) {
|
|
272
|
+
changeValueByPath(form, create$1(name), value);
|
|
273
|
+
}
|
|
274
|
+
function changeValueByPath(form, path, value) {
|
|
275
|
+
const change = form.changeHandlers.get(path.key);
|
|
276
|
+
if (change) change(value);
|
|
277
|
+
else setValueByPath(form, path, value);
|
|
278
|
+
}
|
|
270
279
|
function getError(form, name) {
|
|
271
280
|
return getErrorByPath(form, create$1(name));
|
|
272
281
|
}
|
|
@@ -1315,6 +1324,13 @@
|
|
|
1315
1324
|
if (mode === "onChange" || mode === "all" || mode === "onTouched" && hasTouchedByPath(form, path) || liveErrors.length > 0 && form.reValidateMode === "onChange")
|
|
1316
1325
|
validator();
|
|
1317
1326
|
});
|
|
1327
|
+
React.useEffect(() => {
|
|
1328
|
+
form.changeHandlers.set(path.key, onChange);
|
|
1329
|
+
return () => {
|
|
1330
|
+
if (form.changeHandlers.get(path.key) === onChange)
|
|
1331
|
+
form.changeHandlers.delete(path.key);
|
|
1332
|
+
};
|
|
1333
|
+
}, [form, path.key, onChange]);
|
|
1318
1334
|
const onBlur = useStageFn(() => {
|
|
1319
1335
|
setTouchedByPath(form, path);
|
|
1320
1336
|
if (mode === "onBlur" || mode === "onTouched" || mode === "all" || liveErrors.length > 0 && form.reValidateMode === "onBlur")
|
|
@@ -1749,6 +1765,8 @@
|
|
|
1749
1765
|
exports.FormProvider = FormProvider;
|
|
1750
1766
|
exports.Select = Select;
|
|
1751
1767
|
exports.VALIDATION_OUTCOME = VALIDATION_OUTCOME;
|
|
1768
|
+
exports.changeValue = changeValue;
|
|
1769
|
+
exports.changeValueByPath = changeValueByPath;
|
|
1752
1770
|
exports.clearErrors = clearErrors;
|
|
1753
1771
|
exports.createForm = create;
|
|
1754
1772
|
exports.createFormContext = createFormContext;
|