@patternfly/react-core 4.232.5 → 4.232.8
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 +24 -0
- package/dist/esm/components/Page/Page.d.ts +1 -1
- package/dist/esm/components/Page/Page.d.ts.map +1 -1
- package/dist/js/components/Page/Page.d.ts +1 -1
- package/dist/js/components/Page/Page.d.ts.map +1 -1
- package/dist/styles/base-no-reset.css +1 -1
- package/dist/styles/base.css +1 -1
- package/dist/umd/react-core.css +91 -86
- package/dist/umd/react-core.js +1 -0
- package/dist/umd/react-core.min.css +111 -106
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +7 -7
- package/src/components/Nav/examples/Nav.md +10 -626
- package/src/components/Nav/examples/NavDefault.tsx +29 -0
- package/src/components/Nav/examples/NavDrilldown.tsx +20 -15
- package/src/components/Nav/examples/NavExpandable.tsx +119 -0
- package/src/components/Nav/examples/NavExpandableThirdLevel.tsx +115 -0
- package/src/components/Nav/examples/NavFlyout.tsx +102 -0
- package/src/components/Nav/examples/NavGrouped.tsx +67 -0
- package/src/components/Nav/examples/NavHorizontalPageHeader.tsx +34 -0
- package/src/components/Nav/examples/NavHorizontalSubNav.tsx +32 -0
- package/src/components/Nav/examples/NavLegacyTertiary.tsx +32 -0
- package/src/components/Nav/examples/NavMixed.tsx +101 -0
- package/src/components/Page/Page.tsx +1 -1
- package/src/components/Popover/examples/Popover.md +10 -293
- package/src/components/Popover/examples/PopoverAdvanced.tsx +79 -0
- package/src/components/Popover/examples/PopoverAlert.tsx +47 -0
- package/src/components/Popover/examples/PopoverBasic.tsx +15 -0
- package/src/components/Popover/examples/PopoverCloseControlled.tsx +29 -0
- package/src/components/Popover/examples/PopoverCloseUncontrolled.tsx +25 -0
- package/src/components/Popover/examples/PopoverReactRef.tsx +23 -0
- package/src/components/Popover/examples/PopoverSelectorRef.tsx +19 -0
- package/src/components/Popover/examples/PopoverWidthAuto.tsx +14 -0
- package/src/components/Popover/examples/PopoverWithIconInTheTitle.tsx +17 -0
- package/src/components/Popover/examples/PopoverWithoutHeaderFooterCloseNoPadding.tsx +21 -0
- package/src/components/Progress/examples/Progress.md +18 -117
- package/src/components/Progress/examples/ProgressBasic.tsx +4 -0
- package/src/components/Progress/examples/ProgressFailure.tsx +6 -0
- package/src/components/Progress/examples/ProgressFailureWithoutMeasure.tsx +6 -0
- package/src/components/Progress/examples/ProgressFiniteStep.tsx +14 -0
- package/src/components/Progress/examples/ProgressInside.tsx +6 -0
- package/src/components/Progress/examples/ProgressInsideSuccess.tsx +11 -0
- package/src/components/Progress/examples/ProgressLarge.tsx +6 -0
- package/src/components/Progress/examples/ProgressOutside.tsx +6 -0
- package/src/components/Progress/examples/ProgressOutsideFailure.tsx +11 -0
- package/src/components/Progress/examples/ProgressSingleLine.tsx +6 -0
- package/src/components/Progress/examples/ProgressSmall.tsx +6 -0
- package/src/components/Progress/examples/ProgressStepInstruction.tsx +6 -0
- package/src/components/Progress/examples/ProgressSuccess.tsx +6 -0
- package/src/components/Progress/examples/ProgressTitleOutsideOfProgressBar.tsx +24 -0
- package/src/components/Progress/examples/ProgressTruncateTitle.tsx +10 -0
- package/src/components/Progress/examples/ProgressWarning.tsx +6 -0
- package/src/components/Progress/examples/ProgressWithoutMeasure.tsx +6 -0
|
@@ -78,7 +78,7 @@ export interface PageProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
78
78
|
* Can add callback to be notified when resize occurs, for example to set the sidebar isNav prop to false for a width < 768px
|
|
79
79
|
* Returns object { mobileView: boolean, windowSize: number }
|
|
80
80
|
*/
|
|
81
|
-
onPageResize?: (object: any) => void;
|
|
81
|
+
onPageResize?: ((object: any) => void) | null;
|
|
82
82
|
/**
|
|
83
83
|
* The page resize observer uses the breakpoints returned from this function when adding the pf-m-breakpoint-[default|sm|md|lg|xl|2xl] class
|
|
84
84
|
* You can override the default getBreakpoint function to return breakpoints at different sizes than the default
|
|
@@ -16,335 +16,52 @@ import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon';
|
|
|
16
16
|
|
|
17
17
|
### Basic
|
|
18
18
|
|
|
19
|
-
```
|
|
20
|
-
import React from 'react';
|
|
21
|
-
import { Popover, PopoverPosition, Button } from '@patternfly/react-core';
|
|
22
|
-
|
|
23
|
-
<div style={{ margin: '50px' }}>
|
|
24
|
-
<Popover
|
|
25
|
-
aria-label="Basic popover"
|
|
26
|
-
headerContent={<div>Popover header</div>}
|
|
27
|
-
bodyContent={<div>Popovers are triggered by click rather than hover.</div>}
|
|
28
|
-
footerContent="Popover footer"
|
|
29
|
-
>
|
|
30
|
-
<Button>Toggle popover</Button>
|
|
31
|
-
</Popover>
|
|
32
|
-
</div>;
|
|
19
|
+
```ts file="./PopoverBasic.tsx"
|
|
33
20
|
```
|
|
34
21
|
|
|
35
22
|
### Close popover from content (controlled)
|
|
36
23
|
|
|
37
|
-
```
|
|
38
|
-
import React from 'react';
|
|
39
|
-
import { Popover, PopoverPosition, Button } from '@patternfly/react-core';
|
|
40
|
-
|
|
41
|
-
PopoverCloseControlled = () => {
|
|
42
|
-
const [isVisible, setIsVisible] = React.useState(false);
|
|
43
|
-
return (
|
|
44
|
-
<div style={{ margin: '50px' }}>
|
|
45
|
-
<Popover
|
|
46
|
-
aria-label="Popover with button in the body that can close it"
|
|
47
|
-
isVisible={isVisible}
|
|
48
|
-
shouldOpen={() => setIsVisible(true)}
|
|
49
|
-
shouldClose={() => setIsVisible(false)}
|
|
50
|
-
headerContent={<div>Popover header</div>}
|
|
51
|
-
bodyContent={
|
|
52
|
-
<div>
|
|
53
|
-
<div>
|
|
54
|
-
All the content props (headerContent, bodyContent, footerContent) can take a function which the popover
|
|
55
|
-
component passes the hide function to which can be used to close the popover after some user interaction.
|
|
56
|
-
</div>
|
|
57
|
-
<div>
|
|
58
|
-
<button onClick={() => setIsVisible(false)}>Close popover</button>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
}
|
|
62
|
-
footerContent="Popover footer"
|
|
63
|
-
>
|
|
64
|
-
<Button>Toggle popover</Button>
|
|
65
|
-
</Popover>
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
24
|
+
```ts file="./PopoverCloseControlled.tsx"
|
|
69
25
|
```
|
|
70
26
|
|
|
71
27
|
### Close popover from content (uncontrolled)
|
|
72
28
|
|
|
73
29
|
Note: If you use the isVisible prop, either refer to the example above or if you want to use the hide callback from the content then be sure to keep isVisible in-sync.
|
|
74
30
|
|
|
75
|
-
```
|
|
76
|
-
import React from 'react';
|
|
77
|
-
import { Popover, PopoverPosition, Button } from '@patternfly/react-core';
|
|
78
|
-
|
|
79
|
-
<div style={{ margin: '50px' }}>
|
|
80
|
-
<Popover
|
|
81
|
-
aria-label="Popover with button in the body that can close it"
|
|
82
|
-
headerContent={<div>Popover header</div>}
|
|
83
|
-
bodyContent={hide => (
|
|
84
|
-
<div>
|
|
85
|
-
<div>
|
|
86
|
-
All the content props (headerContent, bodyContent, footerContent) can take a function which the popover
|
|
87
|
-
component passes the hide function to which can be used to close the popover after some user interaction.
|
|
88
|
-
</div>
|
|
89
|
-
<div>
|
|
90
|
-
<button onClick={hide}>Close popover</button>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
)}
|
|
94
|
-
footerContent="Popover footer"
|
|
95
|
-
>
|
|
96
|
-
<Button>Toggle popover</Button>
|
|
97
|
-
</Popover>
|
|
98
|
-
</div>;
|
|
31
|
+
```ts file="./PopoverCloseUncontrolled.tsx"
|
|
99
32
|
```
|
|
100
33
|
|
|
101
34
|
### Without header/footer/close and no padding
|
|
102
35
|
|
|
103
|
-
```
|
|
104
|
-
import React from 'react';
|
|
105
|
-
import { Popover, PopoverPosition, Button } from '@patternfly/react-core';
|
|
106
|
-
|
|
107
|
-
<div style={{ margin: '50px' }}>
|
|
108
|
-
<Popover
|
|
109
|
-
aria-label="Popover with no header, footer, close button, and padding"
|
|
110
|
-
hasNoPadding
|
|
111
|
-
showClose={false}
|
|
112
|
-
bodyContent={hide => (
|
|
113
|
-
<div>
|
|
114
|
-
This popover has no padding and is intended for use with content that has its own spacing and should touch the
|
|
115
|
-
edges of the popover container.
|
|
116
|
-
</div>
|
|
117
|
-
)}
|
|
118
|
-
withFocusTrap={false /* no focusable content in this example */}
|
|
119
|
-
>
|
|
120
|
-
<Button>Toggle popover</Button>
|
|
121
|
-
</Popover>
|
|
122
|
-
</div>;
|
|
36
|
+
```ts file="./PopoverWithoutHeaderFooterCloseNoPadding.tsx"
|
|
123
37
|
```
|
|
124
38
|
|
|
125
39
|
### Width auto
|
|
126
40
|
|
|
127
|
-
```
|
|
128
|
-
import React from 'react';
|
|
129
|
-
import { Popover, PopoverPosition, Button } from '@patternfly/react-core';
|
|
130
|
-
|
|
131
|
-
<div style={{ margin: '50px' }}>
|
|
132
|
-
<Popover
|
|
133
|
-
aria-label="Popover with auto-width"
|
|
134
|
-
hasAutoWidth
|
|
135
|
-
bodyContent={hide => <div>Removes fixed-width and allows width to be defined by contents</div>}
|
|
136
|
-
>
|
|
137
|
-
<Button>Toggle popover</Button>
|
|
138
|
-
</Popover>
|
|
139
|
-
</div>;
|
|
41
|
+
```ts file="./PopoverWidthAuto.tsx"
|
|
140
42
|
```
|
|
141
43
|
|
|
142
44
|
### Popover react ref
|
|
143
45
|
|
|
144
|
-
```
|
|
145
|
-
import React from 'react';
|
|
146
|
-
import { Popover } from '@patternfly/react-core';
|
|
147
|
-
|
|
148
|
-
PopoverReactRef = () => {
|
|
149
|
-
const popoverRef = React.useRef();
|
|
150
|
-
return (
|
|
151
|
-
<div style={{ margin: '50px' }}>
|
|
152
|
-
<button ref={popoverRef}>Popover attached via react ref</button>
|
|
153
|
-
<Popover
|
|
154
|
-
aria-label="Popover with react reference example"
|
|
155
|
-
headerContent={<div>Popover header</div>}
|
|
156
|
-
bodyContent={
|
|
157
|
-
<div>
|
|
158
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla turpis.
|
|
159
|
-
</div>
|
|
160
|
-
}
|
|
161
|
-
footerContent="Popover footer"
|
|
162
|
-
reference={popoverRef}
|
|
163
|
-
/>
|
|
164
|
-
</div>
|
|
165
|
-
);
|
|
166
|
-
};
|
|
46
|
+
```ts file="./PopoverReactRef.tsx"
|
|
167
47
|
```
|
|
168
48
|
|
|
169
49
|
### Popover selector ref
|
|
170
50
|
|
|
171
|
-
```
|
|
172
|
-
import React from 'react';
|
|
173
|
-
import { Popover } from '@patternfly/react-core';
|
|
174
|
-
|
|
175
|
-
<div style={{ margin: '50px' }}>
|
|
176
|
-
<button id="popover-selector">Popover attached via selector ref</button>
|
|
177
|
-
<Popover
|
|
178
|
-
aria-label="Popover with selector reference example"
|
|
179
|
-
headerContent={<div>Popover header</div>}
|
|
180
|
-
bodyContent={
|
|
181
|
-
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla turpis.</div>
|
|
182
|
-
}
|
|
183
|
-
footerContent="Popover footer"
|
|
184
|
-
reference={() => document.getElementById('popover-selector')}
|
|
185
|
-
/>
|
|
186
|
-
</div>;
|
|
51
|
+
```ts file="./PopoverSelectorRef.tsx"
|
|
187
52
|
```
|
|
188
53
|
|
|
189
54
|
### Advanced
|
|
190
55
|
|
|
191
|
-
```
|
|
192
|
-
import React from 'react';
|
|
193
|
-
import { Popover, PopoverPosition, Checkbox, Button } from '@patternfly/react-core';
|
|
194
|
-
|
|
195
|
-
class AdvancedPopover extends React.Component {
|
|
196
|
-
constructor(props) {
|
|
197
|
-
super(props);
|
|
198
|
-
this.state = {
|
|
199
|
-
position: 'auto',
|
|
200
|
-
show: false,
|
|
201
|
-
keepInViewChecked: true
|
|
202
|
-
};
|
|
203
|
-
this.handleKeepInViewChange = checked => {
|
|
204
|
-
this.setState({ keepInViewChecked: checked });
|
|
205
|
-
};
|
|
206
|
-
this.handleProgrammaticChange = checked => {
|
|
207
|
-
this.setState({
|
|
208
|
-
show: checked
|
|
209
|
-
});
|
|
210
|
-
};
|
|
211
|
-
this.shouldClose = () => {
|
|
212
|
-
console.log('shouldClose');
|
|
213
|
-
this.setState({ show: false });
|
|
214
|
-
};
|
|
215
|
-
this.shouldOpen = () => {
|
|
216
|
-
console.log('shouldOpen');
|
|
217
|
-
this.setState({ show: true });
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
render() {
|
|
222
|
-
return (
|
|
223
|
-
<div>
|
|
224
|
-
<div>
|
|
225
|
-
<span style={{ paddingRight: '10px' }}>Popover position</span>
|
|
226
|
-
<select
|
|
227
|
-
aria-label="Popover position"
|
|
228
|
-
onChange={event => {
|
|
229
|
-
this.setState({ position: event.target.value });
|
|
230
|
-
}}
|
|
231
|
-
>
|
|
232
|
-
{Object.values(PopoverPosition).map(position => (
|
|
233
|
-
<option key={position} value={position}>
|
|
234
|
-
{position}
|
|
235
|
-
</option>
|
|
236
|
-
))}
|
|
237
|
-
</select>
|
|
238
|
-
<Checkbox
|
|
239
|
-
label="Flip popover if the position falls outside the view"
|
|
240
|
-
isChecked={this.state.keepInViewChecked}
|
|
241
|
-
onChange={this.handleKeepInViewChange}
|
|
242
|
-
aria-label="Keep in view"
|
|
243
|
-
id="check-3"
|
|
244
|
-
/>
|
|
245
|
-
<Checkbox
|
|
246
|
-
label="Toggle popover from outside"
|
|
247
|
-
isChecked={this.state.show}
|
|
248
|
-
onChange={this.handleProgrammaticChange}
|
|
249
|
-
aria-label="Toggle popover from outside"
|
|
250
|
-
id="check-4"
|
|
251
|
-
/>
|
|
252
|
-
</div>
|
|
253
|
-
|
|
254
|
-
<div style={{ margin: '50px' }}>
|
|
255
|
-
<Popover
|
|
256
|
-
aria-label="Advanced popover usages example"
|
|
257
|
-
position={this.state.position}
|
|
258
|
-
hideOnOutsideClick={false}
|
|
259
|
-
isVisible={this.state.show}
|
|
260
|
-
shouldClose={this.shouldClose}
|
|
261
|
-
shouldOpen={this.shouldOpen}
|
|
262
|
-
enableFlip={this.state.keepInViewChecked}
|
|
263
|
-
appendTo={() => document.body}
|
|
264
|
-
headerContent={<div>Popover header</div>}
|
|
265
|
-
bodyContent={
|
|
266
|
-
<div>
|
|
267
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla turpis.
|
|
268
|
-
</div>
|
|
269
|
-
}
|
|
270
|
-
footerContent="Popover footer"
|
|
271
|
-
>
|
|
272
|
-
<Button>Toggle popover</Button>
|
|
273
|
-
</Popover>
|
|
274
|
-
</div>
|
|
275
|
-
</div>
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
56
|
+
```ts file="./PopoverAdvanced.tsx"
|
|
279
57
|
```
|
|
280
58
|
|
|
281
59
|
### Popover with icon in the title
|
|
282
60
|
|
|
283
|
-
```ts isBeta
|
|
284
|
-
import React from 'react';
|
|
285
|
-
import { Popover, Button } from '@patternfly/react-core';
|
|
286
|
-
import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon';
|
|
287
|
-
|
|
288
|
-
<div style={{ margin: '50px' }}>
|
|
289
|
-
<Popover
|
|
290
|
-
aria-label="Alert popover"
|
|
291
|
-
headerContent="Popover with icon"
|
|
292
|
-
headerIcon={<BullhornIcon />}
|
|
293
|
-
bodyContent={<div>Popovers are triggered by click rather than hover.</div>}
|
|
294
|
-
footerContent="Popover footer"
|
|
295
|
-
>
|
|
296
|
-
<Button>Toggle popover</Button>
|
|
297
|
-
</Popover>
|
|
298
|
-
</div>;
|
|
61
|
+
```ts file="./PopoverWithIconInTheTitle.tsx" isBeta
|
|
299
62
|
```
|
|
300
63
|
|
|
301
64
|
### Alert popover
|
|
302
65
|
|
|
303
|
-
```ts isBeta
|
|
304
|
-
import React from 'react';
|
|
305
|
-
import { Popover, Button } from '@patternfly/react-core';
|
|
306
|
-
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
307
|
-
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
|
|
308
|
-
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
309
|
-
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
|
|
310
|
-
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
311
|
-
|
|
312
|
-
const AlertPopover = () => {
|
|
313
|
-
const [alertSeverityVariant, setAlertSeverityVariant] = React.useState('default');
|
|
314
|
-
const alertIcons = {
|
|
315
|
-
default: <BellIcon />,
|
|
316
|
-
info: <InfoCircleIcon />,
|
|
317
|
-
success: <CheckCircleIcon />,
|
|
318
|
-
warning: <ExclamationTriangleIcon />,
|
|
319
|
-
danger: <ExclamationCircleIcon />
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
return (
|
|
323
|
-
<div>
|
|
324
|
-
<div>
|
|
325
|
-
<span style={{ paddingRight: '10px' }}>Alert variant:</span>
|
|
326
|
-
<select aria-label="Popover alert type" onChange={event => setAlertSeverityVariant(event.target.value)}>
|
|
327
|
-
<option value="default">default</option>
|
|
328
|
-
<option value="info">info</option>
|
|
329
|
-
<option value="success">success</option>
|
|
330
|
-
<option value="warning">warning</option>
|
|
331
|
-
<option value="danger">danger</option>
|
|
332
|
-
</select>
|
|
333
|
-
</div>
|
|
334
|
-
<div style={{ margin: '50px' }}>
|
|
335
|
-
<Popover
|
|
336
|
-
aria-label="Alert popover"
|
|
337
|
-
alertSeverityVariant={alertSeverityVariant as 'default' | 'info' | 'warning' | 'success' | 'danger'}
|
|
338
|
-
headerContent="Default popover title"
|
|
339
|
-
headerIcon={alertIcons[alertSeverityVariant]}
|
|
340
|
-
headerComponent="h1"
|
|
341
|
-
bodyContent={<div>Popovers are triggered by click rather than hover.</div>}
|
|
342
|
-
footerContent="Popover footer"
|
|
343
|
-
>
|
|
344
|
-
<Button>Toggle popover</Button>
|
|
345
|
-
</Popover>
|
|
346
|
-
</div>
|
|
347
|
-
</div>
|
|
348
|
-
);
|
|
349
|
-
};
|
|
66
|
+
```ts file="./PopoverAlert.tsx" isBeta
|
|
350
67
|
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover, PopoverPosition, Checkbox, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const PopoverAdvanced: React.FunctionComponent = () => {
|
|
5
|
+
const [position, setPosition] = React.useState(PopoverPosition.auto);
|
|
6
|
+
const [show, setShow] = React.useState(false);
|
|
7
|
+
const [keepInViewChecked, setKeepInViewChecked] = React.useState(true);
|
|
8
|
+
|
|
9
|
+
const handleKeepInViewChange = (checked: boolean) => {
|
|
10
|
+
setKeepInViewChecked(checked);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const handleProgrammaticChange = (checked: boolean) => {
|
|
14
|
+
setShow(checked);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const shouldClose = () => {
|
|
18
|
+
setShow(false);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const shouldOpen = () => {
|
|
22
|
+
setShow(true);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<div>
|
|
28
|
+
<span style={{ paddingRight: '10px' }}>Popover position</span>
|
|
29
|
+
<select
|
|
30
|
+
aria-label="Popover position"
|
|
31
|
+
onChange={event => {
|
|
32
|
+
setPosition(event.target.value as PopoverPosition);
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
{Object.values(PopoverPosition).map(position => (
|
|
36
|
+
<option key={position} value={position}>
|
|
37
|
+
{position}
|
|
38
|
+
</option>
|
|
39
|
+
))}
|
|
40
|
+
</select>
|
|
41
|
+
<Checkbox
|
|
42
|
+
label="Flip popover if the position falls outside the view"
|
|
43
|
+
isChecked={keepInViewChecked}
|
|
44
|
+
onChange={handleKeepInViewChange}
|
|
45
|
+
aria-label="Keep in view"
|
|
46
|
+
id="popover-advanced-check-1"
|
|
47
|
+
/>
|
|
48
|
+
<Checkbox
|
|
49
|
+
label="Toggle popover from outside"
|
|
50
|
+
isChecked={show}
|
|
51
|
+
onChange={handleProgrammaticChange}
|
|
52
|
+
aria-label="Toggle popover from outside"
|
|
53
|
+
id="popover-advanced-check-2"
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<div style={{ margin: '50px' }}>
|
|
58
|
+
<Popover
|
|
59
|
+
aria-label="Advanced popover usages example"
|
|
60
|
+
position={position}
|
|
61
|
+
hideOnOutsideClick={false}
|
|
62
|
+
isVisible={show}
|
|
63
|
+
shouldClose={shouldClose}
|
|
64
|
+
shouldOpen={shouldOpen}
|
|
65
|
+
enableFlip={keepInViewChecked}
|
|
66
|
+
headerContent={<div>Popover header</div>}
|
|
67
|
+
bodyContent={
|
|
68
|
+
<div>
|
|
69
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla turpis.
|
|
70
|
+
</div>
|
|
71
|
+
}
|
|
72
|
+
footerContent="Popover footer"
|
|
73
|
+
>
|
|
74
|
+
<Button>Toggle popover</Button>
|
|
75
|
+
</Popover>
|
|
76
|
+
</div>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover, Button } from '@patternfly/react-core';
|
|
3
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
4
|
+
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
|
|
5
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
6
|
+
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
|
|
7
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
8
|
+
|
|
9
|
+
export const AlertPopover: React.FunctionComponent = () => {
|
|
10
|
+
const [alertSeverityVariant, setAlertSeverityVariant] = React.useState('default');
|
|
11
|
+
|
|
12
|
+
const alertIcons = {
|
|
13
|
+
default: <BellIcon />,
|
|
14
|
+
info: <InfoCircleIcon />,
|
|
15
|
+
success: <CheckCircleIcon />,
|
|
16
|
+
warning: <ExclamationTriangleIcon />,
|
|
17
|
+
danger: <ExclamationCircleIcon />
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<div>
|
|
23
|
+
<span style={{ paddingRight: '10px' }}>Alert variant:</span>
|
|
24
|
+
<select aria-label="Popover alert type" onChange={event => setAlertSeverityVariant(event.target.value)}>
|
|
25
|
+
<option value="default">default</option>
|
|
26
|
+
<option value="info">info</option>
|
|
27
|
+
<option value="success">success</option>
|
|
28
|
+
<option value="warning">warning</option>
|
|
29
|
+
<option value="danger">danger</option>
|
|
30
|
+
</select>
|
|
31
|
+
</div>
|
|
32
|
+
<div style={{ margin: '50px' }}>
|
|
33
|
+
<Popover
|
|
34
|
+
aria-label="Alert popover"
|
|
35
|
+
alertSeverityVariant={alertSeverityVariant as 'default' | 'info' | 'warning' | 'success' | 'danger'}
|
|
36
|
+
headerContent="Default popover title"
|
|
37
|
+
headerIcon={alertIcons[alertSeverityVariant]}
|
|
38
|
+
headerComponent="h1"
|
|
39
|
+
bodyContent={<div>Popovers are triggered by click rather than hover.</div>}
|
|
40
|
+
footerContent="Popover footer"
|
|
41
|
+
>
|
|
42
|
+
<Button>Toggle popover</Button>
|
|
43
|
+
</Popover>
|
|
44
|
+
</div>
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const PopoverBasic: React.FunctionComponent = () => (
|
|
5
|
+
<div style={{ margin: '50px' }}>
|
|
6
|
+
<Popover
|
|
7
|
+
aria-label="Basic popover"
|
|
8
|
+
headerContent={<div>Popover header</div>}
|
|
9
|
+
bodyContent={<div>Popovers are triggered by click rather than hover.</div>}
|
|
10
|
+
footerContent="Popover footer"
|
|
11
|
+
>
|
|
12
|
+
<Button>Toggle popover</Button>
|
|
13
|
+
</Popover>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const PopoverCloseControlled: React.FunctionComponent = () => {
|
|
5
|
+
const [isVisible, setIsVisible] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<div style={{ margin: '50px' }}>
|
|
9
|
+
<Popover
|
|
10
|
+
aria-label="Popover with button in the body that can close it"
|
|
11
|
+
isVisible={isVisible}
|
|
12
|
+
shouldOpen={() => setIsVisible(true)}
|
|
13
|
+
shouldClose={() => setIsVisible(false)}
|
|
14
|
+
headerContent={<div>Popover header</div>}
|
|
15
|
+
bodyContent={
|
|
16
|
+
<div>
|
|
17
|
+
<div>A controlled popover can be closed by updating its isVisible state after some user interaction.</div>
|
|
18
|
+
<div>
|
|
19
|
+
<button onClick={() => setIsVisible(false)}>Close popover</button>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
}
|
|
23
|
+
footerContent="Popover footer"
|
|
24
|
+
>
|
|
25
|
+
<Button>Toggle popover</Button>
|
|
26
|
+
</Popover>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const PopoverCloseUncontrolled: React.FunctionComponent = () => (
|
|
5
|
+
<div style={{ margin: '50px' }}>
|
|
6
|
+
<Popover
|
|
7
|
+
aria-label="Uncontrolled popover with button in the body that can close it"
|
|
8
|
+
headerContent={<div>Popover header</div>}
|
|
9
|
+
bodyContent={hide => (
|
|
10
|
+
<div>
|
|
11
|
+
<div>
|
|
12
|
+
All the content props (headerContent, bodyContent, footerContent) can take a function which the popover
|
|
13
|
+
component passes the hide function to which can be used to close the popover after some user interaction.
|
|
14
|
+
</div>
|
|
15
|
+
<div>
|
|
16
|
+
<button onClick={hide}>Close popover</button>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
)}
|
|
20
|
+
footerContent="Popover footer"
|
|
21
|
+
>
|
|
22
|
+
<Button>Toggle popover</Button>
|
|
23
|
+
</Popover>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const PopoverReactRef: React.FunctionComponent = () => {
|
|
5
|
+
const popoverRef = React.useRef<HTMLButtonElement>(null);
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<div style={{ margin: '50px' }}>
|
|
9
|
+
<button ref={popoverRef}>Popover attached via react ref</button>
|
|
10
|
+
<Popover
|
|
11
|
+
aria-label="Popover with react reference example"
|
|
12
|
+
headerContent={<div>Popover header</div>}
|
|
13
|
+
bodyContent={
|
|
14
|
+
<div>
|
|
15
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla turpis.
|
|
16
|
+
</div>
|
|
17
|
+
}
|
|
18
|
+
footerContent="Popover footer"
|
|
19
|
+
reference={popoverRef}
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const PopoverSelectorRef: React.FunctionComponent = () => (
|
|
5
|
+
<div style={{ margin: '50px' }}>
|
|
6
|
+
<button id="popover-selector">Popover attached via selector ref</button>
|
|
7
|
+
<Popover
|
|
8
|
+
aria-label="Popover with selector reference example"
|
|
9
|
+
headerContent={<div>Popover header</div>}
|
|
10
|
+
bodyContent={
|
|
11
|
+
<div>
|
|
12
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla turpis.
|
|
13
|
+
</div>
|
|
14
|
+
}
|
|
15
|
+
footerContent="Popover footer"
|
|
16
|
+
reference={() => document.getElementById('popover-selector') as HTMLButtonElement}
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const PopoverWidthAuto: React.FunctionComponent = () => (
|
|
5
|
+
<div style={{ margin: '50px' }}>
|
|
6
|
+
<Popover
|
|
7
|
+
aria-label="Popover with auto-width"
|
|
8
|
+
hasAutoWidth
|
|
9
|
+
bodyContent={() => <div>Removes fixed-width and allows width to be defined by contents</div>}
|
|
10
|
+
>
|
|
11
|
+
<Button>Toggle popover</Button>
|
|
12
|
+
</Popover>
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover, Button } from '@patternfly/react-core';
|
|
3
|
+
import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon';
|
|
4
|
+
|
|
5
|
+
export const PopoverWithIconInTheTitle: React.FunctionComponent = () => (
|
|
6
|
+
<div style={{ margin: '50px' }}>
|
|
7
|
+
<Popover
|
|
8
|
+
aria-label="Popover with icon in the title example"
|
|
9
|
+
headerContent="Popover with icon"
|
|
10
|
+
headerIcon={<BullhornIcon />}
|
|
11
|
+
bodyContent={<div>Popovers are triggered by click rather than hover.</div>}
|
|
12
|
+
footerContent="Popover footer"
|
|
13
|
+
>
|
|
14
|
+
<Button>Toggle popover</Button>
|
|
15
|
+
</Popover>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const PopoverWithoutHeaderFooterCloseNoPadding: React.FunctionComponent = () => (
|
|
5
|
+
<div style={{ margin: '50px' }}>
|
|
6
|
+
<Popover
|
|
7
|
+
aria-label="Popover with no header, footer, close button, and padding"
|
|
8
|
+
hasNoPadding
|
|
9
|
+
showClose={false}
|
|
10
|
+
bodyContent={() => (
|
|
11
|
+
<div>
|
|
12
|
+
This popover has no padding and is intended for use with content that has its own spacing and should touch the
|
|
13
|
+
edges of the popover container.
|
|
14
|
+
</div>
|
|
15
|
+
)}
|
|
16
|
+
withFocusTrap={false /* no focusable content in this example */}
|
|
17
|
+
>
|
|
18
|
+
<Button>Toggle popover</Button>
|
|
19
|
+
</Popover>
|
|
20
|
+
</div>
|
|
21
|
+
);
|