x-ui-design 0.6.48 → 0.6.50
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 +20 -34
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +20 -34
- package/dist/index.js.map +1 -1
- package/lib/components/Form/Form.tsx +2 -6
- package/lib/components/Select/Select.tsx +18 -20
- package/lib/hooks/useForm.ts +7 -6
- package/package.json +1 -1
- package/src/app/page.tsx +8 -11
package/dist/index.esm.js
CHANGED
|
@@ -619,9 +619,6 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
|
|
|
619
619
|
...initialValues
|
|
620
620
|
});
|
|
621
621
|
const fieldInstancesRef = useRef({});
|
|
622
|
-
const [formValues, setFormValues] = useState({
|
|
623
|
-
...initialValues
|
|
624
|
-
});
|
|
625
622
|
const [isReseting, setIsReseting] = useState(false);
|
|
626
623
|
const [errors, setErrors] = useState({});
|
|
627
624
|
const fieldSubscribers = useRef({});
|
|
@@ -633,14 +630,16 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
|
|
|
633
630
|
return name ? fieldInstancesRef.current[name] : fieldInstancesRef.current;
|
|
634
631
|
}
|
|
635
632
|
function getFieldValue(name) {
|
|
636
|
-
|
|
633
|
+
const formData = getFormFields();
|
|
634
|
+
return formData[name];
|
|
637
635
|
}
|
|
638
636
|
function getFieldsValue(nameList) {
|
|
637
|
+
const formData = getFormFields();
|
|
639
638
|
if (!nameList) {
|
|
640
|
-
return
|
|
639
|
+
return formData;
|
|
641
640
|
}
|
|
642
641
|
return nameList.reduce((acc, key) => {
|
|
643
|
-
acc[key] =
|
|
642
|
+
acc[key] = formData[key];
|
|
644
643
|
return acc;
|
|
645
644
|
}, {});
|
|
646
645
|
}
|
|
@@ -661,10 +660,6 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
|
|
|
661
660
|
return;
|
|
662
661
|
}
|
|
663
662
|
formRef.current[stepRef.current][name] = value;
|
|
664
|
-
setFormValues(prev => ({
|
|
665
|
-
...prev,
|
|
666
|
-
[name]: value
|
|
667
|
-
}));
|
|
668
663
|
if (touch) {
|
|
669
664
|
touchedFieldsRef.current.add(name);
|
|
670
665
|
}
|
|
@@ -1218,15 +1213,8 @@ const Form$1 = ({
|
|
|
1218
1213
|
const formInstance = useMemo(() => form || internalForm, [form, internalForm]);
|
|
1219
1214
|
const handleSubmit = async e => {
|
|
1220
1215
|
e.preventDefault();
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
} else if (onFinishFailed) {
|
|
1224
|
-
const errorFields = formInstance.getFieldsError().filter(e => e.errors.length);
|
|
1225
|
-
onFinishFailed({
|
|
1226
|
-
values: formInstance.getFieldsValue(),
|
|
1227
|
-
errorFields
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1216
|
+
e.stopPropagation();
|
|
1217
|
+
await formInstance.submit();
|
|
1230
1218
|
};
|
|
1231
1219
|
const childrenList = useMemo(() => flattenChildren(children), [children]);
|
|
1232
1220
|
useEffect(() => {
|
|
@@ -3689,21 +3677,19 @@ const SelectComponent = ({
|
|
|
3689
3677
|
const triggerNode = useMemo(() => {
|
|
3690
3678
|
return selectRef.current?.querySelector(`.${prefixCls}-trigger`);
|
|
3691
3679
|
}, [prefixCls]);
|
|
3692
|
-
const filteredOptions =
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
});
|
|
3706
|
-
}, [extractedOptions, filterOption, optionFilterProp, searchQuery]);
|
|
3680
|
+
const filteredOptions = extractedOptions.filter(option => {
|
|
3681
|
+
if (typeof filterOption === 'function') {
|
|
3682
|
+
return filterOption(searchQuery, option);
|
|
3683
|
+
}
|
|
3684
|
+
if (filterOption === false) {
|
|
3685
|
+
return true;
|
|
3686
|
+
}
|
|
3687
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3688
|
+
// @ts-expect-error
|
|
3689
|
+
const optionFilterPropValue = option[optionFilterProp];
|
|
3690
|
+
const valueToCheck = optionFilterProp && typeof optionFilterPropValue === 'string' ? String(optionFilterPropValue) : Array.isArray(option.children) && typeof option.children[0] === 'string' ? option.children[0] : getTextFromNode(option.children) || String(option.label) || String(option.value);
|
|
3691
|
+
return valueToCheck.toLowerCase().includes(searchQuery.toLowerCase());
|
|
3692
|
+
});
|
|
3707
3693
|
const handleTriggerClick = () => {
|
|
3708
3694
|
if (!disabled) {
|
|
3709
3695
|
setIsOpen(!isOpen);
|