@patternfly/react-core 4.227.9 → 4.229.0
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 +33 -0
- package/dist/esm/components/DescriptionList/DescriptionList.d.ts +4 -0
- package/dist/esm/components/DescriptionList/DescriptionList.d.ts.map +1 -1
- package/dist/esm/components/DescriptionList/DescriptionList.js +5 -2
- package/dist/esm/components/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/esm/components/DescriptionList/DescriptionListGroup.js.map +1 -1
- package/dist/esm/components/Menu/MenuItem.d.ts.map +1 -1
- package/dist/esm/components/Menu/MenuItem.js +5 -3
- package/dist/esm/components/Menu/MenuItem.js.map +1 -1
- package/dist/esm/components/Nav/NavItem.d.ts.map +1 -1
- package/dist/esm/components/Nav/NavItem.js +5 -1
- package/dist/esm/components/Nav/NavItem.js.map +1 -1
- package/dist/esm/components/Tabs/OverflowTab.d.ts +16 -0
- package/dist/esm/components/Tabs/OverflowTab.d.ts.map +1 -0
- package/dist/esm/components/Tabs/OverflowTab.js +74 -0
- package/dist/esm/components/Tabs/OverflowTab.js.map +1 -0
- package/dist/esm/components/Tabs/Tabs.d.ts +12 -0
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +36 -13
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/TreeView/TreeView.d.ts +2 -0
- package/dist/esm/components/TreeView/TreeView.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeView.js +3 -3
- package/dist/esm/components/TreeView/TreeView.js.map +1 -1
- package/dist/esm/components/TreeView/TreeViewListItem.d.ts +2 -0
- package/dist/esm/components/TreeView/TreeViewListItem.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeViewListItem.js +23 -14
- package/dist/esm/components/TreeView/TreeViewListItem.js.map +1 -1
- package/dist/js/components/DescriptionList/DescriptionList.d.ts +4 -0
- package/dist/js/components/DescriptionList/DescriptionList.d.ts.map +1 -1
- package/dist/js/components/DescriptionList/DescriptionList.js +5 -2
- package/dist/js/components/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/js/components/DescriptionList/DescriptionListGroup.js.map +1 -1
- package/dist/js/components/Menu/MenuItem.d.ts.map +1 -1
- package/dist/js/components/Menu/MenuItem.js +5 -3
- package/dist/js/components/Menu/MenuItem.js.map +1 -1
- package/dist/js/components/Nav/NavItem.d.ts.map +1 -1
- package/dist/js/components/Nav/NavItem.js +5 -1
- package/dist/js/components/Nav/NavItem.js.map +1 -1
- package/dist/js/components/Tabs/OverflowTab.d.ts +16 -0
- package/dist/js/components/Tabs/OverflowTab.d.ts.map +1 -0
- package/dist/js/components/Tabs/OverflowTab.js +78 -0
- package/dist/js/components/Tabs/OverflowTab.js.map +1 -0
- package/dist/js/components/Tabs/Tabs.d.ts +12 -0
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +36 -13
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/components/TreeView/TreeView.d.ts +2 -0
- package/dist/js/components/TreeView/TreeView.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeView.js +3 -3
- package/dist/js/components/TreeView/TreeView.js.map +1 -1
- package/dist/js/components/TreeView/TreeViewListItem.d.ts +2 -0
- package/dist/js/components/TreeView/TreeViewListItem.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeViewListItem.js +23 -14
- package/dist/js/components/TreeView/TreeViewListItem.js.map +1 -1
- package/dist/styles/base-no-reset.css +9 -0
- package/dist/styles/base.css +9 -0
- package/dist/umd/react-core.css +37 -44
- package/dist/umd/react-core.js +147 -42
- package/dist/umd/react-core.min.css +6 -13
- package/dist/umd/react-core.min.js +4 -4
- package/package.json +6 -6
- package/src/components/DescriptionList/DescriptionList.tsx +14 -0
- package/src/components/DescriptionList/DescriptionListGroup.tsx +1 -0
- package/src/components/DescriptionList/examples/DescriptionList.md +31 -1
- package/src/components/DescriptionList/examples/DescriptionListDisplaySizeAndCard.tsx +63 -0
- package/src/components/DescriptionList/examples/DescriptionListDisplaySizeAndCardHorizontalTermWidth.tsx +34 -0
- package/src/components/DescriptionList/examples/DescriptionListDisplaySizeAndCardThreeColumn.tsx +34 -0
- package/src/components/DescriptionList/examples/DescriptionListWithCard.tsx +62 -0
- package/src/components/DescriptionList/examples/DescriptionListWithDisplaySize.tsx +63 -0
- package/src/components/Menu/MenuItem.tsx +7 -5
- package/src/components/Nav/NavItem.tsx +6 -0
- package/src/components/Tabs/OverflowTab.tsx +141 -0
- package/src/components/Tabs/Tabs.tsx +72 -25
- package/src/components/Tabs/examples/Tabs.md +6 -1
- package/src/components/Tabs/examples/TabsHorizontalOverflow.tsx +67 -0
- package/src/components/TreeView/TreeView.tsx +5 -0
- package/src/components/TreeView/TreeViewListItem.tsx +31 -17
- package/src/components/TreeView/__tests__/__snapshots__/TreeView.test.tsx.snap +299 -299
- package/src/components/TreeView/examples/TreeView.md +125 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.229.0",
|
|
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.
|
|
38
|
-
"@patternfly/react-styles": "^4.
|
|
39
|
-
"@patternfly/react-tokens": "^4.
|
|
37
|
+
"@patternfly/react-icons": "^4.80.0",
|
|
38
|
+
"@patternfly/react-styles": "^4.79.0",
|
|
39
|
+
"@patternfly/react-tokens": "^4.81.0",
|
|
40
40
|
"focus-trap": "6.9.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.206.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": "6f68aa3d05370ed0e088e00b2a780f2babe64dd6"
|
|
64
64
|
}
|
|
@@ -30,6 +30,8 @@ export interface DescriptionListProps extends Omit<React.HTMLProps<HTMLDListElem
|
|
|
30
30
|
isFluid?: boolean;
|
|
31
31
|
/** Sets the the default placement of description list groups to fill from top to bottom. */
|
|
32
32
|
isFillColumns?: boolean;
|
|
33
|
+
/** Sets the display size of the descriptions in the description list.*/
|
|
34
|
+
displaySize?: 'lg' | '2xl';
|
|
33
35
|
/** Sets the number of columns on the description list at various breakpoints */
|
|
34
36
|
columnModifier?: {
|
|
35
37
|
default?: '1Col' | '2Col' | '3Col';
|
|
@@ -56,6 +58,8 @@ export interface DescriptionListProps extends Omit<React.HTMLProps<HTMLDListElem
|
|
|
56
58
|
xl?: string;
|
|
57
59
|
'2xl'?: string;
|
|
58
60
|
};
|
|
61
|
+
/** Sets the description list's term column width.*/
|
|
62
|
+
termWidth?: string;
|
|
59
63
|
/** Sets the horizontal description list's term column width at various breakpoints. */
|
|
60
64
|
horizontalTermWidthModifier?: {
|
|
61
65
|
default?: string;
|
|
@@ -86,8 +90,10 @@ export const DescriptionList: React.FunctionComponent<DescriptionListProps> = ({
|
|
|
86
90
|
isCompact,
|
|
87
91
|
isFluid,
|
|
88
92
|
isFillColumns,
|
|
93
|
+
displaySize,
|
|
89
94
|
columnModifier,
|
|
90
95
|
autoFitMinModifier,
|
|
96
|
+
termWidth,
|
|
91
97
|
horizontalTermWidthModifier,
|
|
92
98
|
orientation,
|
|
93
99
|
style,
|
|
@@ -99,6 +105,12 @@ export const DescriptionList: React.FunctionComponent<DescriptionListProps> = ({
|
|
|
99
105
|
...setBreakpointModifiers('--pf-c-description-list--GridTemplateColumns--min', autoFitMinModifier)
|
|
100
106
|
};
|
|
101
107
|
}
|
|
108
|
+
if (termWidth) {
|
|
109
|
+
style = {
|
|
110
|
+
...style,
|
|
111
|
+
...{ '--pf-c-description-list__term--width': termWidth }
|
|
112
|
+
};
|
|
113
|
+
}
|
|
102
114
|
if (isHorizontal && horizontalTermWidthModifier) {
|
|
103
115
|
style = {
|
|
104
116
|
...style,
|
|
@@ -119,6 +131,8 @@ export const DescriptionList: React.FunctionComponent<DescriptionListProps> = ({
|
|
|
119
131
|
isCompact && styles.modifiers.compact,
|
|
120
132
|
isFluid && styles.modifiers.fluid,
|
|
121
133
|
isFillColumns && styles.modifiers.fillColumns,
|
|
134
|
+
displaySize === 'lg' && styles.modifiers.displayLg,
|
|
135
|
+
displaySize === '2xl' && styles.modifiers.display_2xl,
|
|
122
136
|
className
|
|
123
137
|
)}
|
|
124
138
|
style={style}
|
|
@@ -11,10 +11,11 @@ propComponents:
|
|
|
11
11
|
'DescriptionListTermHelpText',
|
|
12
12
|
'DescriptionListTermHelpTextButton',
|
|
13
13
|
'Popover',
|
|
14
|
+
'Card'
|
|
14
15
|
]
|
|
15
16
|
---
|
|
16
17
|
|
|
17
|
-
import { Button, DescriptionList, DescriptionListTerm, DescriptionListDescription, DescriptionListGroup, DescriptionListTermHelpText, DescriptionListTermHelpTextButton, Popover } from '@patternfly/react-core';
|
|
18
|
+
import { Button, DescriptionList, DescriptionListTerm, DescriptionListDescription, DescriptionListGroup, DescriptionListTermHelpText, DescriptionListTermHelpTextButton, Popover, Checkbox, Card } from '@patternfly/react-core';
|
|
18
19
|
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
19
20
|
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
20
21
|
import BookIcon from '@patternfly/react-icons/dist/esm/icons/book-icon';
|
|
@@ -84,6 +85,11 @@ import FlagIcon from '@patternfly/react-icons/dist/esm/icons/flag-icon';
|
|
|
84
85
|
```ts file='./DescriptionListColumnFill.tsx'
|
|
85
86
|
```
|
|
86
87
|
|
|
88
|
+
### Display size
|
|
89
|
+
|
|
90
|
+
```ts file='./DescriptionListWithDisplaySize.tsx'
|
|
91
|
+
```
|
|
92
|
+
|
|
87
93
|
## Responsive column definitions
|
|
88
94
|
|
|
89
95
|
### Default responsive columns
|
|
@@ -120,6 +126,30 @@ import FlagIcon from '@patternfly/react-icons/dist/esm/icons/flag-icon';
|
|
|
120
126
|
```ts file='./DescriptionListDefaultInlineGrid.tsx'
|
|
121
127
|
```
|
|
122
128
|
|
|
129
|
+
## Card variants
|
|
130
|
+
|
|
131
|
+
A [card component](/components/card) can be used in place of a description list group.
|
|
132
|
+
|
|
133
|
+
### Description list with card
|
|
134
|
+
|
|
135
|
+
```ts file='./DescriptionListWithCard.tsx'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Description list with display size and card
|
|
139
|
+
|
|
140
|
+
```ts file='./DescriptionListDisplaySizeAndCard.tsx'
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Display size with card, three column on large breakpoint
|
|
144
|
+
|
|
145
|
+
```ts file='./DescriptionListDisplaySizeAndCardThreeColumn.tsx'
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Display size with card, horizontal, modified term width
|
|
149
|
+
|
|
150
|
+
```ts file='./DescriptionListDisplaySizeAndCardHorizontalTermWidth.tsx'
|
|
151
|
+
```
|
|
152
|
+
|
|
123
153
|
## Auto fit
|
|
124
154
|
|
|
125
155
|
### Auto-fit basic
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
DescriptionList,
|
|
5
|
+
DescriptionListTerm,
|
|
6
|
+
DescriptionListDescription,
|
|
7
|
+
Card,
|
|
8
|
+
Checkbox
|
|
9
|
+
} from '@patternfly/react-core';
|
|
10
|
+
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
11
|
+
|
|
12
|
+
export const DescriptionListDisplaySizeAndCard: React.FunctionComponent = () => {
|
|
13
|
+
const [isChecked, setIsChecked] = React.useState<boolean>(false);
|
|
14
|
+
const [displaySize, setDisplaySize] = React.useState<'lg' | '2xl'>('lg');
|
|
15
|
+
|
|
16
|
+
const toggleDisplaySize = (checked: boolean) => {
|
|
17
|
+
setDisplaySize(checked ? '2xl' : 'lg');
|
|
18
|
+
setIsChecked(checked);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<div style={{ marginBottom: '12px' }}>
|
|
24
|
+
<Checkbox
|
|
25
|
+
label="displaySize 2xl"
|
|
26
|
+
isChecked={isChecked}
|
|
27
|
+
onChange={toggleDisplaySize}
|
|
28
|
+
aria-label="set display size 2xl"
|
|
29
|
+
id="toggle-display-size-with-card"
|
|
30
|
+
name="toggle-display-size-with-card"
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
<DescriptionList displaySize={displaySize} columnModifier={{ lg: '2Col' }}>
|
|
34
|
+
<Card component="div">
|
|
35
|
+
<DescriptionListTerm>Name</DescriptionListTerm>
|
|
36
|
+
<DescriptionListDescription>Example</DescriptionListDescription>
|
|
37
|
+
</Card>
|
|
38
|
+
<Card component="div">
|
|
39
|
+
<DescriptionListTerm>Namespace</DescriptionListTerm>
|
|
40
|
+
<DescriptionListDescription>
|
|
41
|
+
<a href="#">mary-test</a>
|
|
42
|
+
</DescriptionListDescription>
|
|
43
|
+
</Card>
|
|
44
|
+
<Card component="div">
|
|
45
|
+
<DescriptionListTerm>Labels</DescriptionListTerm>
|
|
46
|
+
<DescriptionListDescription>example</DescriptionListDescription>
|
|
47
|
+
</Card>
|
|
48
|
+
<Card component="div">
|
|
49
|
+
<DescriptionListTerm>Pod selector</DescriptionListTerm>
|
|
50
|
+
<DescriptionListDescription>
|
|
51
|
+
<Button variant="link" isInline icon={<PlusCircleIcon />}>
|
|
52
|
+
app=MyApp
|
|
53
|
+
</Button>
|
|
54
|
+
</DescriptionListDescription>
|
|
55
|
+
</Card>
|
|
56
|
+
<Card component="div">
|
|
57
|
+
<DescriptionListTerm>Annotation</DescriptionListTerm>
|
|
58
|
+
<DescriptionListDescription>2 Annotations</DescriptionListDescription>
|
|
59
|
+
</Card>
|
|
60
|
+
</DescriptionList>
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, DescriptionList, DescriptionListTerm, DescriptionListDescription, Card } from '@patternfly/react-core';
|
|
3
|
+
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
4
|
+
|
|
5
|
+
export const DescriptionListDisplaySizeAndCardHorizontalTermWidth: React.FunctionComponent = () => (
|
|
6
|
+
<DescriptionList displaySize="lg" isHorizontal columnModifier={{ lg: '2Col' }} termWidth="10ch">
|
|
7
|
+
<Card component="div">
|
|
8
|
+
<DescriptionListTerm>Name</DescriptionListTerm>
|
|
9
|
+
<DescriptionListDescription>Example</DescriptionListDescription>
|
|
10
|
+
</Card>
|
|
11
|
+
<Card component="div">
|
|
12
|
+
<DescriptionListTerm>Namespace</DescriptionListTerm>
|
|
13
|
+
<DescriptionListDescription>
|
|
14
|
+
<a href="#">mary-test</a>
|
|
15
|
+
</DescriptionListDescription>
|
|
16
|
+
</Card>
|
|
17
|
+
<Card component="div">
|
|
18
|
+
<DescriptionListTerm>Labels</DescriptionListTerm>
|
|
19
|
+
<DescriptionListDescription>example</DescriptionListDescription>
|
|
20
|
+
</Card>
|
|
21
|
+
<Card component="div">
|
|
22
|
+
<DescriptionListTerm>Pod selector</DescriptionListTerm>
|
|
23
|
+
<DescriptionListDescription>
|
|
24
|
+
<Button variant="link" isInline icon={<PlusCircleIcon />}>
|
|
25
|
+
app=MyApp
|
|
26
|
+
</Button>
|
|
27
|
+
</DescriptionListDescription>
|
|
28
|
+
</Card>
|
|
29
|
+
<Card component="div">
|
|
30
|
+
<DescriptionListTerm>Annotation</DescriptionListTerm>
|
|
31
|
+
<DescriptionListDescription>2 Annotations</DescriptionListDescription>
|
|
32
|
+
</Card>
|
|
33
|
+
</DescriptionList>
|
|
34
|
+
);
|
package/src/components/DescriptionList/examples/DescriptionListDisplaySizeAndCardThreeColumn.tsx
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, DescriptionList, DescriptionListTerm, DescriptionListDescription, Card } from '@patternfly/react-core';
|
|
3
|
+
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
4
|
+
|
|
5
|
+
export const DescriptionListDisplayLgAndCardThreeColumn: React.FunctionComponent = () => (
|
|
6
|
+
<DescriptionList displaySize="lg" columnModifier={{ lg: '3Col' }}>
|
|
7
|
+
<Card component="div">
|
|
8
|
+
<DescriptionListTerm>Name</DescriptionListTerm>
|
|
9
|
+
<DescriptionListDescription>Example</DescriptionListDescription>
|
|
10
|
+
</Card>
|
|
11
|
+
<Card component="div">
|
|
12
|
+
<DescriptionListTerm>Namespace</DescriptionListTerm>
|
|
13
|
+
<DescriptionListDescription>
|
|
14
|
+
<a href="#">mary-test</a>
|
|
15
|
+
</DescriptionListDescription>
|
|
16
|
+
</Card>
|
|
17
|
+
<Card component="div">
|
|
18
|
+
<DescriptionListTerm>Labels</DescriptionListTerm>
|
|
19
|
+
<DescriptionListDescription>example</DescriptionListDescription>
|
|
20
|
+
</Card>
|
|
21
|
+
<Card component="div">
|
|
22
|
+
<DescriptionListTerm>Pod selector</DescriptionListTerm>
|
|
23
|
+
<DescriptionListDescription>
|
|
24
|
+
<Button variant="link" isInline icon={<PlusCircleIcon />}>
|
|
25
|
+
app=MyApp
|
|
26
|
+
</Button>
|
|
27
|
+
</DescriptionListDescription>
|
|
28
|
+
</Card>
|
|
29
|
+
<Card component="div">
|
|
30
|
+
<DescriptionListTerm>Annotation</DescriptionListTerm>
|
|
31
|
+
<DescriptionListDescription>2 Annotations</DescriptionListDescription>
|
|
32
|
+
</Card>
|
|
33
|
+
</DescriptionList>
|
|
34
|
+
);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
DescriptionList,
|
|
5
|
+
DescriptionListTerm,
|
|
6
|
+
DescriptionListDescription,
|
|
7
|
+
Card,
|
|
8
|
+
Checkbox
|
|
9
|
+
} from '@patternfly/react-core';
|
|
10
|
+
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
11
|
+
|
|
12
|
+
export const DescriptionListWithCard: React.FunctionComponent = () => {
|
|
13
|
+
const [isChecked, setIsChecked] = React.useState<boolean>(false);
|
|
14
|
+
const [isSelectable, setSelectable] = React.useState<boolean>(false);
|
|
15
|
+
|
|
16
|
+
const toggleSelectable = (checked: boolean) => {
|
|
17
|
+
setSelectable(checked ? true : false);
|
|
18
|
+
setIsChecked(checked);
|
|
19
|
+
};
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<div style={{ marginBottom: '12px' }}>
|
|
23
|
+
<Checkbox
|
|
24
|
+
label="isSelectable"
|
|
25
|
+
isChecked={isChecked}
|
|
26
|
+
onChange={toggleSelectable}
|
|
27
|
+
aria-label="set isSelectable"
|
|
28
|
+
id="toggle-isSelectable"
|
|
29
|
+
name="toggle-isSelectable"
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
<DescriptionList columnModifier={{ lg: '2Col' }}>
|
|
33
|
+
<Card component="div" isSelectable={isSelectable}>
|
|
34
|
+
<DescriptionListTerm>Name</DescriptionListTerm>
|
|
35
|
+
<DescriptionListDescription>Example</DescriptionListDescription>
|
|
36
|
+
</Card>
|
|
37
|
+
<Card component="div" isSelectable={isSelectable}>
|
|
38
|
+
<DescriptionListTerm>Namespace</DescriptionListTerm>
|
|
39
|
+
<DescriptionListDescription>
|
|
40
|
+
<a href="#">mary-test</a>
|
|
41
|
+
</DescriptionListDescription>
|
|
42
|
+
</Card>
|
|
43
|
+
<Card component="div" isSelectable={isSelectable}>
|
|
44
|
+
<DescriptionListTerm>Labels</DescriptionListTerm>
|
|
45
|
+
<DescriptionListDescription>example</DescriptionListDescription>
|
|
46
|
+
</Card>
|
|
47
|
+
<Card component="div" isSelectable={isSelectable}>
|
|
48
|
+
<DescriptionListTerm>Pod selector</DescriptionListTerm>
|
|
49
|
+
<DescriptionListDescription>
|
|
50
|
+
<Button variant="link" isInline icon={<PlusCircleIcon />}>
|
|
51
|
+
app=MyApp
|
|
52
|
+
</Button>
|
|
53
|
+
</DescriptionListDescription>
|
|
54
|
+
</Card>
|
|
55
|
+
<Card component="div" isSelectable={isSelectable}>
|
|
56
|
+
<DescriptionListTerm>Annotation</DescriptionListTerm>
|
|
57
|
+
<DescriptionListDescription>2 Annotations</DescriptionListDescription>
|
|
58
|
+
</Card>
|
|
59
|
+
</DescriptionList>
|
|
60
|
+
</>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
DescriptionList,
|
|
5
|
+
DescriptionListTerm,
|
|
6
|
+
DescriptionListGroup,
|
|
7
|
+
DescriptionListDescription,
|
|
8
|
+
Checkbox
|
|
9
|
+
} from '@patternfly/react-core';
|
|
10
|
+
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
11
|
+
|
|
12
|
+
export const DescriptionListWithDisplaySize: React.FunctionComponent = () => {
|
|
13
|
+
const [isChecked, setIsChecked] = React.useState<boolean>(false);
|
|
14
|
+
const [displaySize, setDisplaySize] = React.useState<'lg' | '2xl'>('lg');
|
|
15
|
+
|
|
16
|
+
const toggleDisplaySize = (checked: boolean) => {
|
|
17
|
+
setDisplaySize(checked ? '2xl' : 'lg');
|
|
18
|
+
setIsChecked(checked);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<div style={{ marginBottom: '12px' }}>
|
|
24
|
+
<Checkbox
|
|
25
|
+
label="displaySize 2xl"
|
|
26
|
+
isChecked={isChecked}
|
|
27
|
+
onChange={toggleDisplaySize}
|
|
28
|
+
aria-label="set display size 2xl"
|
|
29
|
+
id="toggle-display-size"
|
|
30
|
+
name="toggle-display-size"
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
<DescriptionList displaySize={displaySize} columnModifier={{ lg: '2Col' }}>
|
|
34
|
+
<DescriptionListGroup>
|
|
35
|
+
<DescriptionListTerm>Name</DescriptionListTerm>
|
|
36
|
+
<DescriptionListDescription>Example</DescriptionListDescription>
|
|
37
|
+
</DescriptionListGroup>
|
|
38
|
+
<DescriptionListGroup>
|
|
39
|
+
<DescriptionListTerm>Namespace</DescriptionListTerm>
|
|
40
|
+
<DescriptionListDescription>
|
|
41
|
+
<a href="#">mary-test</a>
|
|
42
|
+
</DescriptionListDescription>
|
|
43
|
+
</DescriptionListGroup>
|
|
44
|
+
<DescriptionListGroup>
|
|
45
|
+
<DescriptionListTerm>Labels</DescriptionListTerm>
|
|
46
|
+
<DescriptionListDescription>example</DescriptionListDescription>
|
|
47
|
+
</DescriptionListGroup>
|
|
48
|
+
<DescriptionListGroup>
|
|
49
|
+
<DescriptionListTerm>Pod selector</DescriptionListTerm>
|
|
50
|
+
<DescriptionListDescription>
|
|
51
|
+
<Button variant="link" isInline icon={<PlusCircleIcon />}>
|
|
52
|
+
app=MyApp
|
|
53
|
+
</Button>
|
|
54
|
+
</DescriptionListDescription>
|
|
55
|
+
</DescriptionListGroup>
|
|
56
|
+
<DescriptionListGroup>
|
|
57
|
+
<DescriptionListTerm>Annotation</DescriptionListTerm>
|
|
58
|
+
<DescriptionListDescription>2 Annotations</DescriptionListDescription>
|
|
59
|
+
</DescriptionListGroup>
|
|
60
|
+
</DescriptionList>
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
@@ -192,11 +192,12 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
|
|
|
192
192
|
}
|
|
193
193
|
}, [flyoutVisible, flyoutTarget]);
|
|
194
194
|
|
|
195
|
-
const handleFlyout = (event: React.KeyboardEvent) => {
|
|
196
|
-
const key = event.key;
|
|
195
|
+
const handleFlyout = (event: React.KeyboardEvent | React.MouseEvent) => {
|
|
196
|
+
const key = (event as React.KeyboardEvent).key;
|
|
197
197
|
const target = event.target;
|
|
198
|
+
const type = event.type;
|
|
198
199
|
|
|
199
|
-
if (key === ' ' || key === 'Enter' || key === 'ArrowRight') {
|
|
200
|
+
if (key === ' ' || key === 'Enter' || key === 'ArrowRight' || type === 'click') {
|
|
200
201
|
event.stopPropagation();
|
|
201
202
|
if (!flyoutVisible) {
|
|
202
203
|
showFlyout(true);
|
|
@@ -251,7 +252,7 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
|
|
|
251
252
|
if (isOnPath) {
|
|
252
253
|
additionalProps['aria-expanded'] = true;
|
|
253
254
|
} else if (hasFlyout) {
|
|
254
|
-
additionalProps['aria-haspopup'] =
|
|
255
|
+
additionalProps['aria-haspopup'] = 'menu';
|
|
255
256
|
additionalProps['aria-expanded'] = flyoutVisible;
|
|
256
257
|
}
|
|
257
258
|
const getAriaCurrent = () => {
|
|
@@ -309,12 +310,13 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
|
|
|
309
310
|
className={css(styles.menuItem, getIsSelected() && !hasCheck && styles.modifiers.selected, className)}
|
|
310
311
|
aria-current={getAriaCurrent()}
|
|
311
312
|
{...(!hasCheck && { disabled: isDisabled })}
|
|
312
|
-
{...(!hasCheck && { role: 'menuitem' })}
|
|
313
|
+
{...(!hasCheck && !flyoutMenu && { role: 'menuitem' })}
|
|
313
314
|
ref={innerRef}
|
|
314
315
|
{...(!hasCheck && {
|
|
315
316
|
onClick: (event: any) => {
|
|
316
317
|
onItemSelect(event, onSelect);
|
|
317
318
|
_drill && _drill();
|
|
319
|
+
flyoutMenu && handleFlyout(event);
|
|
318
320
|
}
|
|
319
321
|
})}
|
|
320
322
|
{...(hasCheck && { htmlFor: randomId })}
|
|
@@ -150,6 +150,11 @@ export const NavItem: React.FunctionComponent<NavItemProps> = ({
|
|
|
150
150
|
</span>
|
|
151
151
|
);
|
|
152
152
|
|
|
153
|
+
const ariaFlyoutProps = {
|
|
154
|
+
'aria-haspopup': 'menu',
|
|
155
|
+
'aria-expanded': flyoutVisible
|
|
156
|
+
};
|
|
157
|
+
|
|
153
158
|
const renderDefaultLink = (context: any): React.ReactNode => {
|
|
154
159
|
const preventLinkDefault = preventDefault || !to;
|
|
155
160
|
return (
|
|
@@ -164,6 +169,7 @@ export const NavItem: React.FunctionComponent<NavItemProps> = ({
|
|
|
164
169
|
)}
|
|
165
170
|
aria-current={isActive ? 'page' : null}
|
|
166
171
|
tabIndex={isNavOpen ? null : '-1'}
|
|
172
|
+
{...(hasFlyout && { ...ariaFlyoutProps })}
|
|
167
173
|
{...props}
|
|
168
174
|
>
|
|
169
175
|
{children}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/Tabs/tabs';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
|
|
5
|
+
import { Popper } from '../../helpers';
|
|
6
|
+
import { Menu, MenuContent, MenuList, MenuItem } from '../Menu';
|
|
7
|
+
import { TabsContext } from './TabsContext';
|
|
8
|
+
import { TabProps } from './Tab';
|
|
9
|
+
import { TabTitleText } from './TabTitleText';
|
|
10
|
+
|
|
11
|
+
export interface OverflowTabProps extends React.HTMLProps<HTMLLIElement> {
|
|
12
|
+
/** Additional classes added to the overflow tab */
|
|
13
|
+
className?: string;
|
|
14
|
+
/** The tabs that should be displayed in the menu */
|
|
15
|
+
overflowingTabs?: TabProps[];
|
|
16
|
+
/** Flag which shows the count of overflowing tabs when enabled */
|
|
17
|
+
showTabCount?: boolean;
|
|
18
|
+
/** The text which displays when an overflowing tab isn't selected */
|
|
19
|
+
defaultTitleText?: string;
|
|
20
|
+
/** The aria label applied to the button which toggles the tab overflow menu */
|
|
21
|
+
toggleAriaLabel?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const OverflowTab: React.FunctionComponent<OverflowTabProps> = ({
|
|
25
|
+
className,
|
|
26
|
+
overflowingTabs = [],
|
|
27
|
+
showTabCount,
|
|
28
|
+
defaultTitleText = 'More',
|
|
29
|
+
toggleAriaLabel,
|
|
30
|
+
...props
|
|
31
|
+
}: OverflowTabProps) => {
|
|
32
|
+
const menuRef = React.useRef<HTMLDivElement>();
|
|
33
|
+
const overflowTabRef = React.useRef<HTMLButtonElement>();
|
|
34
|
+
const overflowLIRef = React.useRef<HTMLLIElement>();
|
|
35
|
+
|
|
36
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
37
|
+
|
|
38
|
+
const { localActiveKey, handleTabClick } = React.useContext(TabsContext);
|
|
39
|
+
|
|
40
|
+
const closeMenu = () => {
|
|
41
|
+
setIsExpanded(false);
|
|
42
|
+
overflowTabRef.current.focus();
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const handleMenuKeys = (ev: KeyboardEvent) => {
|
|
46
|
+
const menuContainsEventTarget = menuRef?.current?.contains(ev.target as Node);
|
|
47
|
+
if (isExpanded && menuContainsEventTarget && ev.key === 'Escape') {
|
|
48
|
+
closeMenu();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleClick = (ev: MouseEvent) => {
|
|
53
|
+
const clickIsOutsideMenu = !menuRef?.current?.contains(ev.target as Node);
|
|
54
|
+
const clickIsOutsideOverflowTab = !overflowTabRef?.current?.contains(ev.target as Node);
|
|
55
|
+
if (isExpanded && clickIsOutsideMenu && clickIsOutsideOverflowTab) {
|
|
56
|
+
closeMenu();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
window.addEventListener('click', handleClick);
|
|
62
|
+
window.addEventListener('keydown', handleMenuKeys);
|
|
63
|
+
|
|
64
|
+
return () => {
|
|
65
|
+
window.removeEventListener('click', handleClick);
|
|
66
|
+
window.removeEventListener('keydown', handleMenuKeys);
|
|
67
|
+
};
|
|
68
|
+
}, [isExpanded, menuRef, overflowTabRef]);
|
|
69
|
+
|
|
70
|
+
const selectedTab = overflowingTabs.find(tab => tab.eventKey === localActiveKey);
|
|
71
|
+
const tabTitle = selectedTab?.title ? selectedTab.title : defaultTitleText;
|
|
72
|
+
|
|
73
|
+
const toggleMenu = () => {
|
|
74
|
+
setIsExpanded(prevIsExpanded => !prevIsExpanded);
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
if (menuRef?.current) {
|
|
77
|
+
const firstElement = menuRef.current.querySelector('li > button,input:not(:disabled)');
|
|
78
|
+
firstElement && (firstElement as HTMLElement).focus();
|
|
79
|
+
}
|
|
80
|
+
}, 0);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const overflowTab = (
|
|
84
|
+
<li
|
|
85
|
+
className={css(styles.tabsItem, 'pf-m-overflow', selectedTab && styles.modifiers.current, className)}
|
|
86
|
+
role="presentation"
|
|
87
|
+
ref={overflowLIRef}
|
|
88
|
+
{...props}
|
|
89
|
+
>
|
|
90
|
+
<button
|
|
91
|
+
className={css(styles.tabsLink, isExpanded && styles.modifiers.expanded)}
|
|
92
|
+
onClick={() => toggleMenu()}
|
|
93
|
+
aria-label={toggleAriaLabel}
|
|
94
|
+
aria-haspopup="menu"
|
|
95
|
+
aria-expanded={isExpanded}
|
|
96
|
+
role="tab"
|
|
97
|
+
ref={overflowTabRef}
|
|
98
|
+
>
|
|
99
|
+
<TabTitleText>
|
|
100
|
+
{tabTitle}
|
|
101
|
+
{showTabCount && tabTitle === defaultTitleText && ` (${overflowingTabs.length})`}
|
|
102
|
+
</TabTitleText>
|
|
103
|
+
<span className={styles.tabsLinkToggleIcon}>
|
|
104
|
+
<AngleRightIcon />
|
|
105
|
+
</span>
|
|
106
|
+
</button>
|
|
107
|
+
</li>
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const tabs = overflowingTabs.map(tab => (
|
|
111
|
+
<MenuItem key={tab.eventKey} itemId={tab.eventKey} isSelected={localActiveKey === tab.eventKey}>
|
|
112
|
+
{tab.title}
|
|
113
|
+
</MenuItem>
|
|
114
|
+
));
|
|
115
|
+
|
|
116
|
+
const onTabSelect = (event: React.MouseEvent<HTMLElement, MouseEvent>, key: number | string) => {
|
|
117
|
+
closeMenu();
|
|
118
|
+
const selectedTabRef = overflowingTabs.find(tab => tab.eventKey === key).tabContentRef;
|
|
119
|
+
handleTabClick(event, key, selectedTabRef);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const overflowMenu = (
|
|
123
|
+
<Menu ref={menuRef} onSelect={(ev, itemId) => onTabSelect(ev as React.MouseEvent<HTMLElement, MouseEvent>, itemId)}>
|
|
124
|
+
<MenuContent>
|
|
125
|
+
<MenuList>{tabs}</MenuList>
|
|
126
|
+
</MenuContent>
|
|
127
|
+
</Menu>
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<Popper
|
|
132
|
+
trigger={overflowTab}
|
|
133
|
+
popper={overflowMenu}
|
|
134
|
+
isVisible={isExpanded}
|
|
135
|
+
popperMatchesTriggerWidth={false}
|
|
136
|
+
appendTo={overflowLIRef.current}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
OverflowTab.displayName = 'OverflowTab';
|