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