@bombillazo/rhf-plus 7.67.0-plus.0 → 7.68.0-plus.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.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './controller';
2
2
  export * from './form';
3
+ export * from './formStateSubscribe';
3
4
  export * from './logic';
4
5
  export * from './types';
5
6
  export * from './useController';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -464,7 +464,7 @@ function useWatch(props) {
464
464
  */
465
465
  function useController(props) {
466
466
  const methods = useFormContext();
467
- const { name, disabled, control = methods === null || methods === void 0 ? void 0 : methods.control, shouldUnregister, defaultValue, } = props;
467
+ const { name, disabled, control = methods === null || methods === void 0 ? void 0 : methods.control, shouldUnregister, defaultValue, exact = true, } = props;
468
468
  if (!control) {
469
469
  throw new Error('useController: missing `control`. Pass `control` as a prop or provide it via FormProvider.');
470
470
  }
@@ -474,12 +474,12 @@ function useController(props) {
474
474
  control,
475
475
  name,
476
476
  defaultValue: defaultValueMemo,
477
- exact: true,
477
+ exact,
478
478
  });
479
479
  const formState = useFormState({
480
480
  control,
481
481
  name,
482
- exact: true,
482
+ exact,
483
483
  });
484
484
  const _props = React.useRef(props);
485
485
  const _previousRules = React.useRef(props.rules);
@@ -832,6 +832,8 @@ function Form(props) {
832
832
  }))) : (React.createElement("form", { noValidate: mounted, action: action, method: method, encType: encType, onSubmit: submit, ...rest }, children));
833
833
  }
834
834
 
835
+ const FormStateSubscribe = ({ control, disabled, exact, name, render, }) => render(useFormState({ control, name, disabled, exact }));
836
+
835
837
  var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
836
838
  ? {
837
839
  ...errors[name],
@@ -2599,6 +2601,13 @@ function createFormControl(props = {}) {
2599
2601
  !!keepStateOptions.keepDirtyValues ||
2600
2602
  (!_options.shouldUnregister && !isEmptyObject(values));
2601
2603
  _state.watch = !!_options.shouldUnregister;
2604
+ _state.action = false;
2605
+ // Clear errors synchronously to prevent validation errors on subsequent submissions
2606
+ // This fixes the issue where form.reset() causes validation errors on subsequent
2607
+ // submissions in Next.js 16 with Server Actions
2608
+ if (!keepStateOptions.keepErrors) {
2609
+ _formState.errors = {};
2610
+ }
2602
2611
  _subjects.state.next({
2603
2612
  submitCount: keepStateOptions.keepSubmitCount
2604
2613
  ? _formState.submitCount
@@ -3323,5 +3332,5 @@ function useForm(props = {}) {
3323
3332
  */
3324
3333
  const Watch = ({ control, names, render, }) => render(useWatch({ control, name: names }));
3325
3334
 
3326
- export { Controller, Form, FormProvider, Watch, appendErrors, createFormControl, get, set, submitForm as submit, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch };
3335
+ export { Controller, Form, FormProvider, FormStateSubscribe, Watch, appendErrors, createFormControl, get, set, submitForm as submit, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch };
3327
3336
  //# sourceMappingURL=index.esm.mjs.map