react-f0rm 0.5.0 → 0.6.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/dist/index.umd.js CHANGED
@@ -111,7 +111,7 @@
111
111
  const [prop, ...props] = path;
112
112
  if (props.length) {
113
113
  const next = unset(values[prop], props);
114
- return next === values[prop] ? values : set(values, path, next);
114
+ return next === values[prop] ? values : set(values, [prop], next);
115
115
  }
116
116
  if (Array.isArray(values)) {
117
117
  if (!(prop in values)) return values;
@@ -1282,7 +1282,8 @@
1282
1282
  rules,
1283
1283
  validateDebounce,
1284
1284
  delayError,
1285
- disabled
1285
+ disabled,
1286
+ mode: modeOption
1286
1287
  }, Context) {
1287
1288
  const contextForm = React.useContext(Context);
1288
1289
  const form = f1 || contextForm;
@@ -1302,6 +1303,7 @@
1302
1303
  const error = errorObject?.message;
1303
1304
  const value = useValueByPath(form, path);
1304
1305
  const formDisabled = useWatch(form.emitter, "disabled", () => form.disabled);
1306
+ const mode = modeOption ?? form.mode;
1305
1307
  React.useEffect(() => {
1306
1308
  if (initialValue === void 0) return;
1307
1309
  if (getValueByPath(form, path) === void 0) {
@@ -1310,12 +1312,12 @@
1310
1312
  }, [form, path, initialValue]);
1311
1313
  const onChange = useStageFn((v) => {
1312
1314
  setValueByPath(form, path, v);
1313
- if (form.mode === "onChange" || form.mode === "all" || form.mode === "onTouched" && hasTouchedByPath(form, path) || liveErrors.length > 0 && form.reValidateMode === "onChange")
1315
+ if (mode === "onChange" || mode === "all" || mode === "onTouched" && hasTouchedByPath(form, path) || liveErrors.length > 0 && form.reValidateMode === "onChange")
1314
1316
  validator();
1315
1317
  });
1316
1318
  const onBlur = useStageFn(() => {
1317
1319
  setTouchedByPath(form, path);
1318
- if (form.mode === "onBlur" || form.mode === "onTouched" || form.mode === "all" || liveErrors.length > 0 && form.reValidateMode === "onBlur")
1320
+ if (mode === "onBlur" || mode === "onTouched" || mode === "all" || liveErrors.length > 0 && form.reValidateMode === "onBlur")
1319
1321
  validator();
1320
1322
  });
1321
1323
  React.useEffect(
@@ -1534,6 +1536,7 @@
1534
1536
  validateDebounce,
1535
1537
  disabled,
1536
1538
  delayError,
1539
+ mode,
1537
1540
  ...props
1538
1541
  }, ref) => {
1539
1542
  const innerRef = React__namespace.useRef(null);
@@ -1562,6 +1565,7 @@
1562
1565
  validateDebounce,
1563
1566
  delayError,
1564
1567
  disabled,
1568
+ mode,
1565
1569
  validate: (...params) => {
1566
1570
  const el = innerRef.current;
1567
1571
  if (el && typeof el.checkValidity === "function") {
@@ -1635,6 +1639,7 @@
1635
1639
  validateDebounce,
1636
1640
  disabled,
1637
1641
  delayError,
1642
+ mode,
1638
1643
  ...props
1639
1644
  }, ref) => {
1640
1645
  const {
@@ -1653,7 +1658,8 @@
1653
1658
  rules,
1654
1659
  validateDebounce,
1655
1660
  delayError,
1656
- disabled
1661
+ disabled,
1662
+ mode
1657
1663
  });
1658
1664
  return /* @__PURE__ */ React__namespace.createElement(
1659
1665
  "input",
@@ -1689,6 +1695,7 @@
1689
1695
  validateDebounce,
1690
1696
  disabled,
1691
1697
  delayError,
1698
+ mode,
1692
1699
  ...props
1693
1700
  }, ref) => {
1694
1701
  const {
@@ -1707,7 +1714,8 @@
1707
1714
  rules,
1708
1715
  validateDebounce,
1709
1716
  delayError,
1710
- disabled
1717
+ disabled,
1718
+ mode
1711
1719
  });
1712
1720
  return /* @__PURE__ */ React__namespace.createElement(
1713
1721
  "select",