x-ui-design 0.3.77 → 0.3.79

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.esm.js CHANGED
@@ -607,7 +607,6 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
607
607
  ...initialValues
608
608
  });
609
609
  const fieldInstancesRef = useRef({});
610
- const [isSubmit, setIsSubmit] = useState(false);
611
610
  const [isReseting, setIsReseting] = useState(false);
612
611
  const [errors, setErrors] = useState({});
613
612
  const fieldSubscribers = useRef({});
@@ -739,19 +738,19 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
739
738
  [name]: fieldErrors
740
739
  }));
741
740
  warningsRef.current[name] = fieldWarnings;
742
- if (isSubmit || _scrollToFirstError.current) {
741
+ return fieldErrors.length === 0;
742
+ }
743
+ async function validateFields(nameList) {
744
+ const fieldsToValidate = nameList || Object.keys(formRef.current);
745
+ const results = await Promise.all(fieldsToValidate.map(name => validateField(name)));
746
+ console.log(_scrollToFirstError.current);
747
+ if (_scrollToFirstError.current) {
743
748
  const firstErrorContent = document.querySelectorAll('.xUi-form-item-error')?.[0];
744
749
  if (firstErrorContent) {
745
750
  firstErrorContent.closest('.xUi-form-item')?.closest('[data-item="first-content"]')?.scrollIntoView();
746
- setIsSubmit(false);
747
751
  setScrollToFirstError(false);
748
752
  }
749
753
  }
750
- return fieldErrors.length === 0;
751
- }
752
- async function validateFields(nameList) {
753
- const fieldsToValidate = nameList || Object.keys(formRef.current);
754
- const results = await Promise.all(fieldsToValidate.map(name => validateField(name)));
755
754
  return results.every(valid => valid);
756
755
  }
757
756
  function resetFields(nameList, showError = true) {
@@ -777,7 +776,7 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
777
776
  setIsReseting(prev => !prev);
778
777
  }
779
778
  async function submit() {
780
- setIsSubmit(true);
779
+ setScrollToFirstError(true);
781
780
  return (await validateFields()) ? formRef.current : undefined;
782
781
  }
783
782
  function subscribeToField(name, callback) {