x-ui-design 0.6.59 → 0.6.62

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
@@ -624,22 +624,15 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
624
624
  const errorSubscribers = useRef({});
625
625
  const fieldSubscribers = useRef({});
626
626
  const formSubscribers = useRef([]);
627
- function getFormFields() {
628
- return Object.assign({}, ...Object.values(formRef.current));
629
- }
630
627
  function getFieldInstance(name) {
631
628
  return name ? fieldInstancesRef.current[name] : fieldInstancesRef.current;
632
629
  }
633
630
  function getFieldValue(name) {
634
- const formData = getFormFields();
631
+ const formData = formRef.current[stepRef.current];
635
632
  return formData[name];
636
633
  }
637
634
  function getFieldsValue(nameList) {
638
- const formData = getFormFields();
639
- console.info({
640
- stepRef: stepRef.current,
641
- formRef: formRef.current
642
- });
635
+ const formData = formRef.current[stepRef.current];
643
636
  if (!nameList) {
644
637
  return formData;
645
638
  }
@@ -664,7 +657,13 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
664
657
  if (!reset && reset !== null && ([undefined, null].includes(value) || formRef.current[stepRef.current][name] === value)) {
665
658
  return;
666
659
  }
667
- formRef.current[stepRef.current][name] = value;
660
+ if (reset === true) {
661
+ Object.entries(formRef.current).forEach(([key]) => {
662
+ formRef.current[+key][name] = value;
663
+ });
664
+ } else {
665
+ formRef.current[stepRef.current][name] = value;
666
+ }
668
667
  if (touch) {
669
668
  touchedFieldsRef.current.add(name);
670
669
  }
@@ -794,10 +793,11 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
794
793
  return results.every(valid => valid);
795
794
  }
796
795
  function resetFields(nameList, showError = true) {
797
- const formData = getFormFields();
796
+ const formData = Object.assign({}, ...Object.values(formRef.current));
798
797
  if (nameList?.length) {
799
798
  nameList.forEach(name => {
800
799
  formData[name] = initialValues[name];
800
+ trashFormRef.current[name] = initialValues[name];
801
801
  touchedFieldsRef.current.delete(name);
802
802
  delete warningsRef.current[name];
803
803
  errorsRef.current[name] = [];
@@ -817,9 +817,9 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
817
817
  setIsReseting(prev => !prev);
818
818
  }
819
819
  async function submit() {
820
- const formData = getFormFields();
820
+ const formData = Object.assign({}, ...Object.values(formRef.current));
821
821
  return (await validateFields()) ? (() => {
822
- formHandlersRef.current.onFinish?.(formData);
822
+ formHandlersRef.current.onFinish?.(Object.assign({}, ...Object.values(formRef.current)));
823
823
  return formData;
824
824
  })() : undefined;
825
825
  }
@@ -877,7 +877,6 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
877
877
  }
878
878
  function changeStep(step) {
879
879
  stepRef.current = step ?? 0;
880
- console.info('stepRef', stepRef.current);
881
880
  if (!formRef.current[stepRef.current]) {
882
881
  formRef.current[stepRef.current] = {};
883
882
  }