x-ui-design 0.4.76 → 0.4.78
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/esm/types/types/form.d.ts +2 -2
- package/dist/index.esm.js +6 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +6 -17
- package/dist/index.js.map +1 -1
- package/lib/components/Form/Item/Item.tsx +5 -18
- package/lib/hooks/useForm.ts +5 -1
- package/lib/types/form.ts +2 -2
- package/package.json +1 -1
- package/src/app/page.tsx +2 -0
package/dist/index.js
CHANGED
|
@@ -716,6 +716,9 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
|
|
|
716
716
|
if (remove) {
|
|
717
717
|
delete formRef.current[stepRef.current]?.[name];
|
|
718
718
|
delete rulesRef.current[name];
|
|
719
|
+
if (fieldInstancesRef.current[name]) {
|
|
720
|
+
delete fieldInstancesRef.current[name];
|
|
721
|
+
}
|
|
719
722
|
} else {
|
|
720
723
|
if (!(name in formRef.current[stepRef.current])) {
|
|
721
724
|
formRef.current[stepRef.current][name] = initialValues?.[name];
|
|
@@ -1008,7 +1011,7 @@ const FormItem$1 = ({
|
|
|
1008
1011
|
const childrenList = React.useMemo(() => flattenChildren(children), [children]);
|
|
1009
1012
|
React.useEffect(() => {
|
|
1010
1013
|
if (name && !getFieldInstance(name)) {
|
|
1011
|
-
registerField(name, rules, false, fieldRef.current
|
|
1014
|
+
registerField(name, rules, false, fieldRef.current);
|
|
1012
1015
|
}
|
|
1013
1016
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1014
1017
|
}, [name, rules, fieldRef.current]);
|
|
@@ -1033,19 +1036,9 @@ const FormItem$1 = ({
|
|
|
1033
1036
|
}, [dependencies, name]);
|
|
1034
1037
|
const isRequired = React.useMemo(() => rules.some(rule => rule.required), [rules]);
|
|
1035
1038
|
const errorMessage = getFieldError(name)?.[0];
|
|
1036
|
-
const mergeRefs = elementRef => {
|
|
1037
|
-
return el => {
|
|
1038
|
-
fieldRef.current = el;
|
|
1039
|
-
if (typeof elementRef === 'function') {
|
|
1040
|
-
elementRef(el);
|
|
1041
|
-
} else if (elementRef && typeof elementRef === 'object') {
|
|
1042
|
-
// @ts-ignore
|
|
1043
|
-
elementRef.current = el;
|
|
1044
|
-
}
|
|
1045
|
-
};
|
|
1046
|
-
};
|
|
1047
1039
|
return /*#__PURE__*/React.createElement("div", {
|
|
1048
1040
|
style: style,
|
|
1041
|
+
ref: fieldRef,
|
|
1049
1042
|
className: clsx([`${prefixCls}`, {
|
|
1050
1043
|
[layout]: layout,
|
|
1051
1044
|
[className]: className,
|
|
@@ -1066,11 +1059,7 @@ const FormItem$1 = ({
|
|
|
1066
1059
|
...childProps
|
|
1067
1060
|
} = child.props;
|
|
1068
1061
|
const fieldValue = value ?? getFieldValue(name) ?? initialValue;
|
|
1069
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1070
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1071
|
-
// @ts-expect-error
|
|
1072
|
-
ref: mergeRefs(child.ref)
|
|
1073
|
-
}, /*#__PURE__*/React.createElement(FormItemChildComponent, _extends({}, props, {
|
|
1062
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormItemChildComponent, _extends({}, props, {
|
|
1074
1063
|
key: `${key}_${isReseting}`,
|
|
1075
1064
|
name: name,
|
|
1076
1065
|
child: child,
|