x-ui-design 0.3.58 → 0.3.59
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 +14 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/lib/components/Checkbox/Checkbox.tsx +3 -0
- package/lib/components/Form/Item/Item.tsx +13 -15
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -932,7 +932,6 @@ const FormItem$1 = ({
|
|
|
932
932
|
feedbackIcons,
|
|
933
933
|
...props
|
|
934
934
|
}) => {
|
|
935
|
-
const [_name] = useState(name);
|
|
936
935
|
const formContext = useContext(FormContext);
|
|
937
936
|
const errorRef = useRef(null);
|
|
938
937
|
if (!formContext) {
|
|
@@ -950,25 +949,25 @@ const FormItem$1 = ({
|
|
|
950
949
|
} = formContext;
|
|
951
950
|
const childrenList = useMemo(() => flattenChildren(children), [children]);
|
|
952
951
|
useEffect(() => {
|
|
953
|
-
if (
|
|
954
|
-
registerField(
|
|
952
|
+
if (name && !getFieldInstance(name)) {
|
|
953
|
+
registerField(name, rules);
|
|
955
954
|
}
|
|
956
|
-
}, [
|
|
955
|
+
}, [name, rules]);
|
|
957
956
|
useEffect(() => {
|
|
958
957
|
if (initialValue) {
|
|
959
|
-
setFieldValue(
|
|
958
|
+
setFieldValue(name, initialValue);
|
|
960
959
|
}
|
|
961
960
|
}, []);
|
|
962
961
|
useEffect(() => {
|
|
963
|
-
if (
|
|
962
|
+
if (name && dependencies.length > 0) {
|
|
964
963
|
const unsubscribe = subscribeToFields(dependencies, () => {
|
|
965
|
-
validateFields([
|
|
964
|
+
validateFields([name]);
|
|
966
965
|
});
|
|
967
966
|
return () => {
|
|
968
967
|
unsubscribe();
|
|
969
968
|
};
|
|
970
969
|
}
|
|
971
|
-
}, [dependencies,
|
|
970
|
+
}, [dependencies, name]);
|
|
972
971
|
useEffect(() => {
|
|
973
972
|
if (errorRef.current && errorRef.current?.clientHeight >= REF_CLIENT_HEIGHT) {
|
|
974
973
|
errorRef.current.style.position = 'relative';
|
|
@@ -976,7 +975,7 @@ const FormItem$1 = ({
|
|
|
976
975
|
}
|
|
977
976
|
}, [errorRef.current]);
|
|
978
977
|
const isRequired = useMemo(() => rules.some(rule => rule.required), [rules]);
|
|
979
|
-
const errorMessage = getFieldError(
|
|
978
|
+
const errorMessage = getFieldError(name)?.[0];
|
|
980
979
|
return /*#__PURE__*/React$1.createElement("div", {
|
|
981
980
|
style: style,
|
|
982
981
|
className: clsx([`${prefixCls}`, {
|
|
@@ -984,10 +983,10 @@ const FormItem$1 = ({
|
|
|
984
983
|
[className]: className,
|
|
985
984
|
noStyle: props.noStyle
|
|
986
985
|
}])
|
|
987
|
-
}, !props.noStyle && (label ||
|
|
986
|
+
}, !props.noStyle && (label || name) && /*#__PURE__*/React$1.createElement("label", {
|
|
988
987
|
className: `${prefixCls}-label`,
|
|
989
|
-
htmlFor:
|
|
990
|
-
}, label ||
|
|
988
|
+
htmlFor: name
|
|
989
|
+
}, label || name, ":", isRequired && /*#__PURE__*/React$1.createElement("span", {
|
|
991
990
|
className: `${prefixCls}-required`
|
|
992
991
|
}, "*")), Children.map(childrenList, (child, key) => {
|
|
993
992
|
if (/*#__PURE__*/isValidElement(child) && child.type !== Fragment) {
|
|
@@ -998,9 +997,9 @@ const FormItem$1 = ({
|
|
|
998
997
|
value,
|
|
999
998
|
...childProps
|
|
1000
999
|
} = child.props;
|
|
1001
|
-
const fieldValue = getFieldValue(
|
|
1000
|
+
const fieldValue = getFieldValue(name) ?? initialValue;
|
|
1002
1001
|
return /*#__PURE__*/React$1.createElement(FormItemChildComponent, _extends({}, childProps, {
|
|
1003
|
-
name:
|
|
1002
|
+
name: name,
|
|
1004
1003
|
child: child,
|
|
1005
1004
|
value: value,
|
|
1006
1005
|
fieldValue: fieldValue,
|
|
@@ -1358,6 +1357,7 @@ const Checkbox = /*#__PURE__*/forwardRef(({
|
|
|
1358
1357
|
if (checked !== undefined) {
|
|
1359
1358
|
setInternalChecked(checked);
|
|
1360
1359
|
}
|
|
1360
|
+
console.log('checkbox', name);
|
|
1361
1361
|
}, [checked]);
|
|
1362
1362
|
return /*#__PURE__*/React$1.createElement("div", {
|
|
1363
1363
|
className: `${prefixCls}-wrapper`
|