x-ui-design 0.9.40 → 0.9.43

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
@@ -2650,7 +2650,7 @@ const usePopupPosition = ({
2650
2650
  left: (targetRef.current?.clientLeft || 0) + (targetRef.current?.offsetLeft || 0)
2651
2651
  } : inBody ? {
2652
2652
  top: container.top + window.scrollY + OFFSET,
2653
- left: container.left + +window.scrollX
2653
+ left: container.left + window.scrollX
2654
2654
  } : {
2655
2655
  top: (relativePosition.top || 0) + (targetRef.current?.offsetTop || 0) - (scrollableParents?.offsetTop || 0) + OFFSET,
2656
2656
  left: relativePosition.left + (targetRef.current?.offsetLeft || 0) - (targetRef.current?.clientWidth || 0) / 2
@@ -2697,13 +2697,21 @@ const usePopupPosition = ({
2697
2697
  newPlacement = newPlacement.replace('Left', 'Right');
2698
2698
  }
2699
2699
  }
2700
- if (showInnerContent) {
2700
+ if (showInnerContent && (newPlacement.includes('Left') || newPlacement.includes('Right'))) {
2701
2701
  if (availableSpace.right < 0 && availableSpace.left < 0) {
2702
- if (newPlacement.includes('Right')) {
2703
- positions.left = popupRect.width - positions.left + container.left;
2702
+ const popupWidth = popupRect.width;
2703
+ const targetWidth = container.width;
2704
+ if (!popupContainer) {
2705
+ positions.left = positions.left - popupWidth / 2 + targetWidth / 2;
2706
+ } else if (_containsElement) {
2707
+ positions.left = positions.left - popupWidth / 2 + targetWidth / 2;
2708
+ } else if (inBody) {
2709
+ positions.left = container.left + window.scrollX + targetWidth / 2 - popupWidth / 2;
2704
2710
  }
2705
2711
  if (newPlacement.includes('Left')) {
2706
- positions.left = positions.left - popupRect.width + container.width;
2712
+ newPlacement = newPlacement.replace('Left', '');
2713
+ } else if (newPlacement.includes('Right')) {
2714
+ newPlacement = newPlacement.replace('Right', '');
2707
2715
  }
2708
2716
  }
2709
2717
  }
@@ -4430,7 +4438,6 @@ const Select = ({
4430
4438
  const searchInputRef = useRef(null);
4431
4439
  const [responsiveTagCount, setResponsiveTagCount] = useState(null);
4432
4440
  const [selected, setSelected] = useState(hasMode ? checkModeInitialValue : initialValue);
4433
- const [currentLanguage, setCurrentLanguage] = useState('');
4434
4441
  useImperativeHandle(ref, () => ({
4435
4442
  focus: () => selectRef.current?.focus(),
4436
4443
  blur: () => selectRef.current?.blur(),
@@ -4460,29 +4467,6 @@ const Select = ({
4460
4467
  inputContainer.innerText = '';
4461
4468
  }
4462
4469
  }, [autoClearSearchValue, prefixCls, prefixClsV3]);
4463
- useEffect(() => {
4464
- const targetNode = document.documentElement;
4465
- let originalLang = targetNode.getAttribute('lang');
4466
- const callback = mutationsList => {
4467
- for (const mutation of mutationsList) {
4468
- if (mutation.type === 'attributes' && mutation.attributeName === 'lang') {
4469
- const newLang = targetNode.getAttribute('lang');
4470
- if (newLang !== originalLang) {
4471
- setCurrentLanguage(newLang);
4472
- originalLang = newLang;
4473
- }
4474
- }
4475
- }
4476
- };
4477
- const observer = new MutationObserver(callback);
4478
- observer.observe(targetNode, {
4479
- attributes: true,
4480
- attributeFilter: ['lang']
4481
- });
4482
- return () => {
4483
- observer.disconnect();
4484
- };
4485
- }, []);
4486
4470
  useEffect(() => {
4487
4471
  !controlled && setSelected(hasMode ? checkModeInitialValue : initialValue);
4488
4472
  }, [checkModeInitialValue, hasMode, initialValue]);
@@ -4943,7 +4927,7 @@ const Select = ({
4943
4927
  }, index) => {
4944
4928
  const isSelected = hasMode ? selected.includes(props.value) : props.value === selected;
4945
4929
  return /*#__PURE__*/React.createElement(Option, _extends({
4946
- key: `${props.value}_${index}_${currentLanguage}`
4930
+ key: `${props.value}_${index}`
4947
4931
  }, props, {
4948
4932
  selected: isSelected,
4949
4933
  className: clsx([className, {