x-ui-design 0.9.66 → 0.9.68

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.
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import { PopoverProps } from "../../types/popover";
3
3
  import './style.css';
4
- declare const Popover: ({ prefixCls, content, children, trigger, placement, open, visible, title, style, overlayClassName, overlayStyle, overlayPopupStyle, onVisibleChange, getPopupContainer }: PopoverProps) => React.JSX.Element;
4
+ declare const Popover: ({ prefixCls, content, children, trigger, placement, open, visible, title, style, overlayClassName, overlayStyle, onVisibleChange, getPopupContainer }: PopoverProps) => React.JSX.Element;
5
5
  export default Popover;
@@ -8,9 +8,8 @@ type TPopupPosition = {
8
8
  placement?: Placement;
9
9
  popupContainer?: HTMLElement | null;
10
10
  useTargetWidth?: boolean;
11
- overlayPopupStyle?: CSSProperties;
12
11
  };
13
- export declare const usePopupPosition: ({ open, setOpen, popupRef, targetRef, placement, popupContainer, useTargetWidth, overlayPopupStyle }: TPopupPosition) => {
12
+ export declare const usePopupPosition: ({ open, setOpen, popupRef, targetRef, placement, popupContainer, useTargetWidth, }: TPopupPosition) => {
14
13
  _placement: Placement;
15
14
  popupStyle: CSSProperties;
16
15
  };
@@ -8,10 +8,8 @@ export type PopoverProps = DefaultProps & {
8
8
  open?: boolean;
9
9
  overlayStyle?: CSSProperties;
10
10
  overlayClassName?: string;
11
- overlayPopupStyle?: CSSProperties;
12
11
  title?: string | ReactNode;
13
12
  visible?: boolean;
14
- listenPopoverPositions?: CSSProperties;
15
13
  placementPositionOffset?: number;
16
14
  onVisibleChange?: ((open: boolean) => void) | undefined;
17
15
  getPopupContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
package/dist/index.esm.js CHANGED
@@ -2627,8 +2627,7 @@ const usePopupPosition = ({
2627
2627
  targetRef,
2628
2628
  placement,
2629
2629
  popupContainer,
2630
- useTargetWidth,
2631
- overlayPopupStyle = {}
2630
+ useTargetWidth
2632
2631
  }) => {
2633
2632
  const [_placement, _setPlacement] = useState(placement ?? "bottomLeft");
2634
2633
  const [popupPosition, setPopupPosition] = useState({});
@@ -2664,7 +2663,7 @@ const usePopupPosition = ({
2664
2663
  }
2665
2664
  const popupRect = popupRef.current?.getBoundingClientRect();
2666
2665
  if (popupRect) {
2667
- if (popupRect?.width < OFFSET) {
2666
+ if (popupRect?.width < OFFSET || !targetRef.current) {
2668
2667
  setOpen(false);
2669
2668
  setPopupPosition({});
2670
2669
  const timeout = setTimeout(() => {
@@ -2721,69 +2720,65 @@ const usePopupPosition = ({
2721
2720
  });
2722
2721
  }
2723
2722
  });
2724
- if (Object.keys(overlayPopupStyle).length) {
2725
- setPopupPosition(overlayPopupStyle);
2726
- } else {
2727
- promisePopupPlacment.then(({
2728
- container,
2729
- positions,
2730
- newPlacement
2731
- }) => {
2732
- const _calculation = () => {
2733
- switch (newPlacement) {
2734
- case "bottom":
2735
- setPopupPosition({
2736
- top: positions.top + container.height,
2737
- left: positions.left + (container.width || 0) / 2 - (popupRef.current?.offsetWidth || 0) / 2
2738
- });
2739
- break;
2740
- case "bottomLeft":
2741
- setPopupPosition({
2742
- top: positions.top + container.height,
2743
- left: positions.left
2744
- });
2745
- break;
2746
- case "bottomRight":
2747
- setPopupPosition({
2748
- top: positions.top + container.height,
2749
- left: positions.left + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
2750
- });
2751
- break;
2752
- case "top":
2753
- setPopupPosition({
2754
- top: positions.top - (popupRef.current?.clientHeight || 0) - OFFSET * 2,
2755
- left: positions.left + (container.width || 0) / 2 - (popupRef.current?.offsetWidth || 0) / 2
2756
- });
2757
- break;
2758
- case "topLeft":
2759
- setPopupPosition({
2760
- top: positions.top - (popupRef.current?.clientHeight || 0) - OFFSET * 2,
2761
- left: positions.left
2762
- });
2763
- break;
2764
- case "topRight":
2765
- setPopupPosition({
2766
- top: positions.top - (popupRef.current?.clientHeight || 0) - OFFSET * 2,
2767
- left: positions.left + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
2768
- });
2769
- break;
2770
- case "left":
2771
- setPopupPosition({
2772
- top: positions.top - OFFSET,
2773
- left: positions.left - (popupRef.current?.offsetWidth || 0) - OFFSET
2774
- });
2775
- break;
2776
- case "right":
2777
- setPopupPosition({
2778
- top: positions.top - OFFSET,
2779
- left: positions.left + container.width + OFFSET
2780
- });
2781
- break;
2782
- }
2783
- };
2784
- _calculation();
2785
- });
2786
- }
2723
+ promisePopupPlacment.then(({
2724
+ container,
2725
+ positions,
2726
+ newPlacement
2727
+ }) => {
2728
+ const _calculation = () => {
2729
+ switch (newPlacement) {
2730
+ case "bottom":
2731
+ setPopupPosition({
2732
+ top: positions.top + container.height,
2733
+ left: positions.left + (container.width || 0) / 2 - (popupRef.current?.offsetWidth || 0) / 2
2734
+ });
2735
+ break;
2736
+ case "bottomLeft":
2737
+ setPopupPosition({
2738
+ top: positions.top + container.height,
2739
+ left: positions.left
2740
+ });
2741
+ break;
2742
+ case "bottomRight":
2743
+ setPopupPosition({
2744
+ top: positions.top + container.height,
2745
+ left: positions.left + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
2746
+ });
2747
+ break;
2748
+ case "top":
2749
+ setPopupPosition({
2750
+ top: positions.top - (popupRef.current?.clientHeight || 0) - OFFSET * 2,
2751
+ left: positions.left + (container.width || 0) / 2 - (popupRef.current?.offsetWidth || 0) / 2
2752
+ });
2753
+ break;
2754
+ case "topLeft":
2755
+ setPopupPosition({
2756
+ top: positions.top - (popupRef.current?.clientHeight || 0) - OFFSET * 2,
2757
+ left: positions.left
2758
+ });
2759
+ break;
2760
+ case "topRight":
2761
+ setPopupPosition({
2762
+ top: positions.top - (popupRef.current?.clientHeight || 0) - OFFSET * 2,
2763
+ left: positions.left + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
2764
+ });
2765
+ break;
2766
+ case "left":
2767
+ setPopupPosition({
2768
+ top: positions.top - OFFSET,
2769
+ left: positions.left - (popupRef.current?.offsetWidth || 0) - OFFSET
2770
+ });
2771
+ break;
2772
+ case "right":
2773
+ setPopupPosition({
2774
+ top: positions.top - OFFSET,
2775
+ left: positions.left + container.width + OFFSET
2776
+ });
2777
+ break;
2778
+ }
2779
+ };
2780
+ _calculation();
2781
+ });
2787
2782
  }, [targetRef, popupContainer, popupRef, useTargetWidth, inBody, _placement, setOpen]);
2788
2783
  useEffect(() => {
2789
2784
  if (!open) {
@@ -2811,7 +2806,6 @@ const usePopupPosition = ({
2811
2806
  popupStyle: {
2812
2807
  zIndex: 10000,
2813
2808
  position: "absolute",
2814
- // transition: '1s ease',
2815
2809
  opacity: Object.keys(popupPosition).length ? 1 : 0,
2816
2810
  ...popupPosition
2817
2811
  }
@@ -5675,7 +5669,6 @@ const Popover = ({
5675
5669
  style = {},
5676
5670
  overlayClassName = '',
5677
5671
  overlayStyle = {},
5678
- overlayPopupStyle = {},
5679
5672
  onVisibleChange,
5680
5673
  getPopupContainer
5681
5674
  }) => {
@@ -5692,7 +5685,6 @@ const Popover = ({
5692
5685
  placement,
5693
5686
  open: isOpen,
5694
5687
  setOpen: setInnerOpen,
5695
- overlayPopupStyle,
5696
5688
  popupContainer: getPopupContainer?.(targetRef.current)
5697
5689
  });
5698
5690
  useEffect(() => {