@patternfly/react-core 4.175.1 → 4.175.2

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.
@@ -14250,11 +14250,11 @@
14250
14250
  }
14251
14251
  }
14252
14252
  render() {
14253
- const _a = this.props, { 'aria-label': ariaLabel, id, children, className, onSelect, selected = null, onActionClick, ouiaId, ouiaSafe, containsFlyout, containsDrilldown, isMenuDrilledIn, isPlain, isScrollable, drilldownItemPath, drilledInMenus, onDrillIn, onDrillOut, onGetMenuHeight, parentMenu = null, activeItemId = null,
14253
+ const _a = this.props, { 'aria-label': ariaLabel, id, children, className, onSelect, selected = null, onActionClick, ouiaId, ouiaSafe, containsFlyout, isNavFlyout, containsDrilldown, isMenuDrilledIn, isPlain, isScrollable, drilldownItemPath, drilledInMenus, onDrillIn, onDrillOut, onGetMenuHeight, parentMenu = null, activeItemId = null,
14254
14254
  /* eslint-disable @typescript-eslint/no-unused-vars */
14255
14255
  innerRef, isRootMenu, activeMenu } = _a,
14256
14256
  /* eslint-enable @typescript-eslint/no-unused-vars */
14257
- props = __rest$1(_a, ['aria-label', "id", "children", "className", "onSelect", "selected", "onActionClick", "ouiaId", "ouiaSafe", "containsFlyout", "containsDrilldown", "isMenuDrilledIn", "isPlain", "isScrollable", "drilldownItemPath", "drilledInMenus", "onDrillIn", "onDrillOut", "onGetMenuHeight", "parentMenu", "activeItemId", "innerRef", "isRootMenu", "activeMenu"]);
14257
+ props = __rest$1(_a, ['aria-label', "id", "children", "className", "onSelect", "selected", "onActionClick", "ouiaId", "ouiaSafe", "containsFlyout", "isNavFlyout", "containsDrilldown", "isMenuDrilledIn", "isPlain", "isScrollable", "drilldownItemPath", "drilledInMenus", "onDrillIn", "onDrillOut", "onGetMenuHeight", "parentMenu", "activeItemId", "innerRef", "isRootMenu", "activeMenu"]);
14258
14258
  const _isMenuDrilledIn = isMenuDrilledIn || (drilledInMenus && drilledInMenus.includes(id)) || false;
14259
14259
  return (React__namespace.createElement(MenuContext.Provider, { value: {
14260
14260
  menuId: id,
@@ -14277,7 +14277,7 @@
14277
14277
  (document.activeElement.closest('ol') && document.activeElement.closest('ol').firstChild === element), getFocusableElement: (navigableElement) => navigableElement.firstChild, noHorizontalArrowHandling: document.activeElement &&
14278
14278
  (document.activeElement.classList.contains('pf-c-breadcrumb__link') ||
14279
14279
  document.activeElement.classList.contains('pf-c-dropdown__toggle')), noEnterHandling: true, noSpaceHandling: true })),
14280
- React__namespace.createElement("div", Object.assign({ id: id, className: css(_default$z.menu, isPlain && _default$z.modifiers.plain, isScrollable && _default$z.modifiers.scrollable, containsFlyout && _default$z.modifiers.flyout, containsDrilldown && _default$z.modifiers.drilldown, _isMenuDrilledIn && _default$z.modifiers.drilledIn, className), "aria-label": ariaLabel, ref: this.menuRef }, getOUIAProps(Menu.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe), props), children)));
14280
+ React__namespace.createElement("div", Object.assign({ id: id, className: css(_default$z.menu, isPlain && _default$z.modifiers.plain, isScrollable && _default$z.modifiers.scrollable, containsFlyout && _default$z.modifiers.flyout, isNavFlyout && _default$z.modifiers.nav, containsDrilldown && _default$z.modifiers.drilldown, _isMenuDrilledIn && _default$z.modifiers.drilledIn, className), "aria-label": ariaLabel, ref: this.menuRef }, getOUIAProps(Menu.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe), props), children)));
14281
14281
  }
14282
14282
  }
14283
14283
  MenuBase.displayName = 'Menu';
@@ -15332,8 +15332,10 @@
15332
15332
  const { flyoutRef, setFlyoutRef } = React__namespace.useContext(NavContext);
15333
15333
  const { isNavOpen } = React__namespace.useContext(PageSidebarContext);
15334
15334
  const [flyoutTarget, setFlyoutTarget] = React__namespace.useState(null);
15335
+ const [isHovered, setIsHovered] = React__namespace.useState(false);
15335
15336
  const ref = React__namespace.useRef();
15336
15337
  const flyoutVisible = ref === flyoutRef;
15338
+ const popperRef = React__namespace.useRef();
15337
15339
  const Component = component;
15338
15340
  const hasFlyout = flyout !== undefined;
15339
15341
  const showFlyout = (show, override) => {
@@ -15366,32 +15368,11 @@
15366
15368
  }
15367
15369
  }
15368
15370
  };
15369
- React__namespace.useEffect(() => {
15370
- if (hasFlyout) {
15371
- window.addEventListener('click', onFlyoutClick);
15372
- }
15373
- return () => {
15374
- if (hasFlyout) {
15375
- window.removeEventListener('click', onFlyoutClick);
15376
- }
15377
- };
15378
- }, []);
15379
- React__namespace.useEffect(() => {
15380
- if (flyoutTarget) {
15381
- if (flyoutVisible) {
15382
- const flyoutMenu = flyoutTarget.nextElementSibling;
15383
- const flyoutItems = Array.from(flyoutMenu.getElementsByTagName('UL')[0].children).filter(el => !(el.classList.contains('pf-m-disabled') || el.classList.contains('pf-c-divider')));
15384
- flyoutItems[0].firstChild.focus();
15385
- }
15386
- else {
15387
- flyoutTarget.focus();
15388
- }
15389
- }
15390
- }, [flyoutVisible, flyoutTarget]);
15391
15371
  const handleFlyout = (event) => {
15372
+ var _a, _b;
15392
15373
  const key = event.key;
15393
15374
  const target = event.target;
15394
- if (!hasFlyout) {
15375
+ if (!(((_a = popperRef === null || popperRef === void 0 ? void 0 : popperRef.current) === null || _a === void 0 ? void 0 : _a.contains(target)) || (hasFlyout && ((_b = ref === null || ref === void 0 ? void 0 : ref.current) === null || _b === void 0 ? void 0 : _b.contains(target))))) {
15395
15376
  return;
15396
15377
  }
15397
15378
  if (key === ' ' || key === 'ArrowRight') {
@@ -15410,12 +15391,33 @@
15410
15391
  }
15411
15392
  }
15412
15393
  };
15394
+ React__namespace.useEffect(() => {
15395
+ if (hasFlyout) {
15396
+ window.addEventListener('click', onFlyoutClick);
15397
+ }
15398
+ return () => {
15399
+ if (hasFlyout) {
15400
+ window.removeEventListener('click', onFlyoutClick);
15401
+ }
15402
+ };
15403
+ }, []);
15404
+ React__namespace.useEffect(() => {
15405
+ if (flyoutTarget) {
15406
+ if (flyoutVisible) {
15407
+ const flyoutItems = Array.from(popperRef.current.getElementsByTagName('UL')[0].children).filter(el => !(el.classList.contains('pf-m-disabled') || el.classList.contains('pf-c-divider')));
15408
+ flyoutItems[0].firstChild.focus();
15409
+ }
15410
+ else {
15411
+ flyoutTarget.focus();
15412
+ }
15413
+ }
15414
+ }, [flyoutVisible, flyoutTarget]);
15413
15415
  const flyoutButton = (React__namespace.createElement("span", { className: css(_default$w.navToggle) },
15414
15416
  React__namespace.createElement("span", { className: css(_default$w.navToggleIcon) },
15415
15417
  React__namespace.createElement(AngleRightIcon$1, { "aria-hidden": true }))));
15416
15418
  const renderDefaultLink = (context) => {
15417
15419
  const preventLinkDefault = preventDefault || !to;
15418
- return (React__namespace.createElement(Component, Object.assign({ href: to, onClick: (e) => context.onSelect(e, groupId, itemId, to, preventLinkDefault, onClick), className: css(_default$w.navLink, isActive && _default$w.modifiers.current, className), "aria-current": isActive ? 'page' : null, tabIndex: isNavOpen ? null : '-1' }, props),
15420
+ return (React__namespace.createElement(Component, Object.assign({ href: to, onClick: (e) => context.onSelect(e, groupId, itemId, to, preventLinkDefault, onClick), className: css(_default$w.navLink, isActive && _default$w.modifiers.current, isHovered && _default$w.modifiers.hover, className), "aria-current": isActive ? 'page' : null, tabIndex: isNavOpen ? null : '-1' }, props),
15419
15421
  children,
15420
15422
  flyout && flyoutButton));
15421
15423
  };
@@ -15425,13 +15427,20 @@
15425
15427
  child.props.children,
15426
15428
  flyoutButton)) : (child.props.children) }));
15427
15429
  const ouiaProps = useOUIAProps(NavItem.displayName, ouiaId, ouiaSafe);
15428
- return (React__namespace.createElement("li", Object.assign({}, (hasFlyout && {
15429
- onKeyDown: handleFlyout
15430
- }), { onMouseOver: onMouseOver, className: css(_default$w.navItem, hasFlyout && _default$w.modifiers.flyout, className), ref: ref }, ouiaProps),
15431
- React__namespace.createElement(NavContext.Consumer, null, context => React__namespace.isValidElement(children)
15432
- ? renderClonedChild(context, children)
15433
- : renderDefaultLink(context)),
15434
- flyoutVisible && flyout));
15430
+ const handleMouseEnter = () => {
15431
+ setIsHovered(true);
15432
+ };
15433
+ const handleMouseLeave = () => {
15434
+ setIsHovered(false);
15435
+ };
15436
+ const flyoutPopper = (React__namespace.createElement(Popper, { reference: ref, popper: React__namespace.createElement("div", { ref: popperRef, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }, flyout), placement: "right-start", isVisible: flyoutVisible, onDocumentKeyDown: handleFlyout }));
15437
+ const navItem = (React__namespace.createElement(React__namespace.Fragment, null,
15438
+ React__namespace.createElement("li", Object.assign({ onMouseOver: onMouseOver, className: css(_default$w.navItem, hasFlyout && _default$w.modifiers.flyout, className), ref: ref }, ouiaProps),
15439
+ React__namespace.createElement(NavContext.Consumer, null, context => React__namespace.isValidElement(children)
15440
+ ? renderClonedChild(context, children)
15441
+ : renderDefaultLink(context))),
15442
+ flyout && flyoutPopper));
15443
+ return navItem;
15435
15444
  };
15436
15445
  NavItem.displayName = 'NavItem';
15437
15446