x-ui-design 0.3.79 → 0.3.81

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
@@ -743,11 +743,17 @@ const useForm = (initialValues = {}, onFieldsChange, onValuesChange, scrollToFir
743
743
  async function validateFields(nameList) {
744
744
  const fieldsToValidate = nameList || Object.keys(formRef.current);
745
745
  const results = await Promise.all(fieldsToValidate.map(name => validateField(name)));
746
- console.log(_scrollToFirstError.current);
747
746
  if (_scrollToFirstError.current) {
748
747
  const firstErrorContent = document.querySelectorAll('.xUi-form-item-error')?.[0];
749
748
  if (firstErrorContent) {
750
- firstErrorContent.closest('.xUi-form-item')?.closest('[data-item="first-content"]')?.scrollIntoView();
749
+ function findFormItem(item) {
750
+ if (item?.parentElement?.tagName !== 'FORM') {
751
+ findFormItem(item?.parentElement);
752
+ } else {
753
+ item.scrollIntoView();
754
+ }
755
+ }
756
+ findFormItem(firstErrorContent.closest('.xUi-form-item'));
751
757
  setScrollToFirstError(false);
752
758
  }
753
759
  }
@@ -1134,16 +1140,14 @@ const Form$1 = ({
1134
1140
  formInstance.onValuesChange = onValuesChange;
1135
1141
  }
1136
1142
  }, [formInstance, onFieldsChange, onValuesChange]);
1137
- const injectPropsIntoFinalLeaf = (child, key) => {
1143
+ const injectPropsIntoFinalLeaf = child => {
1138
1144
  if (! /*#__PURE__*/isValidElement(child)) {
1139
1145
  return child;
1140
1146
  }
1141
1147
  const childProps = child.props;
1142
1148
  const isWrapper = typeof child.type === 'string' && !('dangerouslySetInnerHTML' in childProps) && ['div', 'span', 'label'].includes(child.type);
1143
1149
  if (isWrapper) {
1144
- return /*#__PURE__*/React$1.createElement(child.type, _extends({}, childProps, {
1145
- "data-item": key == 0 ? 'first-content' : ''
1146
- }), Children.map(flattenChildren(childProps.children), injectPropsIntoFinalLeaf));
1150
+ return /*#__PURE__*/React$1.createElement(child.type, childProps, Children.map(flattenChildren(childProps.children), injectPropsIntoFinalLeaf));
1147
1151
  }
1148
1152
  if (childProps?.__injected) {
1149
1153
  return child;
@@ -1161,7 +1165,7 @@ const Form$1 = ({
1161
1165
  ref: formRef,
1162
1166
  onSubmit: handleSubmit,
1163
1167
  className: `${prefixCls} ${className}`
1164
- }, Children.map(childrenList, (child, key) => injectPropsIntoFinalLeaf(child, key))));
1168
+ }, Children.map(childrenList, child => injectPropsIntoFinalLeaf(child))));
1165
1169
  };
1166
1170
  Form$1.Item = FormItem$1;
1167
1171
 
@@ -3381,7 +3385,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3381
3385
  style: {
3382
3386
  ...dropdownPosition,
3383
3387
  maxHeight: listHeight,
3384
- opacity: Object.keys(dropdownPosition).length ? 1 : 0
3388
+ opacity: dropdownPosition.top ? 1 : 0
3385
3389
  }
3386
3390
  }, filterable && /*#__PURE__*/React$1.createElement("input", {
3387
3391
  type: "text",