@hexure/ui 1.13.3 → 1.13.5

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/cjs/index.js CHANGED
@@ -736,47 +736,20 @@ const MenuWrapper = styled.div `
736
736
  display: inline-block;
737
737
  `;
738
738
  const StyledMoreMenu = styled(MoreMenu) `
739
- position: absolute;
739
+ position: fixed;
740
+ top: ${props => props.$top};
741
+ left: ${props => props.$left};
742
+ position: fixed;
743
+ top: ${props => props.$top};
744
+ left: ${props => props.$left};
740
745
  width: ${props => props.$menuWidth};
741
746
  max-height: ${props => props.maxHeight};
742
747
  z-index: 10;
743
-
744
- ${props => {
745
- switch (props.$position) {
746
- case 'top':
747
- return `
748
- bottom: 100%;
749
- left: 0;
750
- transform: translateY(-5px); /* Adjust this value as needed */
751
- `;
752
- case 'bottom':
753
- return `
754
- top: 100%;
755
- left: 0;
756
- transform: translateY(5px); /* Adjust this value as needed */
757
- `;
758
- case 'left':
759
- return `
760
- right: 100%;
761
- top: 0;
762
- transform: translateX(-5px); /* Adjust this value as needed */
763
- `;
764
- case 'right':
765
- return `
766
- left: 100%;
767
- top: 0;
768
- transform: translateX(5px); /* Adjust this value as needed */
769
- `;
770
- default:
771
- return `
772
- top: 0;
773
- left: 0;
774
- `;
775
- }
776
- }}
777
748
  `;
778
- const ButtonMenu = ({ disabled, label, maxHeight, menuItems, small, position = 'right', format = 'primary', menuWidth = '200px', enableHover = true, enableClick = false, }) => {
749
+ const ButtonMenu = ({ disabled, label, maxHeight, menuItems, small, position = 'bottomLeft', format = 'primary', menuWidth = '200px', enableHover = true, enableClick = false, }) => {
779
750
  const [showMenu, toggleMenu] = React.useState(false);
751
+ const [menuPosition, setMenuPosition] = React.useState({ top: '0px', left: '0px' });
752
+ const menuWrapperRef = React.useRef(null);
780
753
  const handleMouseEnter = () => {
781
754
  if (!disabled && enableHover) {
782
755
  toggleMenu(true);
@@ -792,9 +765,56 @@ const ButtonMenu = ({ disabled, label, maxHeight, menuItems, small, position = '
792
765
  toggleMenu(!showMenu);
793
766
  }
794
767
  };
795
- return (React.createElement(MenuWrapper, { onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
768
+ React.useEffect(() => {
769
+ if (showMenu && menuWrapperRef.current) {
770
+ const wrapperRect = menuWrapperRef.current.getBoundingClientRect();
771
+ const menuWidthInt = parseInt(menuWidth, 10);
772
+ let top = wrapperRect.top;
773
+ let left = wrapperRect.left;
774
+ switch (position) {
775
+ case 'top':
776
+ top = wrapperRect.top - 142; // Menu above the wrapper
777
+ left = wrapperRect.left;
778
+ break;
779
+ case 'bottom':
780
+ top = wrapperRect.bottom; // Menu below the wrapper
781
+ left = wrapperRect.left;
782
+ break;
783
+ case 'left':
784
+ top = wrapperRect.top;
785
+ left = wrapperRect.left - menuWidthInt; // Menu to the left of the wrapper
786
+ break;
787
+ case 'right':
788
+ top = wrapperRect.top;
789
+ left = wrapperRect.right; // Menu to the right of the wrapper
790
+ break;
791
+ case 'bottomLeft':
792
+ top = wrapperRect.bottom;
793
+ left = wrapperRect.right - menuWidthInt;
794
+ break;
795
+ case 'bottomRight':
796
+ top = wrapperRect.bottom;
797
+ left = wrapperRect.left;
798
+ break;
799
+ case 'topRight':
800
+ top = wrapperRect.top - 142;
801
+ left = wrapperRect.right - 24;
802
+ break;
803
+ case 'topLeft':
804
+ top = wrapperRect.top - 142;
805
+ left = wrapperRect.left - 188;
806
+ break;
807
+ default:
808
+ top = wrapperRect.bottom;
809
+ left = wrapperRect.left;
810
+ break;
811
+ }
812
+ setMenuPosition({ top: `${top}px`, left: `${left}px` });
813
+ }
814
+ }, [showMenu, position, menuWidth]);
815
+ return (React.createElement(MenuWrapper, { onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, ref: menuWrapperRef },
796
816
  React.createElement(Button, { disabled: disabled, format: format, icon: js.mdiDotsHorizontal, small: small }, label),
797
- showMenu && (React.createElement(StyledMoreMenu, { "$menuWidth": menuWidth, "$position": position, "$small": small, maxHeight: maxHeight, menuItems: menuItems }))));
817
+ showMenu && (React.createElement(StyledMoreMenu, { "$left": menuPosition.left, "$menuWidth": menuWidth, "$top": menuPosition.top, maxHeight: maxHeight, menuItems: menuItems }))));
798
818
  };
799
819
 
800
820
  const Wrapper$c = styled.div `
@@ -883,8 +903,8 @@ const Input$2 = styled.input `
883
903
  border-color: ${Colors.MEDIUM_GRAY.Hex};
884
904
  }
885
905
  &:disabled + span {
886
- background-color: #fff;
887
- border-color: ${Colors.MEDIUM_GRAY.Hex};
906
+ background-color: #d3d3d3;
907
+ border-color: #d3d3d3;
888
908
  }
889
909
  &:checked + span:after {
890
910
  display: block;
@@ -2292,8 +2312,8 @@ const Input = styled.input `
2292
2312
  display: block;
2293
2313
  }
2294
2314
  &:disabled + span {
2295
- background-color: #fff;
2296
- border-color: ${Colors.MEDIUM_GRAY.Hex};
2315
+ background-color: #d3d3d3;
2316
+ border-color: #d3d3d3;
2297
2317
  }
2298
2318
  &:disabled + span:after {
2299
2319
  background-color: #fff;