@patternfly/react-core 4.198.0 → 4.198.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/CHANGELOG.md +35 -0
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +12 -3
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectOption.js +3 -1
- package/dist/esm/components/Select/SelectOption.js.map +1 -1
- package/dist/esm/components/Select/SelectToggle.js +1 -1
- package/dist/esm/components/Select/SelectToggle.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +12 -3
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/js/components/Select/SelectOption.js +3 -1
- package/dist/js/components/Select/SelectOption.js.map +1 -1
- package/dist/js/components/Select/SelectToggle.js +1 -1
- package/dist/js/components/Select/SelectToggle.js.map +1 -1
- package/dist/umd/react-core.js +16 -5
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +6 -6
- package/src/components/Nav/examples/Nav.md +5 -0
- package/src/components/Nav/examples/NavDrilldown.tsx +95 -0
- package/src/components/Nav/examples/nav.css +4 -2
- package/src/components/Select/Select.tsx +16 -6
- package/src/components/Select/SelectOption.tsx +3 -0
- package/src/components/Select/SelectToggle.tsx +1 -1
- package/src/demos/Nav.md +7 -8
- package/src/demos/examples/Nav/NavDrilldown.tsx +132 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.198.
|
|
3
|
+
"version": "4.198.4",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.49.
|
|
38
|
-
"@patternfly/react-styles": "^4.48.
|
|
39
|
-
"@patternfly/react-tokens": "^4.50.
|
|
37
|
+
"@patternfly/react-icons": "^4.49.4",
|
|
38
|
+
"@patternfly/react-styles": "^4.48.4",
|
|
39
|
+
"@patternfly/react-tokens": "^4.50.4",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
43
43
|
"tslib": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@patternfly/patternfly": "4.
|
|
46
|
+
"@patternfly/patternfly": "4.179.1",
|
|
47
47
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
49
49
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "90a7e5467db9ae81304af4eb5815a2a97346eac1"
|
|
64
64
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Nav, MenuContent, MenuItem, MenuList, DrilldownMenu, Menu } from '@patternfly/react-core';
|
|
4
|
+
|
|
5
|
+
interface MenuHeights {
|
|
6
|
+
[menuId: string]: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const subMenuTwo: JSX.Element = (
|
|
10
|
+
<DrilldownMenu id="subMenu-2">
|
|
11
|
+
<MenuItem itemId="subMenu-2-breadcrumb" direction="up">
|
|
12
|
+
SubMenu 1 - Item 1
|
|
13
|
+
</MenuItem>
|
|
14
|
+
<MenuItem itemId="subMenu-2_item-1" to="#subMenu-2_item-1">
|
|
15
|
+
SubMenu 2 - Item 1
|
|
16
|
+
</MenuItem>
|
|
17
|
+
<MenuItem itemId="subMenu-2_item-2" to="#subMenu-2_item-2">
|
|
18
|
+
SubMenu 2 - Item 2
|
|
19
|
+
</MenuItem>
|
|
20
|
+
<MenuItem itemId="subMenu-2_item-3" to="#subMenu-2_item-3">
|
|
21
|
+
SubMenu 2 - Item 3
|
|
22
|
+
</MenuItem>
|
|
23
|
+
</DrilldownMenu>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const subMenuOne: JSX.Element = (
|
|
27
|
+
<DrilldownMenu id="subMenu-1">
|
|
28
|
+
<MenuItem itemId="subMenu-1-breadcrumb" direction="up">
|
|
29
|
+
Item 1
|
|
30
|
+
</MenuItem>
|
|
31
|
+
<MenuItem itemId="subMenu-1_item-1" description="SubMenu 2" direction="down" drilldownMenu={subMenuTwo}>
|
|
32
|
+
SubMenu 1 - Item 1
|
|
33
|
+
</MenuItem>
|
|
34
|
+
<MenuItem itemId="subMenu-1_item-2" to="#subMenu-1_item-2">
|
|
35
|
+
SubMenu 1 - Item 2
|
|
36
|
+
</MenuItem>
|
|
37
|
+
<MenuItem itemId="subMenu-1_item-3" to="#subMenu-1_item-3">
|
|
38
|
+
SubMenu 1 - Item 3
|
|
39
|
+
</MenuItem>
|
|
40
|
+
</DrilldownMenu>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
export const NavLevelThreeDrill: React.FunctionComponent = () => {
|
|
44
|
+
const [menuDrilledIn, setMenuDrilledIn] = React.useState<string[]>([]);
|
|
45
|
+
const [drilldownPath, setDrilldownPath] = React.useState<string[]>([]);
|
|
46
|
+
const [menuHeights, setMenuHeights] = React.useState<MenuHeights>({});
|
|
47
|
+
const [activeMenu, setActiveMenu] = React.useState('rootMenu');
|
|
48
|
+
|
|
49
|
+
const onDrillIn = (fromItemId: string, toItemId: string, itemId: string) => {
|
|
50
|
+
setMenuDrilledIn(prevMenuDrilledIn => [...prevMenuDrilledIn, fromItemId]);
|
|
51
|
+
setDrilldownPath(prevDrilldownPath => [...prevDrilldownPath, itemId]);
|
|
52
|
+
setActiveMenu(toItemId);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const onDrillOut = (toItemId: string, _itemId: string) => {
|
|
56
|
+
setMenuDrilledIn(prevMenuDrilledIn => prevMenuDrilledIn.slice(0, prevMenuDrilledIn.length - 1));
|
|
57
|
+
setDrilldownPath(prevDrilldownPath => prevDrilldownPath.slice(0, prevDrilldownPath.length - 1));
|
|
58
|
+
setActiveMenu(toItemId);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const onGetMenuHeight = (menuId: string, height: number) => {
|
|
62
|
+
if (!menuHeights[menuId] && menuId !== 'rootMenu') {
|
|
63
|
+
setMenuHeights(prevMenuHeights => ({ ...prevMenuHeights, [menuId]: height }));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Nav>
|
|
69
|
+
<Menu
|
|
70
|
+
id="rootMenu"
|
|
71
|
+
containsDrilldown
|
|
72
|
+
drilldownItemPath={drilldownPath}
|
|
73
|
+
drilledInMenus={menuDrilledIn}
|
|
74
|
+
activeMenu={activeMenu}
|
|
75
|
+
onDrillIn={onDrillIn}
|
|
76
|
+
onDrillOut={onDrillOut}
|
|
77
|
+
onGetMenuHeight={onGetMenuHeight}
|
|
78
|
+
>
|
|
79
|
+
<MenuContent menuHeight={`${menuHeights[activeMenu]}px`}>
|
|
80
|
+
<MenuList>
|
|
81
|
+
<MenuItem itemId="item-1" direction="down" description="SubMenu 1" drilldownMenu={subMenuOne}>
|
|
82
|
+
Item 1
|
|
83
|
+
</MenuItem>
|
|
84
|
+
<MenuItem itemId="item-2" to="#item-2">
|
|
85
|
+
Item 2
|
|
86
|
+
</MenuItem>
|
|
87
|
+
<MenuItem itemId="item-3" to="#item-3">
|
|
88
|
+
Item 3
|
|
89
|
+
</MenuItem>
|
|
90
|
+
</MenuList>
|
|
91
|
+
</MenuContent>
|
|
92
|
+
</Menu>
|
|
93
|
+
</Nav>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
#ws-react-c-navigation-mixed,
|
|
7
7
|
#ws-react-c-navigation-expandable-third-level,
|
|
8
8
|
#ws-react-c-navigation-horizontal-subnav,
|
|
9
|
-
#ws-react-c-navigation-flyout
|
|
9
|
+
#ws-react-c-navigation-flyout,
|
|
10
|
+
#ws-react-c-navigation-drilldown {
|
|
10
11
|
background-color: var(--pf-global--BackgroundColor--dark-300);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
#ws-react-c-navigation-flyout
|
|
14
|
+
#ws-react-c-navigation-flyout,
|
|
15
|
+
#ws-react-c-navigation-drilldown {
|
|
14
16
|
width: 300px;
|
|
15
17
|
}
|
|
@@ -261,10 +261,8 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
|
|
|
261
261
|
if (firstRef && firstRef[0]) {
|
|
262
262
|
firstRef[0].focus();
|
|
263
263
|
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// if viewMoreNextIndex is not -1, view more was clicked, set focus on first newly loaded item
|
|
267
|
-
if (
|
|
264
|
+
} else if (
|
|
265
|
+
// if viewMoreNextIndex is not -1, view more was clicked, set focus on first newly loaded item
|
|
268
266
|
this.state.viewMoreNextIndex !== -1 &&
|
|
269
267
|
this.refCollection.length > this.state.viewMoreNextIndex &&
|
|
270
268
|
this.props.loadingVariant !== 'spinner' &&
|
|
@@ -352,7 +350,8 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
|
|
|
352
350
|
typeaheadFilteredChildren: React.Children.toArray(this.props.children)
|
|
353
351
|
}),
|
|
354
352
|
typeaheadCurrIndex: -1,
|
|
355
|
-
tabbedIntoFavoritesMenu: false
|
|
353
|
+
tabbedIntoFavoritesMenu: false,
|
|
354
|
+
viewMoreNextIndex: -1
|
|
356
355
|
});
|
|
357
356
|
};
|
|
358
357
|
|
|
@@ -385,7 +384,8 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
|
|
|
385
384
|
noResultsFoundText,
|
|
386
385
|
children,
|
|
387
386
|
isGrouped,
|
|
388
|
-
isCreateSelectOptionObject
|
|
387
|
+
isCreateSelectOptionObject,
|
|
388
|
+
loadingVariant
|
|
389
389
|
} = this.props;
|
|
390
390
|
|
|
391
391
|
if (onFilter) {
|
|
@@ -439,6 +439,16 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
|
|
|
439
439
|
(valueToCheck as SelectOptionObject).toString &&
|
|
440
440
|
(valueToCheck as SelectOptionObject).compareTo;
|
|
441
441
|
|
|
442
|
+
// View more option should be returned as not a match
|
|
443
|
+
if (loadingVariant !== 'spinner' && loadingVariant?.text === valueToCheck) {
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// spinner should be returned as not a match
|
|
448
|
+
if (loadingVariant === 'spinner' && valueToCheck === 'loading') {
|
|
449
|
+
return true;
|
|
450
|
+
}
|
|
451
|
+
|
|
442
452
|
if (isSelectOptionObject) {
|
|
443
453
|
return (valueToCheck as SelectOptionObject).compareTo(typeaheadInputValue);
|
|
444
454
|
} else {
|
|
@@ -297,6 +297,9 @@ export class SelectOption extends React.Component<SelectOptionProps> {
|
|
|
297
297
|
event.stopPropagation();
|
|
298
298
|
}}
|
|
299
299
|
ref={this.ref}
|
|
300
|
+
onKeyDown={(event: React.KeyboardEvent) => {
|
|
301
|
+
this.onKeyDown(event, 0);
|
|
302
|
+
}}
|
|
300
303
|
type="button"
|
|
301
304
|
>
|
|
302
305
|
{itemDisplay}
|
|
@@ -162,7 +162,7 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
|
|
|
162
162
|
}
|
|
163
163
|
// Current element is in footer.
|
|
164
164
|
if (event.shiftKey) {
|
|
165
|
-
// Move focus back to
|
|
165
|
+
// Move focus back to menu if current tab index is 0
|
|
166
166
|
if (currentElementIndex === 0) {
|
|
167
167
|
moveFocusToLastMenuItem();
|
|
168
168
|
event.preventDefault();
|
package/src/demos/Nav.md
CHANGED
|
@@ -1439,7 +1439,7 @@ class VerticalPage extends React.Component {
|
|
|
1439
1439
|
super(props);
|
|
1440
1440
|
this.state = {
|
|
1441
1441
|
isNavOpen: true,
|
|
1442
|
-
activeItem: 0
|
|
1442
|
+
activeItem: 0
|
|
1443
1443
|
};
|
|
1444
1444
|
this.onNavSelect = result => {
|
|
1445
1445
|
this.setState({
|
|
@@ -1489,13 +1489,7 @@ class VerticalPage extends React.Component {
|
|
|
1489
1489
|
<NavItem id="flyout-link1" to="#flyout-link1" itemId={0} isActive={activeItem === 0}>
|
|
1490
1490
|
System Panel
|
|
1491
1491
|
</NavItem>
|
|
1492
|
-
<NavItem
|
|
1493
|
-
flyout={curFlyout}
|
|
1494
|
-
id="flyout-link2"
|
|
1495
|
-
to="#flyout-link2"
|
|
1496
|
-
itemId={1}
|
|
1497
|
-
isActive={activeItem === 1}
|
|
1498
|
-
>
|
|
1492
|
+
<NavItem flyout={curFlyout} id="flyout-link2" to="#flyout-link2" itemId={1} isActive={activeItem === 1}>
|
|
1499
1493
|
Settings
|
|
1500
1494
|
</NavItem>
|
|
1501
1495
|
<NavItem id="flyout-link3" to="#flyout-link3" itemId={2} isActive={activeItem === 2}>
|
|
@@ -1517,3 +1511,8 @@ class VerticalPage extends React.Component {
|
|
|
1517
1511
|
}
|
|
1518
1512
|
}
|
|
1519
1513
|
```
|
|
1514
|
+
|
|
1515
|
+
### Drilldown nav
|
|
1516
|
+
|
|
1517
|
+
```js isBeta isFullscreen file="./examples/Nav/NavDrilldown.tsx"
|
|
1518
|
+
```
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Page,
|
|
5
|
+
PageSidebar,
|
|
6
|
+
Nav,
|
|
7
|
+
MenuContent,
|
|
8
|
+
MenuItem,
|
|
9
|
+
MenuList,
|
|
10
|
+
DrilldownMenu,
|
|
11
|
+
Menu,
|
|
12
|
+
PageSection
|
|
13
|
+
} from '@patternfly/react-core';
|
|
14
|
+
|
|
15
|
+
import DashboardHeader from '../DashboardHeader';
|
|
16
|
+
|
|
17
|
+
interface MenuHeights {
|
|
18
|
+
[menuId: string]: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getNavLayer(menuId: string): number {
|
|
22
|
+
switch (menuId) {
|
|
23
|
+
case 'rootMenu':
|
|
24
|
+
return 1;
|
|
25
|
+
case 'subMenu-1':
|
|
26
|
+
return 2;
|
|
27
|
+
case 'subMenu-2':
|
|
28
|
+
return 3;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const subMenuTwo: JSX.Element = (
|
|
33
|
+
<DrilldownMenu id="subMenu-2">
|
|
34
|
+
<MenuItem itemId="subMenu-2-breadcrumb" direction="up">
|
|
35
|
+
SubMenu 1 - Item 1
|
|
36
|
+
</MenuItem>
|
|
37
|
+
<MenuItem itemId="subMenu-2_item-1" to="#subMenu-2_item-1">
|
|
38
|
+
SubMenu 2 - Item 1
|
|
39
|
+
</MenuItem>
|
|
40
|
+
<MenuItem itemId="subMenu-2_item-2" to="#subMenu-2_item-2">
|
|
41
|
+
SubMenu 2 - Item 2
|
|
42
|
+
</MenuItem>
|
|
43
|
+
<MenuItem itemId="subMenu-2_item-3" to="#subMenu-2_item-3">
|
|
44
|
+
SubMenu 2 - Item 3
|
|
45
|
+
</MenuItem>
|
|
46
|
+
</DrilldownMenu>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const subMenuOne: JSX.Element = (
|
|
50
|
+
<DrilldownMenu id="subMenu-1">
|
|
51
|
+
<MenuItem itemId="subMenu-1-breadcrumb" direction="up">
|
|
52
|
+
Item 1
|
|
53
|
+
</MenuItem>
|
|
54
|
+
<MenuItem itemId="subMenu-1_item-1" description="SubMenu 2" direction="down" drilldownMenu={subMenuTwo}>
|
|
55
|
+
SubMenu 1 - Item 1
|
|
56
|
+
</MenuItem>
|
|
57
|
+
<MenuItem itemId="subMenu-1_item-2" to="#subMenu-1_item-2">
|
|
58
|
+
SubMenu 1 - Item 2
|
|
59
|
+
</MenuItem>
|
|
60
|
+
<MenuItem itemId="subMenu-1_item-3" to="#subMenu-1_item-3">
|
|
61
|
+
SubMenu 1 - Item 3
|
|
62
|
+
</MenuItem>
|
|
63
|
+
</DrilldownMenu>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
export const NavDrilldown: React.FunctionComponent = () => {
|
|
67
|
+
const [menuDrilledIn, setMenuDrilledIn] = React.useState<string[]>([]);
|
|
68
|
+
const [drilldownPath, setDrilldownPath] = React.useState<string[]>([]);
|
|
69
|
+
const [menuHeights, setMenuHeights] = React.useState<MenuHeights>({});
|
|
70
|
+
const [activeMenuId, setActiveMenuId] = React.useState('rootMenu');
|
|
71
|
+
const navLayer = getNavLayer(activeMenuId);
|
|
72
|
+
|
|
73
|
+
const onDrillIn = (fromItemId: string, toItemId: string, itemId: string) => {
|
|
74
|
+
setMenuDrilledIn(prevMenuDrilledIn => [...prevMenuDrilledIn, fromItemId]);
|
|
75
|
+
setDrilldownPath(prevDrilldownPath => [...prevDrilldownPath, itemId]);
|
|
76
|
+
setActiveMenuId(toItemId);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const onDrillOut = (toItemId: string, _itemId: string) => {
|
|
80
|
+
setMenuDrilledIn(prevMenuDrilledIn => prevMenuDrilledIn.slice(0, prevMenuDrilledIn.length - 1));
|
|
81
|
+
setDrilldownPath(prevDrilldownPath => prevDrilldownPath.slice(0, prevDrilldownPath.length - 1));
|
|
82
|
+
setActiveMenuId(toItemId);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const onGetMenuHeight = (menuId: string, height: number) => {
|
|
86
|
+
if (!menuHeights[menuId] && menuId !== 'rootMenu') {
|
|
87
|
+
setMenuHeights(prevMenuHeights => ({ ...prevMenuHeights, [menuId]: height }));
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const sidebar = (
|
|
92
|
+
<PageSidebar
|
|
93
|
+
nav={
|
|
94
|
+
<Nav>
|
|
95
|
+
<Menu
|
|
96
|
+
id="rootMenu"
|
|
97
|
+
containsDrilldown
|
|
98
|
+
drilldownItemPath={drilldownPath}
|
|
99
|
+
drilledInMenus={menuDrilledIn}
|
|
100
|
+
activeMenu={activeMenuId}
|
|
101
|
+
onDrillIn={onDrillIn}
|
|
102
|
+
onDrillOut={onDrillOut}
|
|
103
|
+
onGetMenuHeight={onGetMenuHeight}
|
|
104
|
+
>
|
|
105
|
+
<MenuContent menuHeight={`${menuHeights[activeMenuId]}px`}>
|
|
106
|
+
<MenuList>
|
|
107
|
+
<MenuItem itemId="item-1" direction="down" description="SubMenu 1" drilldownMenu={subMenuOne}>
|
|
108
|
+
Item 1
|
|
109
|
+
</MenuItem>
|
|
110
|
+
<MenuItem itemId="item-2" to="#item-2">
|
|
111
|
+
Item 2
|
|
112
|
+
</MenuItem>
|
|
113
|
+
<MenuItem itemId="item-3" to="#item-3">
|
|
114
|
+
Item 3
|
|
115
|
+
</MenuItem>
|
|
116
|
+
</MenuList>
|
|
117
|
+
</MenuContent>
|
|
118
|
+
</Menu>
|
|
119
|
+
</Nav>
|
|
120
|
+
}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<Page header={<DashboardHeader />} sidebar={sidebar}>
|
|
126
|
+
<PageSection>
|
|
127
|
+
<strong>Nav Layer: </strong>
|
|
128
|
+
{navLayer}
|
|
129
|
+
</PageSection>
|
|
130
|
+
</Page>
|
|
131
|
+
);
|
|
132
|
+
};
|