x-ui-design 0.4.93 → 0.4.94
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 +3 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3 -10
- package/dist/index.js.map +1 -1
- package/lib/hooks/useForm.ts +3 -5
- package/package.json +1 -1
- package/src/app/page.tsx +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -598,13 +598,6 @@ const SpinerIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
|
598
598
|
d: "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
|
|
599
599
|
}));
|
|
600
600
|
|
|
601
|
-
function findFormItem(item) {
|
|
602
|
-
if (item?.parentElement?.tagName !== 'FORM') {
|
|
603
|
-
findFormItem(item?.parentElement);
|
|
604
|
-
} else {
|
|
605
|
-
return item;
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
601
|
const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFirstError, onFinish) => {
|
|
609
602
|
const touchedFieldsRef = useRef(new Set());
|
|
610
603
|
const rulesRef = useRef({});
|
|
@@ -774,10 +767,10 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
|
|
|
774
767
|
const results = await Promise.all(fieldsToValidate.map(name => validateField(name)));
|
|
775
768
|
if (_scrollToFirstError.current) {
|
|
776
769
|
const firstErrorContent = document.querySelectorAll('.xUi-form-item-has-error')?.[0];
|
|
777
|
-
console.log('firstErrorContent', firstErrorContent);
|
|
778
770
|
if (firstErrorContent) {
|
|
779
|
-
|
|
780
|
-
|
|
771
|
+
firstErrorContent.closest('.xUi-form-item')?.scrollIntoView({
|
|
772
|
+
behavior: 'smooth'
|
|
773
|
+
});
|
|
781
774
|
}
|
|
782
775
|
}
|
|
783
776
|
return results.every(valid => valid);
|