x-ui-design 0.3.30 → 0.3.32

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.
@@ -40,7 +40,7 @@ declare const Select: React.ForwardRefExoticComponent<import("../../types").Defa
40
40
  suffixIcon?: ReactNode;
41
41
  open?: boolean;
42
42
  notFoundContent?: ReactNode;
43
- getPopupContainer?: (triggerNode: HTMLElement | null) => HTMLElement;
43
+ getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
44
44
  dropdownRender?: (menu: ReactNode) => ReactNode;
45
45
  feedbackIcons?: boolean;
46
46
  placement?: "bottomLeft" | "bottomRight" | "topLeft" | "topRight";
@@ -138,7 +138,7 @@ declare const Select: import("react").ComponentType<import("@/types").DefaultPro
138
138
  suffixIcon?: import("react").ReactNode;
139
139
  open?: boolean;
140
140
  notFoundContent?: import("react").ReactNode;
141
- getPopupContainer?: (triggerNode: HTMLElement | null) => HTMLElement;
141
+ getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
142
142
  dropdownRender?: (menu: import("react").ReactNode) => import("react").ReactNode;
143
143
  feedbackIcons?: boolean;
144
144
  placement?: "bottomLeft" | "bottomRight" | "topLeft" | "topRight";
@@ -39,7 +39,7 @@ export type SelectProps = DefaultProps & {
39
39
  suffixIcon?: ReactNode;
40
40
  open?: boolean;
41
41
  notFoundContent?: ReactNode;
42
- getPopupContainer?: (triggerNode: HTMLElement | null) => HTMLElement;
42
+ getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
43
43
  dropdownRender?: (menu: ReactNode) => ReactNode;
44
44
  feedbackIcons?: boolean;
45
45
  placement?: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';
package/dist/index.d.ts CHANGED
@@ -222,7 +222,7 @@ declare const Select: react.ComponentType<__types.DefaultProps & {
222
222
  suffixIcon?: react.ReactNode;
223
223
  open?: boolean;
224
224
  notFoundContent?: react.ReactNode;
225
- getPopupContainer?: (triggerNode: HTMLElement | null) => HTMLElement;
225
+ getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
226
226
  dropdownRender?: (menu: react.ReactNode) => react.ReactNode;
227
227
  feedbackIcons?: boolean;
228
228
  placement?: "bottomLeft" | "bottomRight" | "topLeft" | "topRight";
package/dist/index.esm.js CHANGED
@@ -2920,7 +2920,7 @@ var css_248z$5 = "@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(
2920
2920
  styleInject(css_248z$5);
2921
2921
 
2922
2922
  const LIST_HEIGHT = 200;
2923
- const PADDING_PLACEMENT = 18;
2923
+ const PADDING_PLACEMENT = 16;
2924
2924
  const PADDING_TAG_INPUT = 4;
2925
2925
  function getTextFromNode(node) {
2926
2926
  if (typeof node === 'string' || typeof node === 'number') {
@@ -3034,38 +3034,32 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3034
3034
  }, [handleClearInputValue, open, hasMode, prefixCls]);
3035
3035
  const updateDropdownPosition = useCallback(() => {
3036
3036
  if (!selectRef.current) return;
3037
- const selectBox = selectRef.current.getBoundingClientRect();
3037
+ const triggerNode = selectRef.current?.querySelector(`.${prefixCls}-trigger`);
3038
+ const selectBox = triggerNode.getBoundingClientRect();
3038
3039
  const dropdownHeight = listHeight;
3039
3040
  const windowHeight = window.innerHeight;
3040
3041
  const spaceBelow = windowHeight - selectBox.bottom;
3041
3042
  const spaceAbove = selectBox.top;
3042
3043
  let positionStyle = {
3043
- width: `${selectBox.width}px`,
3044
+ width: `${triggerNode.offsetWidth + PADDING_PLACEMENT}px`,
3044
3045
  position: 'absolute'
3045
3046
  };
3046
3047
  const shouldShowAbove = spaceBelow < dropdownHeight && spaceAbove > dropdownHeight;
3047
- console.info({
3048
- selectBox,
3049
- shouldShowAbove,
3050
- scrollX: window.scrollX,
3051
- offsetTop: selectRef.current.offsetTop,
3052
- clientHeight: selectRef.current.clientHeight
3053
- });
3054
3048
  if (getPopupContainer) {
3055
3049
  positionStyle = {
3056
3050
  ...positionStyle,
3057
- top: shouldShowAbove ? `${selectRef.current.offsetTop + PADDING_PLACEMENT / 2 - dropdownHeight}px` : `${selectRef.current.offsetTop + selectRef.current.clientHeight}px`,
3058
- left: `${selectBox.left}px`
3051
+ top: shouldShowAbove ? `${triggerNode.offsetTop + PADDING_PLACEMENT / 2 - dropdownHeight}px` : `${triggerNode.offsetTop + selectRef.current.clientHeight}px`,
3052
+ left: `${triggerNode.offsetLeft - PADDING_PLACEMENT / 2}px`
3059
3053
  };
3060
3054
  } else {
3061
3055
  positionStyle = {
3062
3056
  ...positionStyle,
3063
- top: shouldShowAbove ? `${selectRef.current.clientHeight - dropdownHeight - PADDING_PLACEMENT}px` : `${selectBox.height}px`,
3064
- left: `${window.scrollX}px`
3057
+ top: shouldShowAbove ? `${triggerNode.offsetTop - dropdownHeight + PADDING_PLACEMENT / 2}px` : `${triggerNode.offsetTop + triggerNode.offsetHeight}px`,
3058
+ left: `${triggerNode.offsetLeft - PADDING_PLACEMENT / 2}px`
3065
3059
  };
3066
3060
  }
3067
3061
  setDropdownPosition(positionStyle);
3068
- }, [listHeight, getPopupContainer]);
3062
+ }, [prefixCls, listHeight, getPopupContainer]);
3069
3063
  useEffect(() => {
3070
3064
  if (!isOpen) {
3071
3065
  return setDropdownPosition({});
@@ -3205,8 +3199,9 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3205
3199
  if (typeof window === 'undefined') {
3206
3200
  return selectRef.current;
3207
3201
  }
3208
- return getPopupContainer?.(selectRef.current) || selectRef.current;
3209
- }, [getPopupContainer]);
3202
+ const triggerNode = selectRef.current?.querySelector(`.${prefixCls}-trigger`);
3203
+ return triggerNode ? getPopupContainer?.(triggerNode) : selectRef.current;
3204
+ }, [getPopupContainer, prefixCls]);
3210
3205
  const extractedOptions = children ? extractOptions(children) : options;
3211
3206
  function extractOptions(children, options) {
3212
3207
  const result = [];