x-ui-design 0.3.49 → 0.3.52

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
@@ -709,6 +709,7 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange) => {
709
709
  const fieldWarnings = [];
710
710
  await Promise.all([rules].flat(1).map(async rule => {
711
711
  rule = typeof rule === 'function' ? rule(formInstance) : rule;
712
+ debugger;
712
713
  if (rule.required && (rule.validateBooleanFalse && !value || value === undefined || value === null || value === '' || Array.isArray(value) && !value.length)) {
713
714
  fieldErrors.push(rule.message || 'This field is required');
714
715
  }
@@ -917,6 +918,7 @@ const FormItem$1 = ({
917
918
  feedbackIcons,
918
919
  ...props
919
920
  }) => {
921
+ const [_name] = useState(valuePropName || name);
920
922
  const formContext = useContext(FormContext);
921
923
  const errorRef = useRef(null);
922
924
  if (!formContext) {
@@ -934,25 +936,25 @@ const FormItem$1 = ({
934
936
  } = formContext;
935
937
  const childrenList = useMemo(() => flattenChildren(children), [children]);
936
938
  useEffect(() => {
937
- if (name && !getFieldInstance(name)) {
938
- registerField(name, rules);
939
+ if (_name && !getFieldInstance(_name)) {
940
+ registerField(_name, rules);
939
941
  }
940
- }, [name, rules]);
942
+ }, [_name, rules]);
941
943
  useEffect(() => {
942
944
  if (initialValue) {
943
- setFieldValue(name, initialValue);
945
+ setFieldValue(_name, initialValue);
944
946
  }
945
947
  }, []);
946
948
  useEffect(() => {
947
- if (name && dependencies.length > 0) {
949
+ if (_name && dependencies.length > 0) {
948
950
  const unsubscribe = subscribeToFields(dependencies, () => {
949
- validateFields([name]);
951
+ validateFields([_name]);
950
952
  });
951
953
  return () => {
952
954
  unsubscribe();
953
955
  };
954
956
  }
955
- }, [dependencies, name]);
957
+ }, [dependencies, _name]);
956
958
  useEffect(() => {
957
959
  if (errorRef.current && errorRef.current?.clientHeight >= REF_CLIENT_HEIGHT) {
958
960
  errorRef.current.style.position = 'relative';
@@ -960,7 +962,7 @@ const FormItem$1 = ({
960
962
  }
961
963
  }, [errorRef.current]);
962
964
  const isRequired = useMemo(() => rules.some(rule => rule.required), [rules]);
963
- const errorMessage = getFieldError(valuePropName || name)?.[0];
965
+ const errorMessage = getFieldError(_name)?.[0];
964
966
  return /*#__PURE__*/React$1.createElement("div", {
965
967
  style: style,
966
968
  className: clsx([`${prefixCls}`, {
@@ -968,10 +970,10 @@ const FormItem$1 = ({
968
970
  [className]: className,
969
971
  noStyle: props.noStyle
970
972
  }])
971
- }, !props.noStyle && (label || name) && /*#__PURE__*/React$1.createElement("label", {
973
+ }, !props.noStyle && (label || _name) && /*#__PURE__*/React$1.createElement("label", {
972
974
  className: `${prefixCls}-label`,
973
- htmlFor: name
974
- }, label || name, ":", isRequired && /*#__PURE__*/React$1.createElement("span", {
975
+ htmlFor: _name
976
+ }, label || _name, ":", isRequired && /*#__PURE__*/React$1.createElement("span", {
975
977
  className: `${prefixCls}-required`
976
978
  }, "*")), Children.map(childrenList, (child, key) => {
977
979
  if (/*#__PURE__*/isValidElement(child) && child.type !== Fragment) {
@@ -982,9 +984,9 @@ const FormItem$1 = ({
982
984
  value,
983
985
  ...childProps
984
986
  } = child.props;
985
- const fieldValue = getFieldValue(valuePropName || name) ?? initialValue;
987
+ const fieldValue = getFieldValue(_name) ?? initialValue;
986
988
  return /*#__PURE__*/React$1.createElement(FormItemChildComponent, _extends({}, childProps, {
987
- name: name,
989
+ name: _name,
988
990
  child: child,
989
991
  value: value,
990
992
  fieldValue: fieldValue,
@@ -993,7 +995,6 @@ const FormItem$1 = ({
993
995
  key: `${key}_${isReseting}`,
994
996
  error: Boolean(errorMessage),
995
997
  setFieldValue: setFieldValue,
996
- valuePropName: valuePropName,
997
998
  feedbackIcons: feedbackIcons
998
999
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
999
1000
  // @ts-expect-error
@@ -1015,7 +1016,6 @@ const FormItemChildComponent = ({
1015
1016
  fieldValue,
1016
1017
  setFieldValue,
1017
1018
  onChange,
1018
- valuePropName,
1019
1019
  normalize,
1020
1020
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1021
1021
  noStyle,
@@ -1044,7 +1044,7 @@ const FormItemChildComponent = ({
1044
1044
  return;
1045
1045
  }
1046
1046
  }
1047
- setFieldValue(valuePropName || name, rawValue);
1047
+ setFieldValue(name, rawValue);
1048
1048
  onChange?.(e, option);
1049
1049
  };
1050
1050
  return /*#__PURE__*/React$1.createElement(child.type, _extends({}, props, {