x-ui-design 0.9.37 → 0.9.39

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
@@ -442,7 +442,7 @@ function styleInject(css, ref) {
442
442
  }
443
443
  }
444
444
 
445
- var css_248z$q = ":root{--xui-color-hover:#f5f5f5;--xui-color-disabled:#e6e6e6;--xui-primary-color:#1677ff;--xui-primary-color-light:#40a9ff;--xui-text-color:rgba(0,0,0,.88);--xui-text-color-light:rgba(0,0,0,.5);--xui-error-color:#ff4d4f;--xui-error-color-light:#ff6668;--xui-success-color:#52c41a;--xui-background-color:#fff;--xui-font-size-xs:12px;--xui-font-size-sm:14px;--xui-font-size-md:14px;--xui-font-size-lg:16px;--xui-border-radius-sm:4px;--xui-border-radius-md:4px;--xui-border-radius-lg:6px;--xui-border-color:#d9d9d9;--xui-select-primary-color:var(--xui-primary-color);--xui-select-background-color:var(--xui-background-color);--xui-result-bg:#fff;--xui-result-color:rgba(0,0,0,.85);--xui-subtle-color:rgba(0,0,0,.45);--xui-padding:24px;--xui-gap:16px;--xui-icon-size:72px;--xui-max-width:560px;--xui-font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial}html{font-family:sans-serif}.globalEllipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xUi-popup-position{&:after,&:before{content:\"\";height:12px;left:0;position:absolute;top:-12px;width:100%;z-index:10000}&:after{bottom:-12px;top:unset}}.xUi-popup-position-bottom,.xUi-popup-position-bottomLeft,.xUi-popup-position-bottomRight,.xUi-popup-position-top,.xUi-popup-position-topLeft,.xUi-popup-position-topRight{background:var(--xui-background-color);border-left:.5px solid var(--xui-border-color);border-top:.5px solid var(--xui-border-color);height:10px;position:absolute;width:10px}.xUi-popup-position-bottom,.xUi-popup-position-bottomLeft,.xUi-popup-position-bottomRight{top:-5px;transform:rotate(45deg)}.xUi-popup-position-top,.xUi-popup-position-topLeft,.xUi-popup-position-topRight{bottom:-5px;top:unset;transform:rotate(-135deg)}.xUi-popup-position-bottom,.xUi-popup-position-top{left:50%;right:50%}.xUi-popup-position-bottomLeft,.xUi-popup-position-topLeft{left:12px;right:unset}.xUi-popup-position-bottomRight,.xUi-popup-position-topRight{left:unset;right:12px}";
445
+ var css_248z$q = ":root{--xui-color-hover:#f5f5f5;--xui-color-disabled:#e6e6e6;--xui-primary-color:#1677ff;--xui-primary-color-light:#40a9ff;--xui-text-color:rgba(0,0,0,.88);--xui-text-color-light:rgba(0,0,0,.5);--xui-error-color:#ff4d4f;--xui-error-color-light:#ff6668;--xui-success-color:#52c41a;--xui-background-color:#fff;--xui-font-size-xs:12px;--xui-font-size-sm:14px;--xui-font-size-md:14px;--xui-font-size-lg:16px;--xui-border-radius-sm:4px;--xui-border-radius-md:4px;--xui-border-radius-lg:6px;--xui-border-color:#d9d9d9;--xui-select-primary-color:var(--xui-primary-color);--xui-select-background-color:var(--xui-background-color);--xui-result-bg:#fff;--xui-result-color:rgba(0,0,0,.85);--xui-subtle-color:rgba(0,0,0,.45);--xui-padding:24px;--xui-gap:16px;--xui-icon-size:72px;--xui-max-width:560px;--xui-font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial}html{font-family:sans-serif}.globalEllipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xUi-popup-position{&:after,&:before{content:\"\";height:12px;left:0;position:absolute;top:-12px;width:100%;z-index:10000}&:after{bottom:-12px;top:unset}}.xUi-popup-position-bottom,.xUi-popup-position-bottomLeft,.xUi-popup-position-bottomRight,.xUi-popup-position-left,.xUi-popup-position-right,.xUi-popup-position-top,.xUi-popup-position-topLeft,.xUi-popup-position-topRight{background:var(--xui-background-color);border-left:.5px solid var(--xui-border-color);border-top:.5px solid var(--xui-border-color);height:10px;position:absolute;width:10px}.xUi-popup-position-bottom,.xUi-popup-position-bottomLeft,.xUi-popup-position-bottomRight{top:-5px;transform:rotate(45deg)}.xUi-popup-position-top,.xUi-popup-position-topLeft,.xUi-popup-position-topRight{bottom:-5px;top:unset;transform:rotate(-135deg)}.xUi-popup-position-bottom,.xUi-popup-position-top{left:50%;right:50%}.xUi-popup-position-left{left:calc(100% - 5px);right:unset;top:10px;transform:rotate(135deg)}.xUi-popup-position-right{left:unset;right:calc(100% - 5px);top:10px;transform:rotate(-45deg)}.xUi-popup-position-bottomLeft,.xUi-popup-position-topLeft{left:12px;right:unset}.xUi-popup-position-bottomRight,.xUi-popup-position-topRight{left:unset;right:12px}";
446
446
  styleInject(css_248z$q);
447
447
 
448
448
  const ClearIcon = () => /*#__PURE__*/React.createElement("svg", {
@@ -2619,6 +2619,7 @@ const ConditionalWrapper = ({
2619
2619
  }) => condition ? wrapper(children) : children;
2620
2620
 
2621
2621
  const OFFSET = 11;
2622
+ const LEFT_OR_RIGHT = ['left', 'right'];
2622
2623
  const usePopupPosition = ({
2623
2624
  open,
2624
2625
  setOpen,
@@ -2640,7 +2641,7 @@ const usePopupPosition = ({
2640
2641
  scrollableParents,
2641
2642
  relativePosition
2642
2643
  } = getElementParentDetails(targetRef.current, true);
2643
- const _containsElement = scrollableParents?.contains(popupContainer) && popupContainer !== scrollableParents;
2644
+ const _containsElement = scrollableParents?.contains(popupContainer) && popupContainer !== scrollableParents && !inBody;
2644
2645
  const positions = !popupContainer ? {
2645
2646
  top: (targetRef.current?.offsetTop || 0) + OFFSET,
2646
2647
  left: targetRef.current?.offsetLeft || 0
@@ -2648,8 +2649,8 @@ const usePopupPosition = ({
2648
2649
  top: (targetRef.current?.clientTop || 0) + (targetRef.current?.offsetTop || 0) + OFFSET,
2649
2650
  left: (targetRef.current?.clientLeft || 0) + (targetRef.current?.offsetLeft || 0)
2650
2651
  } : inBody ? {
2651
- top: container.top + OFFSET,
2652
- left: container.left
2652
+ top: container.top + window.scrollY + OFFSET,
2653
+ left: container.left + +window.scrollX
2653
2654
  } : {
2654
2655
  top: (relativePosition.top || 0) + (targetRef.current?.offsetTop || 0) - (scrollableParents?.offsetTop || 0) + OFFSET,
2655
2656
  left: relativePosition.left + (targetRef.current?.offsetLeft || 0) - (targetRef.current?.clientWidth || 0) / 2
@@ -2677,15 +2678,24 @@ const usePopupPosition = ({
2677
2678
  right: (inBody ? window.innerWidth : scrollableParents?.clientWidth || 0) - ((targetRef.current?.offsetLeft || 0 || container.right) + popupRect.width + OFFSET)
2678
2679
  };
2679
2680
  let newPlacement = _placement;
2681
+ const onlyLeftOrRight = LEFT_OR_RIGHT.includes(newPlacement);
2680
2682
  if (availableSpace.bottom < 0 && availableSpace.top > 0) {
2681
2683
  newPlacement = newPlacement.replace('bottom', 'top');
2682
2684
  } else if (availableSpace.top < 0 && availableSpace.bottom > 0) {
2683
2685
  newPlacement = newPlacement.replace('top', 'bottom');
2684
2686
  }
2685
- if (availableSpace.left < 0 && availableSpace.right > 0 && availableSpace.right > popupRect.width) {
2686
- newPlacement = newPlacement.replace('Right', 'Left');
2687
- } else if (availableSpace.right < 0 && availableSpace.left > 0 && availableSpace.left > popupRect.width) {
2688
- newPlacement = newPlacement.replace('Left', 'Right');
2687
+ if (onlyLeftOrRight) {
2688
+ if (availableSpace.left < 0) {
2689
+ newPlacement = newPlacement.replace('left', 'right');
2690
+ } else if (availableSpace.right < 0) {
2691
+ newPlacement = newPlacement.replace('right', 'left');
2692
+ }
2693
+ } else {
2694
+ if (availableSpace.left < 0 && availableSpace.right > 0 && availableSpace.right > popupRect.width) {
2695
+ newPlacement = newPlacement.replace('Right', 'Left');
2696
+ } else if (availableSpace.right < 0 && availableSpace.left > 0 && availableSpace.left > popupRect.width) {
2697
+ newPlacement = newPlacement.replace('Left', 'Right');
2698
+ }
2689
2699
  }
2690
2700
  if (showInnerContent) {
2691
2701
  if (availableSpace.right < 0 && availableSpace.left < 0) {
@@ -2737,6 +2747,18 @@ const usePopupPosition = ({
2737
2747
  left: positions.left + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
2738
2748
  });
2739
2749
  break;
2750
+ case "left":
2751
+ setPopupPosition({
2752
+ top: positions.top - OFFSET,
2753
+ left: positions.left - (popupRef.current?.offsetWidth || 0) - OFFSET
2754
+ });
2755
+ break;
2756
+ case "right":
2757
+ setPopupPosition({
2758
+ top: positions.top - OFFSET,
2759
+ left: positions.left + container.width + OFFSET
2760
+ });
2761
+ break;
2740
2762
  }
2741
2763
  };
2742
2764
  _calculation();