x-ui-design 0.9.66 → 0.9.67
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/esm/types/components/Popover/Popover.d.ts +1 -1
- package/dist/esm/types/hooks/usePopupPosition.d.ts +2 -2
- package/dist/esm/types/types/popover.d.ts +1 -2
- package/dist/index.esm.js +63 -67
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +63 -67
- package/dist/index.js.map +1 -1
- package/lib/components/Popover/Popover.tsx +2 -2
- package/lib/hooks/usePopupPosition.ts +62 -66
- package/lib/types/popover.ts +1 -2
- package/package.json +1 -1
- package/src/app/page.tsx +10 -1
|
@@ -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,
|
|
4
|
+
declare const Popover: ({ prefixCls, content, children, trigger, placement, open, visible, title, style, overlayClassName, overlayStyle, listenPopoverPositions, onVisibleChange, getPopupContainer }: PopoverProps) => React.JSX.Element;
|
|
5
5
|
export default Popover;
|
|
@@ -8,9 +8,9 @@ type TPopupPosition = {
|
|
|
8
8
|
placement?: Placement;
|
|
9
9
|
popupContainer?: HTMLElement | null;
|
|
10
10
|
useTargetWidth?: boolean;
|
|
11
|
-
|
|
11
|
+
listenPopoverPositions?: CSSProperties;
|
|
12
12
|
};
|
|
13
|
-
export declare const usePopupPosition: ({ open, setOpen, popupRef, targetRef, placement, popupContainer, useTargetWidth,
|
|
13
|
+
export declare const usePopupPosition: ({ open, setOpen, popupRef, targetRef, placement, popupContainer, useTargetWidth, listenPopoverPositions }: TPopupPosition) => {
|
|
14
14
|
_placement: Placement;
|
|
15
15
|
popupStyle: CSSProperties;
|
|
16
16
|
};
|
|
@@ -8,10 +8,9 @@ export type PopoverProps = DefaultProps & {
|
|
|
8
8
|
open?: boolean;
|
|
9
9
|
overlayStyle?: CSSProperties;
|
|
10
10
|
overlayClassName?: string;
|
|
11
|
-
|
|
11
|
+
listenPopoverPositions?: CSSProperties;
|
|
12
12
|
title?: string | ReactNode;
|
|
13
13
|
visible?: boolean;
|
|
14
|
-
listenPopoverPositions?: CSSProperties;
|
|
15
14
|
placementPositionOffset?: number;
|
|
16
15
|
onVisibleChange?: ((open: boolean) => void) | undefined;
|
|
17
16
|
getPopupContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
|
package/dist/index.esm.js
CHANGED
|
@@ -2628,7 +2628,7 @@ const usePopupPosition = ({
|
|
|
2628
2628
|
placement,
|
|
2629
2629
|
popupContainer,
|
|
2630
2630
|
useTargetWidth,
|
|
2631
|
-
|
|
2631
|
+
listenPopoverPositions
|
|
2632
2632
|
}) => {
|
|
2633
2633
|
const [_placement, _setPlacement] = useState(placement ?? "bottomLeft");
|
|
2634
2634
|
const [popupPosition, setPopupPosition] = useState({});
|
|
@@ -2721,69 +2721,65 @@ const usePopupPosition = ({
|
|
|
2721
2721
|
});
|
|
2722
2722
|
}
|
|
2723
2723
|
});
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
newPlacement
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
};
|
|
2784
|
-
_calculation();
|
|
2785
|
-
});
|
|
2786
|
-
}
|
|
2724
|
+
promisePopupPlacment.then(({
|
|
2725
|
+
container,
|
|
2726
|
+
positions,
|
|
2727
|
+
newPlacement
|
|
2728
|
+
}) => {
|
|
2729
|
+
const _calculation = () => {
|
|
2730
|
+
switch (newPlacement) {
|
|
2731
|
+
case "bottom":
|
|
2732
|
+
setPopupPosition({
|
|
2733
|
+
top: positions.top + container.height,
|
|
2734
|
+
left: positions.left + (container.width || 0) / 2 - (popupRef.current?.offsetWidth || 0) / 2
|
|
2735
|
+
});
|
|
2736
|
+
break;
|
|
2737
|
+
case "bottomLeft":
|
|
2738
|
+
setPopupPosition({
|
|
2739
|
+
top: positions.top + container.height,
|
|
2740
|
+
left: positions.left
|
|
2741
|
+
});
|
|
2742
|
+
break;
|
|
2743
|
+
case "bottomRight":
|
|
2744
|
+
setPopupPosition({
|
|
2745
|
+
top: positions.top + container.height,
|
|
2746
|
+
left: positions.left + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
|
|
2747
|
+
});
|
|
2748
|
+
break;
|
|
2749
|
+
case "top":
|
|
2750
|
+
setPopupPosition({
|
|
2751
|
+
top: positions.top - (popupRef.current?.clientHeight || 0) - OFFSET * 2,
|
|
2752
|
+
left: positions.left + (container.width || 0) / 2 - (popupRef.current?.offsetWidth || 0) / 2
|
|
2753
|
+
});
|
|
2754
|
+
break;
|
|
2755
|
+
case "topLeft":
|
|
2756
|
+
setPopupPosition({
|
|
2757
|
+
top: positions.top - (popupRef.current?.clientHeight || 0) - OFFSET * 2,
|
|
2758
|
+
left: positions.left
|
|
2759
|
+
});
|
|
2760
|
+
break;
|
|
2761
|
+
case "topRight":
|
|
2762
|
+
setPopupPosition({
|
|
2763
|
+
top: positions.top - (popupRef.current?.clientHeight || 0) - OFFSET * 2,
|
|
2764
|
+
left: positions.left + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
|
|
2765
|
+
});
|
|
2766
|
+
break;
|
|
2767
|
+
case "left":
|
|
2768
|
+
setPopupPosition({
|
|
2769
|
+
top: positions.top - OFFSET,
|
|
2770
|
+
left: positions.left - (popupRef.current?.offsetWidth || 0) - OFFSET
|
|
2771
|
+
});
|
|
2772
|
+
break;
|
|
2773
|
+
case "right":
|
|
2774
|
+
setPopupPosition({
|
|
2775
|
+
top: positions.top - OFFSET,
|
|
2776
|
+
left: positions.left + container.width + OFFSET
|
|
2777
|
+
});
|
|
2778
|
+
break;
|
|
2779
|
+
}
|
|
2780
|
+
};
|
|
2781
|
+
_calculation();
|
|
2782
|
+
});
|
|
2787
2783
|
}, [targetRef, popupContainer, popupRef, useTargetWidth, inBody, _placement, setOpen]);
|
|
2788
2784
|
useEffect(() => {
|
|
2789
2785
|
if (!open) {
|
|
@@ -2805,7 +2801,7 @@ const usePopupPosition = ({
|
|
|
2805
2801
|
controller.abort();
|
|
2806
2802
|
setPopupPosition({});
|
|
2807
2803
|
};
|
|
2808
|
-
}, [open, targetRef, calculatePosition]);
|
|
2804
|
+
}, [open, targetRef, listenPopoverPositions, calculatePosition]);
|
|
2809
2805
|
return {
|
|
2810
2806
|
_placement,
|
|
2811
2807
|
popupStyle: {
|
|
@@ -5675,7 +5671,7 @@ const Popover = ({
|
|
|
5675
5671
|
style = {},
|
|
5676
5672
|
overlayClassName = '',
|
|
5677
5673
|
overlayStyle = {},
|
|
5678
|
-
|
|
5674
|
+
listenPopoverPositions,
|
|
5679
5675
|
onVisibleChange,
|
|
5680
5676
|
getPopupContainer
|
|
5681
5677
|
}) => {
|
|
@@ -5692,7 +5688,7 @@ const Popover = ({
|
|
|
5692
5688
|
placement,
|
|
5693
5689
|
open: isOpen,
|
|
5694
5690
|
setOpen: setInnerOpen,
|
|
5695
|
-
|
|
5691
|
+
listenPopoverPositions,
|
|
5696
5692
|
popupContainer: getPopupContainer?.(targetRef.current)
|
|
5697
5693
|
});
|
|
5698
5694
|
useEffect(() => {
|