x-ui-design 0.9.61 → 0.9.63

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, onVisibleChange, getPopupContainer }: PopoverProps) => React.JSX.Element;
4
+ declare const Popover: ({ prefixCls, content, children, trigger, placement, open, visible, title, style, overlayClassName, overlayStyle, overlayPopupStyle, onVisibleChange, getPopupContainer }: PopoverProps) => React.JSX.Element;
5
5
  export default Popover;
@@ -7,8 +7,9 @@ type TPopupPosition = {
7
7
  popupRef: RefObject<HTMLDivElement | null>;
8
8
  placement?: Placement;
9
9
  popupContainer?: HTMLElement | null;
10
+ useTargetWidth?: boolean;
10
11
  };
11
- export declare const usePopupPosition: ({ open, setOpen, popupRef, targetRef, placement, popupContainer, }: TPopupPosition) => {
12
+ export declare const usePopupPosition: ({ open, setOpen, popupRef, targetRef, placement, popupContainer, useTargetWidth }: TPopupPosition) => {
12
13
  _placement: Placement;
13
14
  popupStyle: CSSProperties;
14
15
  };
@@ -8,6 +8,7 @@ export type PopoverProps = DefaultProps & {
8
8
  open?: boolean;
9
9
  overlayStyle?: CSSProperties;
10
10
  overlayClassName?: string;
11
+ overlayPopupStyle?: CSSProperties;
11
12
  title?: string | ReactNode;
12
13
  visible?: boolean;
13
14
  listenPopoverPositions?: CSSProperties;
package/dist/index.esm.js CHANGED
@@ -2626,7 +2626,8 @@ const usePopupPosition = ({
2626
2626
  popupRef,
2627
2627
  targetRef,
2628
2628
  placement,
2629
- popupContainer
2629
+ popupContainer,
2630
+ useTargetWidth
2630
2631
  }) => {
2631
2632
  const [_placement, _setPlacement] = useState(placement ?? "bottomLeft");
2632
2633
  const [popupPosition, setPopupPosition] = useState({});
@@ -2671,6 +2672,12 @@ const usePopupPosition = ({
2671
2672
  }, 10);
2672
2673
  return;
2673
2674
  }
2675
+ if (targetRef.current && popupRef.current && useTargetWidth) {
2676
+ if (popupRect.width < container.width) {
2677
+ const targetWidth = targetRef.current.offsetWidth;
2678
+ popupRef.current.style.width = `${targetWidth}px`;
2679
+ }
2680
+ }
2674
2681
  const availableSpace = {
2675
2682
  top: container.top - (popupRect.height + OFFSET),
2676
2683
  bottom: (inBody ? window.innerHeight : scrollableParents?.clientHeight || 0) - (container.bottom + popupRect.height + OFFSET),
@@ -2772,7 +2779,7 @@ const usePopupPosition = ({
2772
2779
  };
2773
2780
  _calculation();
2774
2781
  });
2775
- }, [targetRef, popupContainer, popupRef, inBody, _placement, setOpen]);
2782
+ }, [targetRef, popupContainer, popupRef, useTargetWidth, inBody, _placement, setOpen]);
2776
2783
  useEffect(() => {
2777
2784
  if (!open) {
2778
2785
  return;
@@ -4808,7 +4815,8 @@ const Select = ({
4808
4815
  [`${prefixCls}-tag-container-fixHeight ${prefixClsV3}-tag-container-fixHeight`]: !tagtriggerRef.current
4809
4816
  }])
4810
4817
  }, hasMode ? /*#__PURE__*/React.createElement(React.Fragment, null, selectedTags.length ? /*#__PURE__*/React.createElement(React.Fragment, null, tagsToDisplay.map((tag, index) => tagRender ? /*#__PURE__*/React.createElement("div", {
4811
- key: `${index}_${tag}`
4818
+ key: `${index}_${tag}`,
4819
+ className: `${prefixCls}-tag-render-container`
4812
4820
  }, tagRender?.({
4813
4821
  label: (() => {
4814
4822
  const option = extractedOptions.find(e => e.value === tag || e.label === tag || e.children === tag);
@@ -5513,6 +5521,7 @@ const Dropdown = ({
5513
5521
  popupRef,
5514
5522
  targetRef,
5515
5523
  placement,
5524
+ useTargetWidth: true,
5516
5525
  popupContainer: getPopupContainer?.(targetRef.current)
5517
5526
  });
5518
5527
  useEffect(() => {
@@ -5661,6 +5670,7 @@ const Popover = ({
5661
5670
  style = {},
5662
5671
  overlayClassName = '',
5663
5672
  overlayStyle = {},
5673
+ overlayPopupStyle = {},
5664
5674
  onVisibleChange,
5665
5675
  getPopupContainer
5666
5676
  }) => {
@@ -5753,7 +5763,8 @@ const Popover = ({
5753
5763
  className: clsx(prefixCls, prefixClsPopupPosition, overlayClassName),
5754
5764
  style: {
5755
5765
  ...overlayStyle,
5756
- ...popupStyle
5766
+ ...popupStyle,
5767
+ ...overlayPopupStyle
5757
5768
  }
5758
5769
  }), title && /*#__PURE__*/React.createElement("div", {
5759
5770
  className: `${prefixCls}-title`