@hexure/ui 1.13.2 → 1.13.4

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
@@ -301,7 +301,7 @@ Heading.defaultProps = {
301
301
  type: 'primary',
302
302
  };
303
303
 
304
- const Wrapper$i = styled.div `
304
+ const Wrapper$h = styled.div `
305
305
  position: fixed;
306
306
  top: 0;
307
307
  right: 0;
@@ -325,7 +325,7 @@ const Buttons$1 = styled.div `
325
325
  `;
326
326
  const ActionDialog = (_a) => {
327
327
  var { description, title, primaryButton, secondaryButton, tertiaryButton, style = {} } = _a, accessibleProps = __rest(_a, ["description", "title", "primaryButton", "secondaryButton", "tertiaryButton", "style"]);
328
- return (React.createElement(Wrapper$i, Object.assign({}, accessibleProps),
328
+ return (React.createElement(Wrapper$h, Object.assign({}, accessibleProps),
329
329
  React.createElement(Container$4, { "$customStyle": style, open: true },
330
330
  title ? (React.createElement(Heading, { margin: '0px 0px 20px 0px', type: 'secondary' }, title)) : null,
331
331
  description ? React.createElement(Copy, { align: 'center' }, description) : null,
@@ -335,7 +335,7 @@ const ActionDialog = (_a) => {
335
335
  primaryButton ? (React.createElement(Button, Object.assign({}, primaryButton, { format: primaryButton.format || 'primary' }))) : null)) : null)));
336
336
  };
337
337
 
338
- const Wrapper$h = styled.div `
338
+ const Wrapper$g = styled.div `
339
339
  border: 1px solid #f1f1f1;
340
340
  border-radius: 4px;
341
341
  border-left-width: 4px;
@@ -379,7 +379,7 @@ const Alert = (_a) => {
379
379
  icon: js.mdiCheckboxMarkedCircleOutline,
380
380
  },
381
381
  };
382
- return (React.createElement(Wrapper$h, Object.assign({}, accessibleProps, { "$small": small, style: { borderLeftColor: type_mapping[type].color } }),
382
+ return (React.createElement(Wrapper$g, Object.assign({}, accessibleProps, { "$small": small, style: { borderLeftColor: type_mapping[type].color } }),
383
383
  React.createElement(StyledIcon$5, { color: type_mapping[type].color, path: type_mapping[type].icon, size: small ? '20px' : '30px' }),
384
384
  React.createElement("div", null,
385
385
  title && !small ? (React.createElement(Heading, { bold: true, margin: '2px 0 0 0', type: 'tertiary' }, title)) : null,
@@ -458,7 +458,7 @@ const AppHeader = ({ logoUrl, buttons = [] }) => {
458
458
  React.createElement(Buttons, null, buttons.map((b, i) => (React.createElement(Button, Object.assign({ key: i }, b)))))));
459
459
  };
460
460
 
461
- const Wrapper$g = styled.div `
461
+ const Wrapper$f = styled.div `
462
462
  display: inline-block;
463
463
  border-radius: 4px;
464
464
  padding: 4px 6px;
@@ -485,7 +485,7 @@ const Remove$1 = styled.div `
485
485
  `;
486
486
  const Tag = (_a) => {
487
487
  var { children, color = 'PRIMARY', removable, onClick } = _a, accessibleProps = __rest(_a, ["children", "color", "removable", "onClick"]);
488
- return (React.createElement(Wrapper$g, Object.assign({ "$color": color, "$removable": removable, onClick: onClick }, accessibleProps),
488
+ return (React.createElement(Wrapper$f, Object.assign({ "$color": color, "$removable": removable, onClick: onClick }, accessibleProps),
489
489
  React.createElement(Content$3, null,
490
490
  React.createElement(Label$4, { "$color": color }, children),
491
491
  removable ? (React.createElement(Remove$1, null,
@@ -500,7 +500,7 @@ const SidebarContainer = styled.div `
500
500
  padding: 12px 0px;
501
501
  width: ${props => (props.$isOpen ? props.$width : '60px')};
502
502
  `;
503
- const MenuWrapper = styled.div `
503
+ const MenuWrapper$1 = styled.div `
504
504
  display: flex;
505
505
  align-items: center;
506
506
  border-left-width: 4px;
@@ -582,7 +582,7 @@ const AppMenu = ({ menu, isCollapsed, footerTag, defaultWidth = '280px' }) => {
582
582
  return (React.createElement(SidebarContainer, { "$isOpen": !collapsed, "$width": defaultWidth },
583
583
  React.createElement(SidebarMenuContainer, null, menu.map(nav_item => {
584
584
  return (React.createElement(React.Fragment, { key: nav_item.label },
585
- React.createElement(MenuWrapper, { "$active": !!nav_item.is_active, "$color": theme.PRIMARY_COLOR, onClick: nav_item.onClick },
585
+ React.createElement(MenuWrapper$1, { "$active": !!nav_item.is_active, "$color": theme.PRIMARY_COLOR, onClick: nav_item.onClick },
586
586
  React.createElement(MenuIcon, { "$active": !!nav_item.is_active, path: nav_item.icon }),
587
587
  collapsed ? null : (React.createElement(MenuLabel, { "$active": nav_item.is_active, "$color": theme.PRIMARY_COLOR }, nav_item.label))),
588
588
  nav_item.is_active && nav_item.menu && !collapsed ? (React.createElement(SubMenu, null, nav_item.menu.map(menu_item => (React.createElement(SubMenuItem, { "$active": menu_item.is_active, "$color": theme.PRIMARY_COLOR, key: menu_item.label, onClick: menu_item.onClick }, menu_item.label))))) : null));
@@ -600,7 +600,7 @@ const AppMenu = ({ menu, isCollapsed, footerTag, defaultWidth = '280px' }) => {
600
600
  }, small: true }))));
601
601
  };
602
602
 
603
- const Wrapper$f = styled.div `
603
+ const Wrapper$e = styled.div `
604
604
  border: 1px solid ${props => props.theme.PRIMARY_COLOR.Hex};
605
605
  border-radius: 8px;
606
606
  box-sizing: border-box;
@@ -609,7 +609,7 @@ const Wrapper$f = styled.div `
609
609
  justify-content: space-between;
610
610
  padding: 16px 20px;
611
611
  `;
612
- Wrapper$f.defaultProps = { theme: EditableTheme };
612
+ Wrapper$e.defaultProps = { theme: EditableTheme };
613
613
  const Left = styled.div `
614
614
  box-sizing: border-box;
615
615
  display: flex;
@@ -670,7 +670,7 @@ const ErrorMsg = styled.span `
670
670
  `;
671
671
  const BulkActionBar = (_a) => {
672
672
  var { actions = [], errorMsg, onClear, selectedCount = 0 } = _a, accessibleProps = __rest(_a, ["actions", "errorMsg", "onClear", "selectedCount"]);
673
- return (React.createElement(Wrapper$f, Object.assign({}, accessibleProps),
673
+ return (React.createElement(Wrapper$e, Object.assign({}, accessibleProps),
674
674
  React.createElement(Left, null,
675
675
  React.createElement(Info$1, null,
676
676
  React.createElement(Selected, null,
@@ -683,7 +683,7 @@ const BulkActionBar = (_a) => {
683
683
  React.createElement(ErrorMsg, null, errorMsg))) : null));
684
684
  };
685
685
 
686
- const Wrapper$e = styled.div `
686
+ const Wrapper$d = styled.div `
687
687
  background: #fff;
688
688
  border-radius: 8px;
689
689
  box-shadow: 0px 10px 30px -15px rgba(0, 0, 0, 0.2);
@@ -724,30 +724,93 @@ const Title$1 = styled.span `
724
724
  `;
725
725
  const MoreMenu = (_a) => {
726
726
  var { maxHeight, menuItems = [] } = _a, accessibleProps = __rest(_a, ["maxHeight", "menuItems"]);
727
- return (React.createElement(Wrapper$e, Object.assign({ "$maxHeight": maxHeight }, accessibleProps), menuItems.map((item, i) => {
727
+ return (React.createElement(Wrapper$d, Object.assign({ "$maxHeight": maxHeight }, accessibleProps), menuItems.map((item, i) => {
728
728
  return (React.createElement(MenuItem, { key: i, onClick: item.onClick },
729
729
  item.icon ? (React.createElement(Icon, { color: Colors.MEDIUM_GRAY.Hex, path: item.icon, size: '20px' })) : null,
730
730
  React.createElement(Title$1, null, item.label)));
731
731
  })));
732
732
  };
733
733
 
734
- const Wrapper$d = styled.div `
734
+ const MenuWrapper = styled.div `
735
735
  position: relative;
736
736
  display: inline-block;
737
737
  `;
738
738
  const StyledMoreMenu = styled(MoreMenu) `
739
- position: absolute;
740
- right: ${props => (props.$position === 'right' ? '0px' : 'auto')};
741
- left: ${props => (props.$position === 'left' ? '0px' : 'auto')};
742
- top: ${props => (props.$small ? '30px' : '40px')};
739
+ position: fixed;
740
+ top: ${props => props.$top};
741
+ left: ${props => props.$left};
743
742
  width: ${props => props.$menuWidth};
743
+ max-height: ${props => props.maxHeight};
744
744
  z-index: 10;
745
745
  `;
746
- const ButtonMenu = ({ disabled, label, maxHeight, menuItems, small, position = 'right', format = 'primary', menuWidth = '200px', }) => {
747
- const [show_menu, toggleMenu] = React.useState(false);
748
- return (React.createElement(Wrapper$d, { onMouseEnter: disabled ? undefined : toggleMenu.bind(null, true), onMouseLeave: disabled ? undefined : toggleMenu.bind(null, false) },
746
+ const ButtonMenu = ({ disabled, label, maxHeight, menuItems, small, position = 'bottomLeft', format = 'primary', menuWidth = '200px', enableHover = true, enableClick = false, }) => {
747
+ const [showMenu, toggleMenu] = React.useState(false);
748
+ const [menuPosition, setMenuPosition] = React.useState({ top: '0px', left: '0px' });
749
+ const menuWrapperRef = React.useRef(null);
750
+ const handleMouseEnter = () => {
751
+ if (!disabled && enableHover) {
752
+ toggleMenu(true);
753
+ }
754
+ };
755
+ const handleMouseLeave = () => {
756
+ if (!disabled && enableHover) {
757
+ toggleMenu(false);
758
+ }
759
+ };
760
+ const handleClick = () => {
761
+ if (enableClick) {
762
+ toggleMenu(!showMenu);
763
+ }
764
+ };
765
+ React.useEffect(() => {
766
+ if (showMenu && menuWrapperRef.current) {
767
+ const rect = menuWrapperRef.current.getBoundingClientRect();
768
+ let top = rect.top;
769
+ let left = rect.left;
770
+ switch (position) {
771
+ case 'top':
772
+ top = rect.top - rect.height;
773
+ left = rect.left;
774
+ break;
775
+ case 'bottom':
776
+ top = rect.bottom;
777
+ left = rect.left;
778
+ break;
779
+ case 'left':
780
+ top = rect.top;
781
+ left = rect.left - rect.width;
782
+ break;
783
+ case 'right':
784
+ top = rect.top;
785
+ left = rect.right;
786
+ break;
787
+ case 'bottomRight':
788
+ top = rect.bottom;
789
+ left = rect.left;
790
+ break;
791
+ case 'bottomLeft':
792
+ top = rect.bottom;
793
+ left = rect.right - parseInt(menuWidth, 10);
794
+ break;
795
+ case 'topRight':
796
+ top = rect.top - parseInt(menuWidth, 10);
797
+ left = rect.left;
798
+ break;
799
+ case 'topLeft':
800
+ top = rect.top - parseInt(menuWidth, 10);
801
+ left = rect.right - parseInt(menuWidth, 10);
802
+ break;
803
+ default:
804
+ top = rect.bottom;
805
+ left = rect.left;
806
+ break;
807
+ }
808
+ setMenuPosition({ top: `${top}px`, left: `${left}px` });
809
+ }
810
+ }, [showMenu, position, menuWidth]);
811
+ return (React.createElement(MenuWrapper, { onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, ref: menuWrapperRef },
749
812
  React.createElement(Button, { disabled: disabled, format: format, icon: js.mdiDotsHorizontal, small: small }, label),
750
- show_menu ? (React.createElement(StyledMoreMenu, { "$menuWidth": menuWidth, "$position": position, "$small": small, maxHeight: maxHeight, menuItems: menuItems })) : null));
813
+ showMenu && (React.createElement(StyledMoreMenu, { "$left": menuPosition.left, "$menuWidth": menuWidth, "$top": menuPosition.top, maxHeight: maxHeight, menuItems: menuItems }))));
751
814
  };
752
815
 
753
816
  const Wrapper$c = styled.div `