@patternfly/react-core 4.161.1 → 4.162.1
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/CHANGELOG.md +35 -0
- package/dist/esm/components/DualListSelector/DualListSelectorControl.d.ts +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorControlsWrapper.d.ts +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorListItem.d.ts +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorListWrapper.d.ts +1 -1
- package/dist/esm/components/Nav/Nav.d.ts +4 -0
- package/dist/esm/components/Nav/Nav.d.ts.map +1 -1
- package/dist/esm/components/Nav/Nav.js +5 -2
- package/dist/esm/components/Nav/Nav.js.map +1 -1
- package/dist/esm/components/Nav/NavItem.d.ts +4 -0
- package/dist/esm/components/Nav/NavItem.d.ts.map +1 -1
- package/dist/esm/components/Nav/NavItem.js +96 -6
- package/dist/esm/components/Nav/NavItem.js.map +1 -1
- package/dist/esm/components/Nav/NavList.d.ts +2 -0
- package/dist/esm/components/Nav/NavList.d.ts.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorControl.d.ts +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorControlsWrapper.d.ts +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorListItem.d.ts +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorListWrapper.d.ts +1 -1
- package/dist/js/components/Nav/Nav.d.ts +4 -0
- package/dist/js/components/Nav/Nav.d.ts.map +1 -1
- package/dist/js/components/Nav/Nav.js +5 -2
- package/dist/js/components/Nav/Nav.js.map +1 -1
- package/dist/js/components/Nav/NavItem.d.ts +4 -0
- package/dist/js/components/Nav/NavItem.d.ts.map +1 -1
- package/dist/js/components/Nav/NavItem.js +96 -6
- package/dist/js/components/Nav/NavItem.js.map +1 -1
- package/dist/js/components/Nav/NavList.d.ts +2 -0
- package/dist/js/components/Nav/NavList.d.ts.map +1 -1
- package/dist/umd/react-core.css +9093 -9048
- package/dist/umd/react-core.js +103 -8
- package/dist/umd/react-core.min.css +9357 -9313
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +6 -6
- package/src/components/Nav/Nav.tsx +11 -3
- package/src/components/Nav/NavItem.tsx +124 -3
- package/src/components/Nav/__tests__/Generated/__snapshots__/Nav.test.tsx.snap +2 -0
- package/src/components/Nav/__tests__/Generated/__snapshots__/NavItem.test.tsx.snap +1 -0
- package/src/components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap +49 -0
- package/src/components/Nav/examples/Nav.md +69 -0
- package/src/components/Nav/examples/nav.css +6 -1
- package/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +15 -0
package/dist/umd/react-core.js
CHANGED
|
@@ -14440,6 +14440,7 @@
|
|
|
14440
14440
|
"divider": "pf-c-divider",
|
|
14441
14441
|
"menu": "pf-c-menu",
|
|
14442
14442
|
"menuItem": "pf-c-menu__item",
|
|
14443
|
+
"menuListItem": "pf-c-menu__list-item",
|
|
14443
14444
|
"modifiers": {
|
|
14444
14445
|
"horizontal": "pf-m-horizontal",
|
|
14445
14446
|
"tertiary": "pf-m-tertiary",
|
|
@@ -14449,6 +14450,8 @@
|
|
|
14449
14450
|
"overflowHidden": "pf-m-overflow-hidden",
|
|
14450
14451
|
"expandable": "pf-m-expandable",
|
|
14451
14452
|
"flyout": "pf-m-flyout",
|
|
14453
|
+
"top": "pf-m-top",
|
|
14454
|
+
"left": "pf-m-left",
|
|
14452
14455
|
"drilldown": "pf-m-drilldown",
|
|
14453
14456
|
"expanded": "pf-m-expanded",
|
|
14454
14457
|
"current": "pf-m-current",
|
|
@@ -14472,7 +14475,8 @@
|
|
|
14472
14475
|
super(...arguments);
|
|
14473
14476
|
this.state = {
|
|
14474
14477
|
isScrollable: false,
|
|
14475
|
-
ouiaStateId: getDefaultOUIAId(Nav.displayName, this.props.variant)
|
|
14478
|
+
ouiaStateId: getDefaultOUIAId(Nav.displayName, this.props.variant),
|
|
14479
|
+
flyoutRef: null
|
|
14476
14480
|
};
|
|
14477
14481
|
}
|
|
14478
14482
|
// Callback from NavItem
|
|
@@ -14504,7 +14508,9 @@
|
|
|
14504
14508
|
onSelect: (event, groupId, itemId, to, preventDefault, onClick) => this.onSelect(event, groupId, itemId, to, preventDefault, onClick),
|
|
14505
14509
|
onToggle: (event, groupId, expanded) => this.onToggle(event, groupId, expanded),
|
|
14506
14510
|
updateIsScrollable: (isScrollable) => this.setState({ isScrollable }),
|
|
14507
|
-
isHorizontal: ['horizontal', 'tertiary', 'horizontal-subnav'].includes(variant)
|
|
14511
|
+
isHorizontal: ['horizontal', 'tertiary', 'horizontal-subnav'].includes(variant),
|
|
14512
|
+
flyoutRef: this.state.flyoutRef,
|
|
14513
|
+
setFlyoutRef: flyoutRef => this.setState({ flyoutRef })
|
|
14508
14514
|
} },
|
|
14509
14515
|
React__namespace.createElement("nav", Object.assign({ className: css(_default$u.nav, theme === 'light' && _default$u.modifiers.light, isHorizontal && _default$u.modifiers.horizontal, variant === 'tertiary' && _default$u.modifiers.tertiary, variant === 'horizontal-subnav' && _default$u.modifiers.horizontalSubnav, this.state.isScrollable && _default$u.modifiers.scrollable, className), "aria-label": ariaLabel || (variant === 'tertiary' ? 'Local' : 'Global') }, getOUIAProps(Nav.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe), props), children)));
|
|
14510
14516
|
}
|
|
@@ -14862,21 +14868,110 @@
|
|
|
14862
14868
|
NavGroup.displayName = 'NavGroup';
|
|
14863
14869
|
|
|
14864
14870
|
const NavItem = (_a) => {
|
|
14865
|
-
var { children, styleChildren = true, className, to, isActive = false, groupId = null, itemId = null, preventDefault = false, onClick = null, component = 'a', ouiaId, ouiaSafe } = _a, props = __rest$1(_a, ["children", "styleChildren", "className", "to", "isActive", "groupId", "itemId", "preventDefault", "onClick", "component", "ouiaId", "ouiaSafe"]);
|
|
14866
|
-
const
|
|
14871
|
+
var { children, styleChildren = true, className, to, isActive = false, groupId = null, itemId = null, preventDefault = false, onClick = null, component = 'a', flyout, onShowFlyout, ouiaId, ouiaSafe } = _a, props = __rest$1(_a, ["children", "styleChildren", "className", "to", "isActive", "groupId", "itemId", "preventDefault", "onClick", "component", "flyout", "onShowFlyout", "ouiaId", "ouiaSafe"]);
|
|
14872
|
+
const { flyoutRef, setFlyoutRef } = React__namespace.useContext(NavContext);
|
|
14867
14873
|
const { isNavOpen } = React__namespace.useContext(PageSidebarContext);
|
|
14874
|
+
const [flyoutTarget, setFlyoutTarget] = React__namespace.useState(null);
|
|
14875
|
+
const ref = React__namespace.useRef();
|
|
14876
|
+
const flyoutVisible = ref === flyoutRef;
|
|
14877
|
+
const Component = component;
|
|
14878
|
+
const hasFlyout = flyout !== undefined;
|
|
14879
|
+
const showFlyout = (show, override) => {
|
|
14880
|
+
if ((!flyoutVisible || override) && show) {
|
|
14881
|
+
setFlyoutRef(ref);
|
|
14882
|
+
}
|
|
14883
|
+
else if ((flyoutVisible || override) && !show) {
|
|
14884
|
+
setFlyoutRef(null);
|
|
14885
|
+
}
|
|
14886
|
+
onShowFlyout && show && onShowFlyout();
|
|
14887
|
+
};
|
|
14888
|
+
const onMouseOver = (event) => {
|
|
14889
|
+
const evtContainedInFlyout = event.target.closest('.pf-c-nav__item.pf-m-flyout');
|
|
14890
|
+
if (hasFlyout && !flyoutVisible) {
|
|
14891
|
+
showFlyout(true);
|
|
14892
|
+
}
|
|
14893
|
+
else if (flyoutRef !== null && !evtContainedInFlyout) {
|
|
14894
|
+
setFlyoutRef(null);
|
|
14895
|
+
}
|
|
14896
|
+
};
|
|
14897
|
+
const onFlyoutClick = (event) => {
|
|
14898
|
+
const target = event.target;
|
|
14899
|
+
const closestItem = target.closest('.pf-m-flyout');
|
|
14900
|
+
if (!closestItem) {
|
|
14901
|
+
if (hasFlyout) {
|
|
14902
|
+
showFlyout(false, true);
|
|
14903
|
+
}
|
|
14904
|
+
else if (flyoutRef !== null) {
|
|
14905
|
+
setFlyoutRef(null);
|
|
14906
|
+
}
|
|
14907
|
+
}
|
|
14908
|
+
};
|
|
14909
|
+
React__namespace.useEffect(() => {
|
|
14910
|
+
if (hasFlyout) {
|
|
14911
|
+
window.addEventListener('click', onFlyoutClick);
|
|
14912
|
+
}
|
|
14913
|
+
return () => {
|
|
14914
|
+
if (hasFlyout) {
|
|
14915
|
+
window.removeEventListener('click', onFlyoutClick);
|
|
14916
|
+
}
|
|
14917
|
+
};
|
|
14918
|
+
}, []);
|
|
14919
|
+
React__namespace.useEffect(() => {
|
|
14920
|
+
if (flyoutTarget) {
|
|
14921
|
+
if (flyoutVisible) {
|
|
14922
|
+
const flyoutMenu = flyoutTarget.nextElementSibling;
|
|
14923
|
+
const flyoutItems = Array.from(flyoutMenu.getElementsByTagName('UL')[0].children).filter(el => !(el.classList.contains('pf-m-disabled') || el.classList.contains('pf-c-divider')));
|
|
14924
|
+
flyoutItems[0].firstChild.focus();
|
|
14925
|
+
}
|
|
14926
|
+
else {
|
|
14927
|
+
flyoutTarget.focus();
|
|
14928
|
+
}
|
|
14929
|
+
}
|
|
14930
|
+
}, [flyoutVisible, flyoutTarget]);
|
|
14931
|
+
const handleFlyout = (event) => {
|
|
14932
|
+
const key = event.key;
|
|
14933
|
+
const target = event.target;
|
|
14934
|
+
if (!hasFlyout) {
|
|
14935
|
+
return;
|
|
14936
|
+
}
|
|
14937
|
+
if (key === ' ' || key === 'ArrowRight') {
|
|
14938
|
+
event.stopPropagation();
|
|
14939
|
+
event.preventDefault();
|
|
14940
|
+
if (!flyoutVisible) {
|
|
14941
|
+
showFlyout(true);
|
|
14942
|
+
setFlyoutTarget(target);
|
|
14943
|
+
}
|
|
14944
|
+
}
|
|
14945
|
+
if (key === 'Escape' || key === 'ArrowLeft') {
|
|
14946
|
+
if (flyoutVisible) {
|
|
14947
|
+
event.stopPropagation();
|
|
14948
|
+
event.preventDefault();
|
|
14949
|
+
showFlyout(false);
|
|
14950
|
+
}
|
|
14951
|
+
}
|
|
14952
|
+
};
|
|
14953
|
+
const flyoutButton = (React__namespace.createElement("span", { className: css(_default$u.navToggle) },
|
|
14954
|
+
React__namespace.createElement("span", { className: css(_default$u.navToggleIcon) },
|
|
14955
|
+
React__namespace.createElement(AngleRightIcon$1, { "aria-hidden": true }))));
|
|
14868
14956
|
const renderDefaultLink = (context) => {
|
|
14869
14957
|
const preventLinkDefault = preventDefault || !to;
|
|
14870
|
-
return (React__namespace.createElement(Component, Object.assign({ href: to, onClick: (e) => context.onSelect(e, groupId, itemId, to, preventLinkDefault, onClick), className: css(_default$u.navLink, isActive && _default$u.modifiers.current, className), "aria-current": isActive ? 'page' : null, tabIndex: isNavOpen ? null : '-1' }, props),
|
|
14958
|
+
return (React__namespace.createElement(Component, Object.assign({ href: to, onClick: (e) => context.onSelect(e, groupId, itemId, to, preventLinkDefault, onClick), className: css(_default$u.navLink, isActive && _default$u.modifiers.current, className), "aria-current": isActive ? 'page' : null, tabIndex: isNavOpen ? null : '-1' }, props),
|
|
14959
|
+
children,
|
|
14960
|
+
flyout && flyoutButton));
|
|
14871
14961
|
};
|
|
14872
14962
|
const renderClonedChild = (context, child) => React__namespace.cloneElement(child, Object.assign(Object.assign({ onClick: (e) => context.onSelect(e, groupId, itemId, to, preventDefault, onClick), 'aria-current': isActive ? 'page' : null }, (styleChildren && {
|
|
14873
14963
|
className: css(_default$u.navLink, isActive && _default$u.modifiers.current, child.props && child.props.className)
|
|
14874
|
-
})), { tabIndex: child.props.tabIndex || isNavOpen ? null : -1
|
|
14964
|
+
})), { tabIndex: child.props.tabIndex || isNavOpen ? null : -1, children: hasFlyout ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
14965
|
+
child.props.children,
|
|
14966
|
+
flyoutButton)) : (child.props.children) }));
|
|
14875
14967
|
const ouiaProps = useOUIAProps(NavItem.displayName, ouiaId, ouiaSafe);
|
|
14876
|
-
return (React__namespace.createElement("li", Object.assign({
|
|
14968
|
+
return (React__namespace.createElement("li", Object.assign({}, (hasFlyout && {
|
|
14969
|
+
onKeyDown: handleFlyout
|
|
14970
|
+
}), { onMouseOver: onMouseOver, className: css(_default$u.navItem, hasFlyout && _default$u.modifiers.flyout, className), ref: ref }, ouiaProps),
|
|
14877
14971
|
React__namespace.createElement(NavContext.Consumer, null, context => React__namespace.isValidElement(children)
|
|
14878
14972
|
? renderClonedChild(context, children)
|
|
14879
|
-
: renderDefaultLink(context))
|
|
14973
|
+
: renderDefaultLink(context)),
|
|
14974
|
+
flyoutVisible && flyout));
|
|
14880
14975
|
};
|
|
14881
14976
|
NavItem.displayName = 'NavItem';
|
|
14882
14977
|
|