x-ui-design 0.9.35 → 0.9.37

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 { TRangePickerProps } from '../../../types/datepicker';
3
3
  import './style.css';
4
- declare const RangePicker: ({ prefixCls, value, onChange, placeholder, disabled, error, format, prefix, allowClear, inputReadOnly, size, picker, locale, disabledDate, onVisibleChange, onCalendarChange, style, className, separator, defaultValue, bordered, getPopupContainer, placement }: TRangePickerProps) => React.JSX.Element;
4
+ declare const RangePicker: ({ prefixCls, value, onChange, placeholder, disabled, error, format, prefix, allowClear, inputReadOnly, size, picker, locale, disabledDate, onVisibleChange, onCalendarChange, style, className, separator, defaultValue, bordered, getPopupContainer, placement, showInnerContent }: TRangePickerProps) => React.JSX.Element;
5
5
  export default RangePicker;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { DropdownProps } from '../../types/dropdown';
3
3
  import './style.css';
4
- declare const Dropdown: ({ children, menu, open: controlledOpen, defaultOpen, onVisibleChange, trigger, placement, overlayClassName, overlayStyle, getPopupContainer, destroyOnHidden, disabled, arrow, autoFocus, popupRender, className, overlay, prefixCls, }: DropdownProps) => React.JSX.Element;
4
+ declare const Dropdown: ({ children, menu, open: controlledOpen, defaultOpen, onVisibleChange, trigger, placement, overlayClassName, overlayStyle, getPopupContainer, destroyOnHidden, disabled, arrow, autoFocus, popupRender, className, overlay, prefixCls, showInnerContent }: DropdownProps) => React.JSX.Element;
5
5
  export default Dropdown;
@@ -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, listenPopoverPositions, placementPositionOffset, onVisibleChange, getPopupContainer }: PopoverProps) => React.JSX.Element;
4
+ declare const Popover: ({ prefixCls, content, children, trigger, placement, open, visible, title, style, overlayClassName, overlayStyle, showInnerContent, 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
+ showInnerContent?: 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, showInnerContent }: TPopupPosition) => {
12
13
  _placement: Placement;
13
14
  popupStyle: CSSProperties;
14
15
  };
@@ -40,6 +40,7 @@ export type TDatePickerProps = DefaultProps & {
40
40
  picker?: PanelMode;
41
41
  bordered?: boolean;
42
42
  defaultPickerValue?: Date;
43
+ showInnerContent?: boolean;
43
44
  };
44
45
  export type TRangePickerProps = Omit<TDatePickerProps, 'placeholder' | 'value' | 'defaultValue'> & {
45
46
  placeholder?: string[];
@@ -119,4 +120,5 @@ export type TimePickerProps = DefaultProps & {
119
120
  suffixIcon?: ReactNode;
120
121
  placeholder?: string;
121
122
  placement?: Placement;
123
+ showInnerContent?: boolean;
122
124
  };
@@ -28,6 +28,7 @@ export type DropdownProps = DefaultProps & {
28
28
  autoAdjustOverflow?: boolean;
29
29
  popupRender?: (node: ReactNode) => ReactNode;
30
30
  overlay?: ReactElement | OverlayFunc;
31
+ showInnerContent?: boolean;
31
32
  };
32
33
  export type DropdownMenuInnerProps = DefaultProps & {
33
34
  items: DropdownItemType[];
@@ -12,6 +12,7 @@ export type PopoverProps = DefaultProps & {
12
12
  visible?: boolean;
13
13
  listenPopoverPositions?: CSSProperties;
14
14
  placementPositionOffset?: number;
15
+ showInnerContent?: boolean;
15
16
  onVisibleChange?: ((open: boolean) => void) | undefined;
16
17
  getPopupContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
17
18
  };
package/dist/index.esm.js CHANGED
@@ -1639,14 +1639,17 @@ function getElementParentDetails(el, includeSelf = false) {
1639
1639
  left: 0,
1640
1640
  top: 0
1641
1641
  };
1642
+ function hasActualScroll(element) {
1643
+ return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
1644
+ }
1642
1645
  while (current) {
1643
1646
  const style = getComputedStyle(current);
1644
- const canScroll = ['auto', 'scroll'].includes(style.overflowY) || ['auto', 'scroll'].includes(style.overflowX);
1645
- if (current.style.position === 'relative') {
1647
+ const allowScroll = style.overflowY !== "visible" || style.overflowX !== "visible";
1648
+ if (current.style.position === "relative") {
1646
1649
  relativePosition.left += current.offsetLeft;
1647
1650
  relativePosition.top += current.offsetTop;
1648
1651
  }
1649
- if (canScroll) {
1652
+ if (allowScroll && hasActualScroll(current)) {
1650
1653
  return {
1651
1654
  relativePosition,
1652
1655
  scrollableParents: current
@@ -1655,10 +1658,7 @@ function getElementParentDetails(el, includeSelf = false) {
1655
1658
  current = current.parentElement;
1656
1659
  }
1657
1660
  return {
1658
- relativePosition: {
1659
- left: 0,
1660
- top: 0
1661
- },
1661
+ relativePosition,
1662
1662
  scrollableParents: document.scrollingElement
1663
1663
  };
1664
1664
  }
@@ -2618,14 +2618,15 @@ const ConditionalWrapper = ({
2618
2618
  children
2619
2619
  }) => condition ? wrapper(children) : children;
2620
2620
 
2621
- const OFFSET = 12;
2621
+ const OFFSET = 11;
2622
2622
  const usePopupPosition = ({
2623
2623
  open,
2624
2624
  setOpen,
2625
2625
  popupRef,
2626
2626
  targetRef,
2627
2627
  placement,
2628
- popupContainer
2628
+ popupContainer,
2629
+ showInnerContent
2629
2630
  }) => {
2630
2631
  const [_placement, _setPlacement] = useState(placement ?? "bottomLeft");
2631
2632
  const [popupPosition, setPopupPosition] = useState({});
@@ -2676,9 +2677,9 @@ const usePopupPosition = ({
2676
2677
  right: (inBody ? window.innerWidth : scrollableParents?.clientWidth || 0) - ((targetRef.current?.offsetLeft || 0 || container.right) + popupRect.width + OFFSET)
2677
2678
  };
2678
2679
  let newPlacement = _placement;
2679
- if (availableSpace.bottom < 0 && availableSpace.top > 0 && availableSpace.top > popupRect.height) {
2680
+ if (availableSpace.bottom < 0 && availableSpace.top > 0) {
2680
2681
  newPlacement = newPlacement.replace('bottom', 'top');
2681
- } else if (availableSpace.top < 0 && availableSpace.bottom > 0 && availableSpace.bottom > popupRect.height) {
2682
+ } else if (availableSpace.top < 0 && availableSpace.bottom > 0) {
2682
2683
  newPlacement = newPlacement.replace('top', 'bottom');
2683
2684
  }
2684
2685
  if (availableSpace.left < 0 && availableSpace.right > 0 && availableSpace.right > popupRect.width) {
@@ -2686,14 +2687,16 @@ const usePopupPosition = ({
2686
2687
  } else if (availableSpace.right < 0 && availableSpace.left > 0 && availableSpace.left > popupRect.width) {
2687
2688
  newPlacement = newPlacement.replace('Left', 'Right');
2688
2689
  }
2689
- // if (availableSpace.right < 0 && availableSpace.left < 0) {
2690
- // if (newPlacement.includes('Right')) {
2691
- // positions.left = (popupRect.width - positions.left) + container.left
2692
- // }
2693
- // if (newPlacement.includes('Left')) {
2694
- // positions.left = positions.left - popupRect.width + container.width
2695
- // }
2696
- // }
2690
+ if (showInnerContent) {
2691
+ if (availableSpace.right < 0 && availableSpace.left < 0) {
2692
+ if (newPlacement.includes('Right')) {
2693
+ positions.left = popupRect.width - positions.left + container.left;
2694
+ }
2695
+ if (newPlacement.includes('Left')) {
2696
+ positions.left = positions.left - popupRect.width + container.width;
2697
+ }
2698
+ }
2699
+ }
2697
2700
  _setPlacement(newPlacement);
2698
2701
  }
2699
2702
  const _calculation = () => {
@@ -2737,7 +2740,7 @@ const usePopupPosition = ({
2737
2740
  }
2738
2741
  };
2739
2742
  _calculation();
2740
- }, [targetRef, popupContainer, popupRef, inBody, _placement, setOpen]);
2743
+ }, [targetRef, popupContainer, popupRef, showInnerContent, inBody, _placement, setOpen]);
2741
2744
  useEffect(() => {
2742
2745
  if (!open) {
2743
2746
  return;
@@ -3145,7 +3148,8 @@ const RangePicker = ({
3145
3148
  defaultValue,
3146
3149
  bordered = true,
3147
3150
  getPopupContainer,
3148
- placement = "bottomLeft"
3151
+ placement = "bottomLeft",
3152
+ showInnerContent
3149
3153
  }) => {
3150
3154
  const [isOpen, setIsOpen] = useState(false);
3151
3155
  const [selectedDates, setSelectedDates] = useState([value?.[0] || defaultValue?.[0] || null, value?.[1] || defaultValue?.[1] || null]);
@@ -3166,6 +3170,7 @@ const RangePicker = ({
3166
3170
  popupRef,
3167
3171
  placement,
3168
3172
  open: isOpen,
3173
+ showInnerContent,
3169
3174
  setOpen: setIsOpen,
3170
3175
  popupContainer: getPopupContainer?.(targetRef.current)
3171
3176
  });
@@ -3467,7 +3472,8 @@ const TimePicker = ({
3467
3472
  suffixIcon = /*#__PURE__*/React.createElement(TimeIcon, null),
3468
3473
  placeholder = 'Select time',
3469
3474
  getPopupContainer,
3470
- placement = "bottomLeft"
3475
+ placement = "bottomLeft",
3476
+ showInnerContent
3471
3477
  }) => {
3472
3478
  const [open, setOpen] = useState(false);
3473
3479
  const [innerValue, setInnerValue] = useState(propValue || defaultValue ? new Date(propValue || defaultValue) : null);
@@ -3486,6 +3492,7 @@ const TimePicker = ({
3486
3492
  popupRef,
3487
3493
  placement,
3488
3494
  targetRef,
3495
+ showInnerContent,
3489
3496
  setOpen: setOpen,
3490
3497
  popupContainer: getPopupContainer?.(targetRef.current)
3491
3498
  });
@@ -5449,7 +5456,8 @@ const Dropdown = ({
5449
5456
  popupRender,
5450
5457
  className = '',
5451
5458
  overlay,
5452
- prefixCls = prefixClsDropdown
5459
+ prefixCls = prefixClsDropdown,
5460
+ showInnerContent
5453
5461
  }) => {
5454
5462
  const [open, setOpen] = useState(controlledOpen ?? defaultOpen);
5455
5463
  const isControlled = controlledOpen !== undefined;
@@ -5461,10 +5469,11 @@ const Dropdown = ({
5461
5469
  _placement
5462
5470
  } = usePopupPosition({
5463
5471
  open,
5464
- targetRef,
5472
+ setOpen,
5465
5473
  popupRef,
5474
+ targetRef,
5466
5475
  placement,
5467
- setOpen,
5476
+ showInnerContent,
5468
5477
  popupContainer: getPopupContainer?.(targetRef.current)
5469
5478
  });
5470
5479
  useEffect(() => {
@@ -5616,8 +5625,7 @@ const Popover = ({
5616
5625
  style = {},
5617
5626
  overlayClassName = '',
5618
5627
  overlayStyle = {},
5619
- listenPopoverPositions,
5620
- placementPositionOffset,
5628
+ showInnerContent,
5621
5629
  onVisibleChange,
5622
5630
  getPopupContainer
5623
5631
  }) => {
@@ -5633,6 +5641,7 @@ const Popover = ({
5633
5641
  popupRef,
5634
5642
  placement,
5635
5643
  open: isOpen,
5644
+ showInnerContent,
5636
5645
  setOpen: setInnerOpen,
5637
5646
  popupContainer: getPopupContainer?.(targetRef.current)
5638
5647
  });