@underverse-ui/underverse 0.2.18 → 0.2.20

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.js CHANGED
@@ -2251,29 +2251,28 @@ var useToast = () => {
2251
2251
  }
2252
2252
  return context;
2253
2253
  };
2254
- var ToastProvider = ({
2255
- children,
2256
- position = "top-right",
2257
- maxToasts = 5
2258
- }) => {
2254
+ var ToastProvider = ({ children, position = "top-right", maxToasts = 5 }) => {
2259
2255
  const [toasts, setToasts] = useState8([]);
2260
2256
  const idRef = useRef2(0);
2261
2257
  const removeToast = useCallback2((id) => {
2262
2258
  setToasts((prev) => prev.filter((toast) => toast.id !== id));
2263
2259
  }, []);
2264
- const addToast = useCallback2((toast) => {
2265
- const id = `toast-${++idRef.current}`;
2266
- const newToast = { ...toast, id };
2267
- setToasts((prev) => {
2268
- const updated = [newToast, ...prev];
2269
- return updated.slice(0, maxToasts);
2270
- });
2271
- if (toast.duration !== 0) {
2272
- setTimeout(() => {
2273
- removeToast(id);
2274
- }, toast.duration || 5e3);
2275
- }
2276
- }, [maxToasts, removeToast]);
2260
+ const addToast = useCallback2(
2261
+ (toast) => {
2262
+ const id = `toast-${++idRef.current}`;
2263
+ const newToast = { ...toast, id };
2264
+ setToasts((prev) => {
2265
+ const updated = [newToast, ...prev];
2266
+ return updated.slice(0, maxToasts);
2267
+ });
2268
+ if (toast.duration !== 0) {
2269
+ setTimeout(() => {
2270
+ removeToast(id);
2271
+ }, toast.duration || 5e3);
2272
+ }
2273
+ },
2274
+ [maxToasts, removeToast]
2275
+ );
2277
2276
  const positionClasses = {
2278
2277
  "top-right": "top-4 right-4",
2279
2278
  "top-left": "top-4 left-4",
@@ -2284,7 +2283,7 @@ var ToastProvider = ({
2284
2283
  };
2285
2284
  return /* @__PURE__ */ jsxs12(ToastContext.Provider, { value: { addToast, removeToast, toasts }, children: [
2286
2285
  children,
2287
- /* @__PURE__ */ jsx14("div", { className: cn("fixed z-50 flex flex-col gap-2 pointer-events-none", positionClasses[position]), "aria-live": "polite", "aria-atomic": true, children: toasts.map((toast) => /* @__PURE__ */ jsx14(ToastComponent, { toast, onRemove: removeToast }, toast.id)) })
2286
+ /* @__PURE__ */ jsx14("div", { className: cn("fixed z-[99999] flex flex-col gap-2 pointer-events-none", positionClasses[position]), "aria-live": "polite", "aria-atomic": true, children: toasts.map((toast) => /* @__PURE__ */ jsx14(ToastComponent, { toast, onRemove: removeToast }, toast.id)) })
2288
2287
  ] });
2289
2288
  };
2290
2289
  var ToastComponent = ({ toast, onRemove }) => {
@@ -3725,36 +3724,34 @@ var DropdownMenu = ({
3725
3724
  if (open && triggerRef.current && contentRef.current) {
3726
3725
  const rect = triggerRef.current.getBoundingClientRect();
3727
3726
  const menuRect = contentRef.current.getBoundingClientRect();
3728
- const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
3729
- const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
3730
3727
  const viewportHeight = window.innerHeight;
3731
- let top = rect.bottom + scrollTop + 4;
3732
- let left = rect.left + scrollLeft;
3728
+ let top = rect.bottom + 4;
3729
+ let left = rect.left;
3733
3730
  if (rect.bottom + menuRect.height > viewportHeight && rect.top > menuRect.height) {
3734
- top = rect.top + scrollTop - menuRect.height - 4;
3731
+ top = rect.top - menuRect.height - 4;
3735
3732
  }
3736
3733
  switch (placement) {
3737
3734
  case "top":
3738
3735
  case "top-start":
3739
- top = rect.top + scrollTop - menuRect.height - 4;
3736
+ top = rect.top - menuRect.height - 4;
3740
3737
  break;
3741
3738
  case "top-end":
3742
- top = rect.top + scrollTop - menuRect.height - 4;
3743
- left = rect.right + scrollLeft - menuRect.width;
3739
+ top = rect.top - menuRect.height - 4;
3740
+ left = rect.right - menuRect.width;
3744
3741
  break;
3745
3742
  case "bottom":
3746
3743
  case "bottom-start":
3747
3744
  break;
3748
3745
  case "bottom-end":
3749
- left = rect.right + scrollLeft - menuRect.width;
3746
+ left = rect.right - menuRect.width;
3750
3747
  break;
3751
3748
  case "left":
3752
- top = rect.top + scrollTop;
3753
- left = rect.left + scrollLeft - menuRect.width - 4;
3749
+ top = rect.top;
3750
+ left = rect.left - menuRect.width - 4;
3754
3751
  break;
3755
3752
  case "right":
3756
- top = rect.top + scrollTop;
3757
- left = rect.right + scrollLeft + 4;
3753
+ top = rect.top;
3754
+ left = rect.right + 4;
3758
3755
  break;
3759
3756
  }
3760
3757
  setPosition({ top, left });
@@ -3828,7 +3825,7 @@ var DropdownMenu = ({
3828
3825
  "data-combobox-dropdown": true,
3829
3826
  ref: contentRef,
3830
3827
  style: {
3831
- position: "absolute",
3828
+ position: "fixed",
3832
3829
  top: position?.top ?? -9999,
3833
3830
  left: position?.left ?? -9999,
3834
3831
  zIndex: 9999,
@@ -10315,25 +10312,23 @@ var isPlainObject = (tempObject) => {
10315
10312
  };
10316
10313
  var isWeb = typeof window !== "undefined" && typeof window.HTMLElement !== "undefined" && typeof document !== "undefined";
10317
10314
  function cloneObject(data) {
10318
- let copy;
10319
- const isArray = Array.isArray(data);
10320
- const isFileListInstance = typeof FileList !== "undefined" ? data instanceof FileList : false;
10321
10315
  if (data instanceof Date) {
10322
- copy = new Date(data);
10323
- } else if (!(isWeb && (data instanceof Blob || isFileListInstance)) && (isArray || isObject(data))) {
10324
- copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
10325
- if (!isArray && !isPlainObject(data)) {
10326
- copy = data;
10327
- } else {
10328
- for (const key in data) {
10329
- if (data.hasOwnProperty(key)) {
10330
- copy[key] = cloneObject(data[key]);
10331
- }
10332
- }
10333
- }
10334
- } else {
10316
+ return new Date(data);
10317
+ }
10318
+ const isFileListInstance = typeof FileList !== "undefined" && data instanceof FileList;
10319
+ if (isWeb && (data instanceof Blob || isFileListInstance)) {
10335
10320
  return data;
10336
10321
  }
10322
+ const isArray = Array.isArray(data);
10323
+ if (!isArray && !(isObject(data) && isPlainObject(data))) {
10324
+ return data;
10325
+ }
10326
+ const copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
10327
+ for (const key in data) {
10328
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
10329
+ copy[key] = cloneObject(data[key]);
10330
+ }
10331
+ }
10337
10332
  return copy;
10338
10333
  }
10339
10334
  var isKey = (value) => /^\w*$/.test(value);
@@ -10348,6 +10343,7 @@ var get = (object, path, defaultValue) => {
10348
10343
  return isUndefined(result) || result === object ? isUndefined(object[path]) ? defaultValue : object[path] : result;
10349
10344
  };
10350
10345
  var isBoolean = (value) => typeof value === "boolean";
10346
+ var isFunction = (value) => typeof value === "function";
10351
10347
  var set = (object, path, value) => {
10352
10348
  let index = -1;
10353
10349
  const tempPath = isKey(path) ? [path] : stringToPath(path);
@@ -10459,7 +10455,7 @@ var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) =>
10459
10455
  var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
10460
10456
  function deepEqual(object1, object2, _internal_visited = /* @__PURE__ */ new WeakSet()) {
10461
10457
  if (isPrimitive(object1) || isPrimitive(object2)) {
10462
- return object1 === object2;
10458
+ return Object.is(object1, object2);
10463
10459
  }
10464
10460
  if (isDateObject(object1) && isDateObject(object2)) {
10465
10461
  return object1.getTime() === object2.getTime();
@@ -10481,7 +10477,7 @@ function deepEqual(object1, object2, _internal_visited = /* @__PURE__ */ new Wea
10481
10477
  }
10482
10478
  if (key !== "ref") {
10483
10479
  const val2 = object2[key];
10484
- if (isDateObject(val1) && isDateObject(val2) || isObject(val1) && isObject(val2) || Array.isArray(val1) && Array.isArray(val2) ? !deepEqual(val1, val2, _internal_visited) : val1 !== val2) {
10480
+ if (isDateObject(val1) && isDateObject(val2) || isObject(val1) && isObject(val2) || Array.isArray(val1) && Array.isArray(val2) ? !deepEqual(val1, val2, _internal_visited) : !Object.is(val1, val2)) {
10485
10481
  return false;
10486
10482
  }
10487
10483
  }
@@ -10494,48 +10490,76 @@ function useWatch(props) {
10494
10490
  const _defaultValue = React38.useRef(defaultValue);
10495
10491
  const _compute = React38.useRef(compute);
10496
10492
  const _computeFormValues = React38.useRef(void 0);
10493
+ const _prevControl = React38.useRef(control);
10494
+ const _prevName = React38.useRef(name);
10497
10495
  _compute.current = compute;
10498
- const defaultValueMemo = React38.useMemo(() => control._getWatch(name, _defaultValue.current), [control, name]);
10499
- const [value, updateValue] = React38.useState(_compute.current ? _compute.current(defaultValueMemo) : defaultValueMemo);
10500
- useIsomorphicLayoutEffect(() => control._subscribe({
10501
- name,
10502
- formState: {
10503
- values: true
10504
- },
10505
- exact,
10506
- callback: (formState) => {
10507
- if (!disabled) {
10508
- const formValues = generateWatchOutput(name, control._names, formState.values || control._formValues, false, _defaultValue.current);
10509
- if (_compute.current) {
10510
- const computedFormValues = _compute.current(formValues);
10511
- if (!deepEqual(computedFormValues, _computeFormValues.current)) {
10512
- updateValue(computedFormValues);
10513
- _computeFormValues.current = computedFormValues;
10514
- }
10515
- } else {
10516
- updateValue(formValues);
10496
+ const [value, updateValue] = React38.useState(() => {
10497
+ const defaultValue2 = control._getWatch(name, _defaultValue.current);
10498
+ return _compute.current ? _compute.current(defaultValue2) : defaultValue2;
10499
+ });
10500
+ const getCurrentOutput = React38.useCallback((values) => {
10501
+ const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
10502
+ return _compute.current ? _compute.current(formValues) : formValues;
10503
+ }, [control._formValues, control._names, name]);
10504
+ const refreshValue = React38.useCallback((values) => {
10505
+ if (!disabled) {
10506
+ const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
10507
+ if (_compute.current) {
10508
+ const computedFormValues = _compute.current(formValues);
10509
+ if (!deepEqual(computedFormValues, _computeFormValues.current)) {
10510
+ updateValue(computedFormValues);
10511
+ _computeFormValues.current = computedFormValues;
10517
10512
  }
10513
+ } else {
10514
+ updateValue(formValues);
10518
10515
  }
10519
10516
  }
10520
- }), [control, disabled, name, exact]);
10517
+ }, [control._formValues, control._names, disabled, name]);
10518
+ useIsomorphicLayoutEffect(() => {
10519
+ if (_prevControl.current !== control || !deepEqual(_prevName.current, name)) {
10520
+ _prevControl.current = control;
10521
+ _prevName.current = name;
10522
+ refreshValue();
10523
+ }
10524
+ return control._subscribe({
10525
+ name,
10526
+ formState: {
10527
+ values: true
10528
+ },
10529
+ exact,
10530
+ callback: (formState) => {
10531
+ refreshValue(formState.values);
10532
+ }
10533
+ });
10534
+ }, [control, exact, name, refreshValue]);
10521
10535
  React38.useEffect(() => control._removeUnmounted());
10522
- return value;
10536
+ const controlChanged = _prevControl.current !== control;
10537
+ const prevName = _prevName.current;
10538
+ const computedOutput = React38.useMemo(() => {
10539
+ if (disabled) {
10540
+ return null;
10541
+ }
10542
+ const nameChanged = !controlChanged && !deepEqual(prevName, name);
10543
+ const shouldReturnImmediate = controlChanged || nameChanged;
10544
+ return shouldReturnImmediate ? getCurrentOutput() : null;
10545
+ }, [disabled, controlChanged, name, prevName, getCurrentOutput]);
10546
+ return computedOutput !== null ? computedOutput : value;
10523
10547
  }
10524
10548
  function useController(props) {
10525
10549
  const methods = useFormContext();
10526
- const { name, disabled, control = methods.control, shouldUnregister, defaultValue } = props;
10550
+ const { name, disabled, control = methods.control, shouldUnregister, defaultValue, exact = true } = props;
10527
10551
  const isArrayField = isNameInFieldArray(control._names.array, name);
10528
10552
  const defaultValueMemo = React38.useMemo(() => get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [control, name, defaultValue]);
10529
10553
  const value = useWatch({
10530
10554
  control,
10531
10555
  name,
10532
10556
  defaultValue: defaultValueMemo,
10533
- exact: true
10557
+ exact
10534
10558
  });
10535
10559
  const formState = useFormState({
10536
10560
  control,
10537
10561
  name,
10538
- exact: true
10562
+ exact
10539
10563
  });
10540
10564
  const _props = React38.useRef(props);
10541
10565
  const _previousNameRef = React38.useRef(void 0);
@@ -10583,12 +10607,12 @@ function useController(props) {
10583
10607
  }), [name, control._formValues]);
10584
10608
  const ref = React38.useCallback((elm) => {
10585
10609
  const field2 = get(control._fields, name);
10586
- if (field2 && elm) {
10610
+ if (field2 && field2._f && elm) {
10587
10611
  field2._f.ref = {
10588
- focus: () => elm.focus && elm.focus(),
10589
- select: () => elm.select && elm.select(),
10590
- setCustomValidity: (message) => elm.setCustomValidity(message),
10591
- reportValidity: () => elm.reportValidity()
10612
+ focus: () => isFunction(elm.focus) && elm.focus(),
10613
+ select: () => isFunction(elm.select) && elm.select(),
10614
+ setCustomValidity: (message) => isFunction(elm.setCustomValidity) && elm.setCustomValidity(message),
10615
+ reportValidity: () => isFunction(elm.reportValidity) && elm.reportValidity()
10592
10616
  };
10593
10617
  }
10594
10618
  }, [control._fields, name]);
@@ -10698,7 +10722,6 @@ function extractFormValues(fieldsState, formValues) {
10698
10722
  }
10699
10723
  var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
10700
10724
  var isFileInput = (element) => element.type === "file";
10701
- var isFunction = (value) => typeof value === "function";
10702
10725
  var isHTMLElement = (value) => {
10703
10726
  if (!isWeb) {
10704
10727
  return false;
@@ -10752,10 +10775,11 @@ function isTraversable(value) {
10752
10775
  }
10753
10776
  function markFieldsDirty(data, fields = {}) {
10754
10777
  for (const key in data) {
10755
- if (isTraversable(data[key])) {
10756
- fields[key] = Array.isArray(data[key]) ? [] : {};
10757
- markFieldsDirty(data[key], fields[key]);
10758
- } else if (!isUndefined(data[key])) {
10778
+ const value = data[key];
10779
+ if (isTraversable(value)) {
10780
+ fields[key] = Array.isArray(value) ? [] : {};
10781
+ markFieldsDirty(value, fields[key]);
10782
+ } else if (!isUndefined(value)) {
10759
10783
  fields[key] = true;
10760
10784
  }
10761
10785
  }
@@ -10766,14 +10790,16 @@ function getDirtyFields(data, formValues, dirtyFieldsFromValues) {
10766
10790
  dirtyFieldsFromValues = markFieldsDirty(formValues);
10767
10791
  }
10768
10792
  for (const key in data) {
10769
- if (isTraversable(data[key])) {
10793
+ const value = data[key];
10794
+ if (isTraversable(value)) {
10770
10795
  if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) {
10771
- dirtyFieldsFromValues[key] = markFieldsDirty(data[key], Array.isArray(data[key]) ? [] : {});
10796
+ dirtyFieldsFromValues[key] = markFieldsDirty(value, Array.isArray(value) ? [] : {});
10772
10797
  } else {
10773
- getDirtyFields(data[key], isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
10798
+ getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
10774
10799
  }
10775
10800
  } else {
10776
- dirtyFieldsFromValues[key] = !deepEqual(data[key], formValues[key]);
10801
+ const formValue = formValues[key];
10802
+ dirtyFieldsFromValues[key] = !deepEqual(value, formValue);
10777
10803
  }
10778
10804
  }
10779
10805
  return dirtyFieldsFromValues;
@@ -11125,7 +11151,8 @@ function createFormControl(props = {}) {
11125
11151
  let _state = {
11126
11152
  action: false,
11127
11153
  mount: false,
11128
- watch: false
11154
+ watch: false,
11155
+ keepIsValid: false
11129
11156
  };
11130
11157
  let _names = {
11131
11158
  mount: /* @__PURE__ */ new Set(),
@@ -11136,7 +11163,7 @@ function createFormControl(props = {}) {
11136
11163
  };
11137
11164
  let delayErrorCallback;
11138
11165
  let timer = 0;
11139
- const _proxyFormState = {
11166
+ const defaultProxyFormState = {
11140
11167
  isDirty: false,
11141
11168
  dirtyFields: false,
11142
11169
  validatingFields: false,
@@ -11145,6 +11172,9 @@ function createFormControl(props = {}) {
11145
11172
  isValid: false,
11146
11173
  errors: false
11147
11174
  };
11175
+ const _proxyFormState = {
11176
+ ...defaultProxyFormState
11177
+ };
11148
11178
  let _proxySubscribeFormState = {
11149
11179
  ..._proxyFormState
11150
11180
  };
@@ -11158,8 +11188,17 @@ function createFormControl(props = {}) {
11158
11188
  timer = setTimeout(callback, wait);
11159
11189
  };
11160
11190
  const _setValid = async (shouldUpdateValid) => {
11191
+ if (_state.keepIsValid) {
11192
+ return;
11193
+ }
11161
11194
  if (!_options.disabled && (_proxyFormState.isValid || _proxySubscribeFormState.isValid || shouldUpdateValid)) {
11162
- const isValid = _options.resolver ? isEmptyObject((await _runSchema()).errors) : await executeBuiltInValidation(_fields, true);
11195
+ let isValid;
11196
+ if (_options.resolver) {
11197
+ isValid = isEmptyObject((await _runSchema()).errors);
11198
+ _updateIsValidating();
11199
+ } else {
11200
+ isValid = await executeBuiltInValidation(_fields, true);
11201
+ }
11163
11202
  if (isValid !== _formState.isValid) {
11164
11203
  _subjects.state.next({
11165
11204
  isValid
@@ -11228,7 +11267,7 @@ function createFormControl(props = {}) {
11228
11267
  if (field) {
11229
11268
  const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);
11230
11269
  isUndefined(defaultValue) || ref && ref.defaultChecked || shouldSkipSetValueAs ? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f)) : setFieldValue(name, defaultValue);
11231
- _state.mount && _setValid();
11270
+ _state.mount && !_state.action && _setValid();
11232
11271
  }
11233
11272
  };
11234
11273
  const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {
@@ -11290,11 +11329,11 @@ function createFormControl(props = {}) {
11290
11329
  const _runSchema = async (name) => {
11291
11330
  _updateIsValidating(name, true);
11292
11331
  const result = await _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
11293
- _updateIsValidating(name);
11294
11332
  return result;
11295
11333
  };
11296
11334
  const executeSchemaAndUpdateState = async (names) => {
11297
11335
  const { errors } = await _runSchema(names);
11336
+ _updateIsValidating(names);
11298
11337
  if (names) {
11299
11338
  for (const name of names) {
11300
11339
  const error = get(errors, name);
@@ -11473,6 +11512,7 @@ function createFormControl(props = {}) {
11473
11512
  !isBlurEvent && watched && _subjects.state.next({ ..._formState });
11474
11513
  if (_options.resolver) {
11475
11514
  const { errors } = await _runSchema([name]);
11515
+ _updateIsValidating([name]);
11476
11516
  _updateIsFieldValueUpdated(fieldValue);
11477
11517
  if (isFieldValueUpdated) {
11478
11518
  const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
@@ -11593,7 +11633,10 @@ function createFormControl(props = {}) {
11593
11633
  };
11594
11634
  return _subscribe({
11595
11635
  ...props2,
11596
- formState: _proxySubscribeFormState
11636
+ formState: {
11637
+ ...defaultProxyFormState,
11638
+ ...props2.formState
11639
+ }
11597
11640
  });
11598
11641
  };
11599
11642
  const unregister = (name, options = {}) => {
@@ -11721,6 +11764,7 @@ function createFormControl(props = {}) {
11721
11764
  });
11722
11765
  if (_options.resolver) {
11723
11766
  const { errors, values } = await _runSchema();
11767
+ _updateIsValidating();
11724
11768
  _formState.errors = errors;
11725
11769
  fieldValues = cloneObject(values);
11726
11770
  } else {
@@ -11839,8 +11883,13 @@ function createFormControl(props = {}) {
11839
11883
  watchAll: false,
11840
11884
  focus: ""
11841
11885
  };
11842
- _state.mount = !_proxyFormState.isValid || !!keepStateOptions.keepIsValid || !!keepStateOptions.keepDirtyValues;
11886
+ _state.mount = !_proxyFormState.isValid || !!keepStateOptions.keepIsValid || !!keepStateOptions.keepDirtyValues || !_options.shouldUnregister && !isEmptyObject(values);
11843
11887
  _state.watch = !!_options.shouldUnregister;
11888
+ _state.keepIsValid = !!keepStateOptions.keepIsValid;
11889
+ _state.action = false;
11890
+ if (!keepStateOptions.keepErrors) {
11891
+ _formState.errors = {};
11892
+ }
11844
11893
  _subjects.state.next({
11845
11894
  submitCount: keepStateOptions.keepSubmitCount ? _formState.submitCount : 0,
11846
11895
  isDirty: isEmptyResetValues ? false : keepStateOptions.keepDirty ? _formState.isDirty : !!(keepStateOptions.keepDefaultValues && !deepEqual(formValues, _defaultValues)),
@@ -11853,15 +11902,17 @@ function createFormControl(props = {}) {
11853
11902
  defaultValues: _defaultValues
11854
11903
  });
11855
11904
  };
11856
- const reset = (formValues, keepStateOptions) => _reset(isFunction(formValues) ? formValues(_formValues) : formValues, keepStateOptions);
11905
+ const reset = (formValues, keepStateOptions) => _reset(isFunction(formValues) ? formValues(_formValues) : formValues, { ..._options.resetOptions, ...keepStateOptions });
11857
11906
  const setFocus = (name, options = {}) => {
11858
11907
  const field = get(_fields, name);
11859
11908
  const fieldReference = field && field._f;
11860
11909
  if (fieldReference) {
11861
11910
  const fieldRef = fieldReference.refs ? fieldReference.refs[0] : fieldReference.ref;
11862
11911
  if (fieldRef.focus) {
11863
- fieldRef.focus();
11864
- options.shouldSelect && isFunction(fieldRef.select) && fieldRef.select();
11912
+ setTimeout(() => {
11913
+ fieldRef.focus();
11914
+ options.shouldSelect && isFunction(fieldRef.select) && fieldRef.select();
11915
+ });
11865
11916
  }
11866
11917
  }
11867
11918
  };
@@ -11886,6 +11937,7 @@ function createFormControl(props = {}) {
11886
11937
  setError,
11887
11938
  _subscribe,
11888
11939
  _runSchema,
11940
+ _updateIsValidating,
11889
11941
  _focusError,
11890
11942
  _getWatch,
11891
11943
  _getDirty,
@@ -12037,11 +12089,15 @@ function useForm(props = {}) {
12037
12089
  }
12038
12090
  }, [control, formState.isDirty]);
12039
12091
  React38.useEffect(() => {
12092
+ var _a;
12040
12093
  if (props.values && !deepEqual(props.values, _values.current)) {
12041
12094
  control._reset(props.values, {
12042
12095
  keepFieldsRef: true,
12043
12096
  ...control._options.resetOptions
12044
12097
  });
12098
+ if (!((_a = control._options.resetOptions) === null || _a === void 0 ? void 0 : _a.keepIsValid)) {
12099
+ control._setValid();
12100
+ }
12045
12101
  _values.current = props.values;
12046
12102
  updateFormState((state) => ({ ...state }));
12047
12103
  } else {