@patternfly/react-core 4.176.0 → 4.177.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 +19 -0
- package/dist/esm/components/Dropdown/DropdownToggle.d.ts +3 -1
- package/dist/esm/components/Dropdown/DropdownToggle.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/DropdownToggle.js +4 -4
- package/dist/esm/components/Dropdown/DropdownToggle.js.map +1 -1
- package/dist/esm/components/Dropdown/Toggle.d.ts +3 -1
- package/dist/esm/components/Dropdown/Toggle.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/Toggle.js +8 -3
- package/dist/esm/components/Dropdown/Toggle.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggle.d.ts +3 -1
- package/dist/js/components/Dropdown/DropdownToggle.d.ts.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggle.js +4 -4
- package/dist/js/components/Dropdown/DropdownToggle.js.map +1 -1
- package/dist/js/components/Dropdown/Toggle.d.ts +3 -1
- package/dist/js/components/Dropdown/Toggle.d.ts.map +1 -1
- package/dist/js/components/Dropdown/Toggle.js +8 -3
- package/dist/js/components/Dropdown/Toggle.js.map +1 -1
- package/dist/umd/react-core.js +12 -7
- package/dist/umd/react-core.min.css +62 -62
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +5 -5
- package/src/components/Alert/examples/Alert.md +201 -382
- package/src/components/Alert/examples/AlertAsyncLiveRegion.tsx +61 -0
- package/src/components/Alert/examples/AlertDynamicLiveRegion.tsx +61 -0
- package/src/components/ApplicationLauncher/__tests__/__snapshots__/ApplicationLauncher.test.tsx.snap +6 -0
- package/src/components/Dropdown/DropdownToggle.tsx +6 -1
- package/src/components/Dropdown/Toggle.tsx +11 -1
- package/src/components/Dropdown/__tests__/DropdownToggle.test.tsx +51 -0
- package/src/components/Dropdown/__tests__/__snapshots__/Dropdown.test.tsx.snap +8 -0
- package/src/components/Dropdown/__tests__/__snapshots__/DropdownToggle.test.tsx.snap +346 -4
- package/src/components/Dropdown/__tests__/__snapshots__/Toggle.test.tsx.snap +1 -0
- package/src/components/Dropdown/examples/Dropdown.md +160 -91
- package/src/components/OptionsMenu/__tests__/__snapshots__/OptionsMenu.test.tsx.snap +7 -0
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +15 -0
- package/src/demos/CardDemos.md +65 -91
- package/src/demos/Tabs/NestedTabsDemo.js +151 -0
- package/src/demos/Tabs.md +4 -0
|
@@ -16,412 +16,245 @@ import LaptopIcon from '@patternfly/react-icons/dist/esm/icons/laptop-icon';
|
|
|
16
16
|
## Examples
|
|
17
17
|
|
|
18
18
|
### Types
|
|
19
|
-
```
|
|
19
|
+
```ts
|
|
20
20
|
import React from 'react';
|
|
21
21
|
import { Alert } from '@patternfly/react-core';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<Alert variant="warning" title="Warning alert title" />
|
|
31
|
-
<Alert variant="danger" title="Danger alert title" />
|
|
32
|
-
</React.Fragment>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
23
|
+
<React.Fragment>
|
|
24
|
+
<Alert title="Default alert title" />
|
|
25
|
+
<Alert variant="info" title="Info alert title" />
|
|
26
|
+
<Alert variant="success" title="Success alert title" />
|
|
27
|
+
<Alert variant="warning" title="Warning alert title" />
|
|
28
|
+
<Alert variant="danger" title="Danger alert title" />
|
|
29
|
+
</React.Fragment>
|
|
36
30
|
```
|
|
37
31
|
|
|
38
32
|
### Variations
|
|
39
|
-
```
|
|
33
|
+
```ts
|
|
40
34
|
import React from 'react';
|
|
41
35
|
import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core';
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
<React.Fragment>
|
|
38
|
+
<Alert
|
|
39
|
+
variant="success"
|
|
40
|
+
title="Success alert title"
|
|
41
|
+
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
42
|
+
actionLinks={
|
|
46
43
|
<React.Fragment>
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
title="Success alert title"
|
|
50
|
-
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
51
|
-
actionLinks={
|
|
52
|
-
<React.Fragment>
|
|
53
|
-
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
54
|
-
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
55
|
-
</React.Fragment>
|
|
56
|
-
}
|
|
57
|
-
>
|
|
58
|
-
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
59
|
-
</Alert>
|
|
60
|
-
<Alert variant="success" title="Success alert title" actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}>
|
|
61
|
-
<p>
|
|
62
|
-
Success alert description. This should tell the user more information about the alert.{' '}
|
|
63
|
-
<a href="#">This is a link.</a>
|
|
64
|
-
</p>
|
|
65
|
-
</Alert>
|
|
66
|
-
<Alert
|
|
67
|
-
variant="success"
|
|
68
|
-
title="Success alert title"
|
|
69
|
-
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
70
|
-
actionLinks={
|
|
71
|
-
<React.Fragment>
|
|
72
|
-
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
73
|
-
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
74
|
-
</React.Fragment>
|
|
75
|
-
}
|
|
76
|
-
/>
|
|
77
|
-
<Alert variant="success" title="Success alert title" actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />} />
|
|
78
|
-
<Alert variant="success" title="h1 Success alert title" titleHeadingLevel="h1" />
|
|
79
|
-
<Alert variant="success" title="h6 Success alert title" titleHeadingLevel="h6" />
|
|
44
|
+
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
45
|
+
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
80
46
|
</React.Fragment>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
47
|
+
}
|
|
48
|
+
>
|
|
49
|
+
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
50
|
+
</Alert>
|
|
51
|
+
<Alert variant="success" title="Success alert title" actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}>
|
|
52
|
+
<p>
|
|
53
|
+
Success alert description. This should tell the user more information about the alert.{' '}
|
|
54
|
+
<a href="#">This is a link.</a>
|
|
55
|
+
</p>
|
|
56
|
+
</Alert>
|
|
57
|
+
<Alert
|
|
58
|
+
variant="success"
|
|
59
|
+
title="Success alert title"
|
|
60
|
+
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
61
|
+
actionLinks={
|
|
62
|
+
<React.Fragment>
|
|
63
|
+
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
64
|
+
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
65
|
+
</React.Fragment>
|
|
66
|
+
}
|
|
67
|
+
/>
|
|
68
|
+
<Alert variant="success" title="Success alert title" actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />} />
|
|
69
|
+
<Alert variant="success" title="h1 Success alert title" titleHeadingLevel="h1" />
|
|
70
|
+
<Alert variant="success" title="h6 Success alert title" titleHeadingLevel="h6" />
|
|
71
|
+
</React.Fragment>
|
|
84
72
|
```
|
|
85
73
|
|
|
86
74
|
### Inline types
|
|
87
|
-
```
|
|
75
|
+
```ts
|
|
88
76
|
import React from 'react';
|
|
89
77
|
import { Alert } from '@patternfly/react-core';
|
|
90
78
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
<Alert variant="warning" isInline title="Warning inline alert title" />
|
|
99
|
-
<Alert variant="danger" isInline title="Danger inline alert title" />
|
|
100
|
-
</React.Fragment>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
79
|
+
<React.Fragment>
|
|
80
|
+
<Alert variant="default" isInline title="Default inline alert title" />
|
|
81
|
+
<Alert variant="info" isInline title="Info inline alert title" />
|
|
82
|
+
<Alert variant="success" isInline title="Success inline alert title" />
|
|
83
|
+
<Alert variant="warning" isInline title="Warning inline alert title" />
|
|
84
|
+
<Alert variant="danger" isInline title="Danger inline alert title" />
|
|
85
|
+
</React.Fragment>
|
|
104
86
|
```
|
|
105
87
|
|
|
106
88
|
### Inline variations
|
|
107
|
-
```
|
|
89
|
+
```ts
|
|
108
90
|
import React from 'react';
|
|
109
91
|
import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core';
|
|
110
92
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
93
|
+
<React.Fragment>
|
|
94
|
+
<Alert
|
|
95
|
+
isInline
|
|
96
|
+
variant="success"
|
|
97
|
+
title="Success alert title"
|
|
98
|
+
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
99
|
+
actionLinks={
|
|
114
100
|
<React.Fragment>
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
variant="success"
|
|
118
|
-
title="Success alert title"
|
|
119
|
-
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
120
|
-
actionLinks={
|
|
121
|
-
<React.Fragment>
|
|
122
|
-
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
123
|
-
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
124
|
-
</React.Fragment>
|
|
125
|
-
}
|
|
126
|
-
>
|
|
127
|
-
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
128
|
-
</Alert>
|
|
129
|
-
<Alert isInline variant="success" title="Success alert title" actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}>
|
|
130
|
-
<p>
|
|
131
|
-
Success alert description. This should tell the user more information about the alert.{' '}
|
|
132
|
-
<a href="#">This is a link.</a>
|
|
133
|
-
</p>
|
|
134
|
-
</Alert>
|
|
135
|
-
<Alert
|
|
136
|
-
isInline
|
|
137
|
-
variant="success"
|
|
138
|
-
title="Success alert title"
|
|
139
|
-
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
140
|
-
actionLinks={
|
|
141
|
-
<React.Fragment>
|
|
142
|
-
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
143
|
-
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
144
|
-
</React.Fragment>
|
|
145
|
-
}
|
|
146
|
-
/>
|
|
147
|
-
<Alert
|
|
148
|
-
isInline
|
|
149
|
-
variant="success"
|
|
150
|
-
title="Success alert title"
|
|
151
|
-
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
152
|
-
/>
|
|
153
|
-
<Alert isInline variant="success" title="Success alert title" />
|
|
101
|
+
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
102
|
+
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
154
103
|
</React.Fragment>
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
104
|
+
}
|
|
105
|
+
>
|
|
106
|
+
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
107
|
+
</Alert>
|
|
108
|
+
<Alert isInline variant="success" title="Success alert title" actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}>
|
|
109
|
+
<p>
|
|
110
|
+
Success alert description. This should tell the user more information about the alert.{' '}
|
|
111
|
+
<a href="#">This is a link.</a>
|
|
112
|
+
</p>
|
|
113
|
+
</Alert>
|
|
114
|
+
<Alert
|
|
115
|
+
isInline
|
|
116
|
+
variant="success"
|
|
117
|
+
title="Success alert title"
|
|
118
|
+
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
119
|
+
actionLinks={
|
|
120
|
+
<React.Fragment>
|
|
121
|
+
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
122
|
+
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
123
|
+
</React.Fragment>
|
|
124
|
+
}
|
|
125
|
+
/>
|
|
126
|
+
<Alert
|
|
127
|
+
isInline
|
|
128
|
+
variant="success"
|
|
129
|
+
title="Success alert title"
|
|
130
|
+
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
131
|
+
/>
|
|
132
|
+
<Alert isInline variant="success" title="Success alert title" />
|
|
133
|
+
</React.Fragment>
|
|
158
134
|
```
|
|
159
135
|
|
|
160
136
|
### Inline plain types
|
|
161
|
-
```
|
|
137
|
+
```ts
|
|
162
138
|
import React from 'react';
|
|
163
139
|
import { Alert } from '@patternfly/react-core';
|
|
164
140
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
<Alert variant="warning" isInline isPlain title="Warning inline alert title" />
|
|
173
|
-
<Alert variant="danger" isInline isPlain title="Danger inline alert title" />
|
|
174
|
-
</React.Fragment>
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
141
|
+
<React.Fragment>
|
|
142
|
+
<Alert variant="default" isInline isPlain title="Default inline alert title" />
|
|
143
|
+
<Alert variant="info" isInline isPlain title="Info inline alert title" />
|
|
144
|
+
<Alert variant="success" isInline isPlain title="Success inline alert title" />
|
|
145
|
+
<Alert variant="warning" isInline isPlain title="Warning inline alert title" />
|
|
146
|
+
<Alert variant="danger" isInline isPlain title="Danger inline alert title" />
|
|
147
|
+
</React.Fragment>
|
|
178
148
|
```
|
|
179
149
|
|
|
180
150
|
### Inline plain variations
|
|
181
151
|
|
|
182
152
|
It is not recommended to use an inline plain alert with actionClose nor actionLinks.
|
|
183
153
|
|
|
184
|
-
```
|
|
154
|
+
```ts
|
|
185
155
|
import React from 'react';
|
|
186
156
|
import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core';
|
|
187
157
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
>
|
|
197
|
-
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
198
|
-
</Alert>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
158
|
+
<Alert
|
|
159
|
+
isInline
|
|
160
|
+
isPlain
|
|
161
|
+
variant="success"
|
|
162
|
+
title="Success alert title"
|
|
163
|
+
>
|
|
164
|
+
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
165
|
+
</Alert>
|
|
202
166
|
```
|
|
203
167
|
|
|
204
168
|
### Expandable
|
|
205
169
|
|
|
206
170
|
It is not recommended to use an expandable alert within a toast Alert group. In such a case, the Alert could timeout before users would have time to interact and view the entire Alert.
|
|
207
171
|
|
|
208
|
-
```
|
|
172
|
+
```ts
|
|
209
173
|
import React from 'react';
|
|
210
174
|
import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core';
|
|
211
175
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
176
|
+
<React.Fragment>
|
|
177
|
+
<Alert
|
|
178
|
+
isExpandable
|
|
179
|
+
variant="success"
|
|
180
|
+
title="Success alert title"
|
|
181
|
+
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
182
|
+
actionLinks={
|
|
215
183
|
<React.Fragment>
|
|
216
|
-
<
|
|
217
|
-
|
|
218
|
-
variant="success"
|
|
219
|
-
title="Success alert title"
|
|
220
|
-
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
221
|
-
actionLinks={
|
|
222
|
-
<React.Fragment>
|
|
223
|
-
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
224
|
-
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
225
|
-
</React.Fragment>
|
|
226
|
-
}
|
|
227
|
-
>
|
|
228
|
-
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
229
|
-
</Alert>
|
|
230
|
-
<Alert
|
|
231
|
-
isExpandable
|
|
232
|
-
isInline
|
|
233
|
-
variant="success"
|
|
234
|
-
title="Success alert title"
|
|
235
|
-
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
236
|
-
actionLinks={
|
|
237
|
-
<React.Fragment>
|
|
238
|
-
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
239
|
-
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
240
|
-
</React.Fragment>
|
|
241
|
-
}
|
|
242
|
-
>
|
|
243
|
-
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
244
|
-
</Alert>
|
|
184
|
+
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
185
|
+
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
245
186
|
</React.Fragment>
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
187
|
+
}
|
|
188
|
+
>
|
|
189
|
+
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
190
|
+
</Alert>
|
|
191
|
+
<Alert
|
|
192
|
+
isExpandable
|
|
193
|
+
isInline
|
|
194
|
+
variant="success"
|
|
195
|
+
title="Success alert title"
|
|
196
|
+
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
197
|
+
actionLinks={
|
|
198
|
+
<React.Fragment>
|
|
199
|
+
<AlertActionLink onClick={() => alert('Clicked on View details')}>View details</AlertActionLink>
|
|
200
|
+
<AlertActionLink onClick={() => alert('Clicked on Ignore')}>Ignore</AlertActionLink>
|
|
201
|
+
</React.Fragment>
|
|
202
|
+
}
|
|
203
|
+
>
|
|
204
|
+
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
205
|
+
</Alert>
|
|
206
|
+
</React.Fragment>
|
|
249
207
|
```
|
|
250
208
|
|
|
251
209
|
### Static live region alert
|
|
252
|
-
```
|
|
210
|
+
```ts
|
|
253
211
|
import React from 'react';
|
|
254
212
|
import { Alert, AlertActionCloseButton } from '@patternfly/react-core';
|
|
255
213
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
the containing element.
|
|
278
|
-
</Alert>
|
|
279
|
-
</React.Fragment>
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
214
|
+
<React.Fragment>
|
|
215
|
+
<Alert
|
|
216
|
+
isLiveRegion
|
|
217
|
+
variant="info"
|
|
218
|
+
title="Default live region configuration"
|
|
219
|
+
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
220
|
+
>
|
|
221
|
+
This alert uses the recommended <code>isLiveRegion</code> prop to automatically set ARIA attributes and CSS classes.
|
|
222
|
+
</Alert>
|
|
223
|
+
<Alert
|
|
224
|
+
aria-live="assertive"
|
|
225
|
+
aria-relevant="additions text"
|
|
226
|
+
aria-atomic="true"
|
|
227
|
+
variant="info"
|
|
228
|
+
title="Customized live region"
|
|
229
|
+
actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />}
|
|
230
|
+
>
|
|
231
|
+
You can alternatively omit the <code>isLiveRegion</code> prop to specify ARIA attributes and CSS manually on
|
|
232
|
+
the containing element.
|
|
233
|
+
</Alert>
|
|
234
|
+
</React.Fragment>
|
|
283
235
|
```
|
|
284
236
|
|
|
285
237
|
### Dynamic live region alert
|
|
286
238
|
Alerts asynchronously appended into dynamic AlertGroups with isLiveRegion will be announced to assistive technology at the moment the change happens, following the strategy used for aria-atomic, which defaults to false. This means only changes of type "addition" will be announced.
|
|
287
|
-
```
|
|
288
|
-
import React from 'react';
|
|
289
|
-
import { Alert, AlertGroup, InputGroup } from '@patternfly/react-core';
|
|
290
|
-
|
|
291
|
-
class DynamicLiveRegionAlert extends React.Component {
|
|
292
|
-
constructor() {
|
|
293
|
-
super();
|
|
294
|
-
this.state = {
|
|
295
|
-
alerts: []
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
render() {
|
|
300
|
-
const addAlert = alertProps => {
|
|
301
|
-
this.setState({ alerts: [...this.state.alerts, alertProps] });
|
|
302
|
-
};
|
|
303
|
-
const getUniqueId = () => new Date().getTime();
|
|
304
|
-
const addSuccessAlert = () => {
|
|
305
|
-
addAlert({
|
|
306
|
-
title: 'Single success alert',
|
|
307
|
-
variant: 'success',
|
|
308
|
-
key: getUniqueId()
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
const addInfoAlert = () => {
|
|
312
|
-
addAlert({
|
|
313
|
-
title: 'Single info alert',
|
|
314
|
-
variant: 'info',
|
|
315
|
-
key: getUniqueId()
|
|
316
|
-
});
|
|
317
|
-
};
|
|
318
|
-
const addDangerAlert = () => {
|
|
319
|
-
addAlert({
|
|
320
|
-
title: 'Single danger alert',
|
|
321
|
-
variant: 'danger',
|
|
322
|
-
key: getUniqueId()
|
|
323
|
-
});
|
|
324
|
-
};
|
|
325
|
-
const btnClasses = ['pf-c-button', 'pf-m-secondary'].join(' ');
|
|
326
|
-
return (
|
|
327
|
-
<React.Fragment>
|
|
328
|
-
<InputGroup style={{ marginBottom: '16px' }}>
|
|
329
|
-
<button onClick={addSuccessAlert} type="button" className={btnClasses}>
|
|
330
|
-
Add single success alert
|
|
331
|
-
</button>
|
|
332
|
-
<button onClick={addInfoAlert} type="button" className={btnClasses}>
|
|
333
|
-
Add single info alert
|
|
334
|
-
</button>
|
|
335
|
-
<button onClick={addDangerAlert} type="button" className={btnClasses}>
|
|
336
|
-
Add single danger alert
|
|
337
|
-
</button>
|
|
338
|
-
</InputGroup>
|
|
339
|
-
<AlertGroup isLiveRegion aria-live="polite" aria-relevant="additions text" aria-atomic="false">
|
|
340
|
-
{this.state.alerts.map(({ title, variant, isLiveRegion, ariaLive, ariaRelevant, ariaAtomic, key }) => (
|
|
341
|
-
<Alert
|
|
342
|
-
variant={variant}
|
|
343
|
-
title={title}
|
|
344
|
-
key={key}
|
|
345
|
-
/>
|
|
346
|
-
))}
|
|
347
|
-
</AlertGroup>
|
|
348
|
-
</React.Fragment>
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
239
|
+
```ts file="AlertDynamicLiveRegion.tsx"
|
|
352
240
|
```
|
|
353
241
|
|
|
354
242
|
### Async live region alert
|
|
355
243
|
This shows how an alert could be triggered by an asynchronous event in the application. Note that you can customize how the alert will be announced to assistive technology. See the alert accessibility tab for more information.
|
|
356
|
-
```
|
|
357
|
-
import React from 'react';
|
|
358
|
-
import { Alert, AlertGroup, InputGroup } from '@patternfly/react-core';
|
|
359
|
-
|
|
360
|
-
class AsyncLiveRegionAlert extends React.Component {
|
|
361
|
-
constructor() {
|
|
362
|
-
super();
|
|
363
|
-
this.state = {
|
|
364
|
-
alerts: [],
|
|
365
|
-
timer: null
|
|
366
|
-
};
|
|
367
|
-
this.stopAsyncAlerts = () => {
|
|
368
|
-
clearInterval(this.state.timer);
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
componentWillUnmount() {
|
|
372
|
-
this.stopAsyncAlerts();
|
|
373
|
-
}
|
|
374
|
-
render() {
|
|
375
|
-
const addAlert = incomingAlerts => {
|
|
376
|
-
this.setState({ alerts: [...this.state.alerts, incomingAlerts] });
|
|
377
|
-
};
|
|
378
|
-
const getUniqueId = () => new Date().getTime();
|
|
379
|
-
const startAsyncAlerts = () => {
|
|
380
|
-
let timerValue = setInterval(() => {
|
|
381
|
-
addAlert({
|
|
382
|
-
title: `Async alert number ${this.state.alerts.length + 1}`,
|
|
383
|
-
variant: 'info',
|
|
384
|
-
key: getUniqueId()
|
|
385
|
-
});
|
|
386
|
-
}, 4500);
|
|
387
|
-
this.setState({ timer: timerValue });
|
|
388
|
-
};
|
|
389
|
-
const btnClasses = ['pf-c-button', 'pf-m-secondary'].join(' ');
|
|
390
|
-
return (
|
|
391
|
-
<React.Fragment>
|
|
392
|
-
<InputGroup style={{ marginBottom: '16px' }}>
|
|
393
|
-
<button onClick={startAsyncAlerts} type="button" className={btnClasses}>
|
|
394
|
-
Start async info alerts
|
|
395
|
-
</button>
|
|
396
|
-
<button onClick={this.stopAsyncAlerts} type="button" className={btnClasses}>
|
|
397
|
-
Stop async info alerts
|
|
398
|
-
</button>
|
|
399
|
-
</InputGroup>
|
|
400
|
-
<AlertGroup isLiveRegion>
|
|
401
|
-
{this.state.alerts.map(({ title, variant, key }) => (
|
|
402
|
-
<Alert variant={variant} title={title} key={key} />
|
|
403
|
-
))}
|
|
404
|
-
</AlertGroup>
|
|
405
|
-
</React.Fragment>
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
244
|
+
```ts file="AlertAsyncLiveRegion.tsx"
|
|
409
245
|
```
|
|
410
246
|
|
|
411
247
|
### Alert timeout
|
|
412
|
-
```
|
|
248
|
+
```ts
|
|
413
249
|
import React from 'react';
|
|
414
250
|
import { Alert, AlertActionLink, AlertGroup, Button } from '@patternfly/react-core';
|
|
415
251
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
this.onClick = () => {
|
|
423
|
-
const timeout = 8000;
|
|
424
|
-
this.state.alerts.push(
|
|
252
|
+
const AlertTimeout: React.FunctionComponent = () => {
|
|
253
|
+
const [alerts, setAlerts] = React.useState<React.ReactNode[]>([]);
|
|
254
|
+
const onClick = () => {
|
|
255
|
+
const timeout = 8000;
|
|
256
|
+
setAlerts(prevAlerts => {
|
|
257
|
+
return [...prevAlerts,
|
|
425
258
|
<Alert title="Default timeout Alert" timeout={timeout} actionLinks={
|
|
426
259
|
<React.Fragment>
|
|
427
260
|
<AlertActionLink>View details</AlertActionLink>
|
|
@@ -430,50 +263,42 @@ class AlertTimeout extends React.Component {
|
|
|
430
263
|
}>
|
|
431
264
|
This alert will dismiss after {`${timeout / 1000} seconds`}
|
|
432
265
|
</Alert>
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
};
|
|
266
|
+
]
|
|
267
|
+
});
|
|
436
268
|
}
|
|
437
269
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
<
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
}
|
|
270
|
+
return (
|
|
271
|
+
<React.Fragment>
|
|
272
|
+
<Button variant="secondary" onClick={onClick}>Add alert</Button>
|
|
273
|
+
<Button variant="secondary" onClick={() => setAlerts([])}>Remove all alerts</Button>
|
|
274
|
+
<AlertGroup isLiveRegion>
|
|
275
|
+
{alerts}
|
|
276
|
+
</AlertGroup>
|
|
277
|
+
</React.Fragment>
|
|
278
|
+
);
|
|
279
|
+
};
|
|
450
280
|
```
|
|
451
281
|
|
|
452
282
|
### Truncate
|
|
453
|
-
```
|
|
283
|
+
```ts
|
|
454
284
|
import React from 'react';
|
|
455
285
|
import { Alert } from '@patternfly/react-core';
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
`} />
|
|
469
|
-
</React.Fragment>
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
286
|
+
|
|
287
|
+
<React.Fragment>
|
|
288
|
+
<Alert variant="info" truncateTitle={1} title={`
|
|
289
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pellentesque neque cursus enim fringilla tincidunt. Proin lobortis aliquam dictum. Nam vel ullamcorper nulla, nec blandit dolor. Vivamus pellentesque neque justo, nec accumsan nulla rhoncus id. Suspendisse mollis, tortor quis faucibus volutpat, sem leo fringilla turpis, ac lacinia augue metus in nulla. Cras vestibulum lacinia orci. Pellentesque sodales consequat interdum. Sed porttitor tincidunt metus nec iaculis. Pellentesque non commodo justo. Morbi feugiat rhoncus neque, vitae facilisis diam aliquam nec. Sed dapibus vitae quam at tristique. Nunc vel commodo mi. Mauris et rhoncus leo.
|
|
290
|
+
`} />
|
|
291
|
+
<Alert variant="warning" truncateTitle={2} title={`
|
|
292
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pellentesque neque cursus enim fringilla tincidunt. Proin lobortis aliquam dictum. Nam vel ullamcorper nulla, nec blandit dolor. Vivamus pellentesque neque justo, nec accumsan nulla rhoncus id. Suspendisse mollis, tortor quis faucibus volutpat, sem leo fringilla turpis, ac lacinia augue metus in nulla. Cras vestibulum lacinia orci. Pellentesque sodales consequat interdum. Sed porttitor tincidunt metus nec iaculis. Pellentesque non commodo justo. Morbi feugiat rhoncus neque, vitae facilisis diam aliquam nec. Sed dapibus vitae quam at tristique. Nunc vel commodo mi. Mauris et rhoncus leo.
|
|
293
|
+
`} />
|
|
294
|
+
<Alert variant="danger" truncateTitle={3} title={`
|
|
295
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pellentesque neque cursus enim fringilla tincidunt. Proin lobortis aliquam dictum. Nam vel ullamcorper nulla, nec blandit dolor. Vivamus pellentesque neque justo, nec accumsan nulla rhoncus id. Suspendisse mollis, tortor quis faucibus volutpat, sem leo fringilla turpis, ac lacinia augue metus in nulla. Cras vestibulum lacinia orci. Pellentesque sodales consequat interdum. Sed porttitor tincidunt metus nec iaculis. Pellentesque non commodo justo. Morbi feugiat rhoncus neque, vitae facilisis diam aliquam nec. Sed dapibus vitae quam at tristique. Nunc vel commodo mi. Mauris et rhoncus leo.
|
|
296
|
+
`} />
|
|
297
|
+
</React.Fragment>
|
|
473
298
|
```
|
|
474
299
|
|
|
475
300
|
### Custom icons
|
|
476
|
-
```
|
|
301
|
+
```ts
|
|
477
302
|
import React from 'react';
|
|
478
303
|
import { Alert } from '@patternfly/react-core';
|
|
479
304
|
import UsersIcon from '@patternfly/react-icons/dist/esm/icons/users-icon';
|
|
@@ -482,17 +307,11 @@ import DatabaseIcon from '@patternfly/react-icons/dist/esm/icons/database-icon';
|
|
|
482
307
|
import ServerIcon from '@patternfly/react-icons/dist/esm/icons/server-icon';
|
|
483
308
|
import LaptopIcon from '@patternfly/react-icons/dist/esm/icons/laptop-icon';
|
|
484
309
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
<Alert customIcon={<ServerIcon />} variant="warning" title="Warning alert title" />
|
|
493
|
-
<Alert customIcon={<LaptopIcon />} variant="danger" title="Danger alert title" />
|
|
494
|
-
</React.Fragment>
|
|
495
|
-
);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
310
|
+
<React.Fragment>
|
|
311
|
+
<Alert customIcon={<UsersIcon />} title="Default alert title" />
|
|
312
|
+
<Alert customIcon={<BoxIcon />} variant="info" title="Info alert title" />
|
|
313
|
+
<Alert customIcon={<DatabaseIcon />} variant="success" title="Success alert title" />
|
|
314
|
+
<Alert customIcon={<ServerIcon />} variant="warning" title="Warning alert title" />
|
|
315
|
+
<Alert customIcon={<LaptopIcon />} variant="danger" title="Danger alert title" />
|
|
316
|
+
</React.Fragment>
|
|
498
317
|
```
|