Skip to content

Commit eca701f

Browse files
committed
fix(deps): Apply JSX tranform changes to missed demos and examples
1 parent dace189 commit eca701f

File tree

212 files changed

+933
-830
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+933
-830
lines changed

packages/react-core/src/components/ActionList/examples/ActionList.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cssPrefix: pf-v6-c-action-list
55
propComponents: ['ActionList', 'ActionListGroup', 'ActionListItem']
66
---
77

8-
import { Fragment } from 'react';
8+
import { Fragment, useState } from 'react';
99
import TimesIcon from '@patternfly/react-icons/dist/js/icons/times-icon';
1010
import CheckIcon from '@patternfly/react-icons/dist/js/icons/check-icon';
1111
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';

packages/react-core/src/components/ActionList/examples/ActionListSingleGroup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fragment } from 'react';
1+
import { Fragment, useState } from 'react';
22
import {
33
ActionList,
44
ActionListGroup,
@@ -14,7 +14,7 @@ import {
1414
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
1515

1616
export const ActionListSingleGroup: React.FunctionComponent = () => {
17-
const [isOpen, setIsOpen] = React.useState(false);
17+
const [isOpen, setIsOpen] = useState(false);
1818

1919
const onToggle = () => {
2020
setIsOpen(!isOpen);

packages/react-core/src/components/Alert/examples/Alert.md

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ouia: true
77
---
88

99
import './alert.css';
10-
import { Fragment, useState } from 'react';
10+
import { Fragment, useEffect, useState } from 'react';
1111
import UsersIcon from '@patternfly/react-icons/dist/esm/icons/users-icon';
1212
import BoxIcon from '@patternfly/react-icons/dist/esm/icons/box-icon';
1313
import DatabaseIcon from '@patternfly/react-icons/dist/esm/icons/database-icon';
@@ -30,15 +30,16 @@ PatternFly supports several alert variants for different scenarios. Each variant
3030
| Danger | Use to indicate that a critical or blocking error has occurred |
3131

3232
```ts
33+
import { Fragment } from 'react';
3334
import { Alert } from '@patternfly/react-core';
3435

35-
<React.Fragment>
36+
<Fragment>
3637
<Alert title="Custom alert title" ouiaId="CustomAlert" />
3738
<Alert variant="info" title="Info alert title" ouiaId="InfoAlert" />
3839
<Alert variant="success" title="Success alert title" ouiaId="SuccessAlert" />
3940
<Alert variant="warning" title="Warning alert title" ouiaId="WarningAlert" />
4041
<Alert variant="danger" title="Danger alert title" ouiaId="DangerAlert" />
41-
</React.Fragment>;
42+
</Fragment>;
4243
```
4344

4445
### Alert variations
@@ -56,14 +57,15 @@ PatternFly supports several properties and variations that can be used to add ex
5657
- If there is a description passed via `children` prop, then the `component` prop should be a heading element. Headings should be ordered by their level and heading levels should not be skipped. For example, a heading of an `h2` level should not be followed directly by an `h4`.
5758

5859
```ts
60+
import { Fragment } from 'react';
5961
import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core';
6062

61-
<React.Fragment>
63+
<Fragment>
6264
<Alert
6365
variant="success"
6466
title="Success alert title"
6567
actionLinks={
66-
<React.Fragment>
68+
<Fragment>
6769
<AlertActionLink component="a" href="#">
6870
View details
6971
</AlertActionLink>
@@ -72,7 +74,7 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac
7274
>
7375
Ignore
7476
</AlertActionLink>
75-
</React.Fragment>
77+
</Fragment>
7678
}
7779
>
7880
<p>Success alert description. This should tell the user more information about the alert.</p>
@@ -95,19 +97,20 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac
9597
<Alert variant="success" title="h6 Success alert title" component="h6">
9698
<p>Short alert description.</p>
9799
</Alert>
98-
</React.Fragment>;
100+
</Fragment>;
99101
```
100102
101103
### Alert timeout
102104
103105
Use the `timeout` property to automatically dismiss an alert after a period of time. If set to `true`, the `timeout` will be 8000 milliseconds. Provide a specific value to dismiss the alert after a different number of milliseconds.
104106
105107
```ts
108+
import { Fragment, useState } from 'react';
106109
import { Alert, AlertActionLink, AlertGroup, Button } from '@patternfly/react-core';
107110

108111
const AlertTimeout: React.FunctionComponent = () => {
109-
const [alerts, setAlerts] = React.useState<React.ReactNode[]>([]);
110-
const [newAlertKey, setNewAlertKey] = React.useState<number>(0);
112+
const [alerts, setAlerts] = useState<React.ReactNode[]>([]);
113+
const [newAlertKey, setNewAlertKey] = useState<number>(0);
111114

112115
const onClick = () => {
113116
const timeout = 8000;
@@ -119,7 +122,7 @@ const AlertTimeout: React.FunctionComponent = () => {
119122
title="Default timeout Alert"
120123
timeout={timeout}
121124
actionLinks={
122-
<React.Fragment>
125+
<Fragment>
123126
<AlertActionLink component="a" href="#">
124127
View details
125128
</AlertActionLink>
@@ -128,7 +131,7 @@ const AlertTimeout: React.FunctionComponent = () => {
128131
>
129132
Ignore
130133
</AlertActionLink>
131-
</React.Fragment>
134+
</Fragment>
132135
}
133136
key={newAlertKey}
134137
>
@@ -139,15 +142,15 @@ const AlertTimeout: React.FunctionComponent = () => {
139142
};
140143

141144
return (
142-
<React.Fragment>
145+
<Fragment>
143146
<Button variant="secondary" onClick={onClick}>
144147
Add alert
145148
</Button>
146149
<Button variant="secondary" onClick={() => setAlerts([])}>
147150
Remove all alerts
148151
</Button>
149152
<AlertGroup isLiveRegion>{alerts}</AlertGroup>
150-
</React.Fragment>
153+
</Fragment>
151154
);
152155
};
153156
```
@@ -161,9 +164,10 @@ It is not recommended to use an expandable alert with a `timeout` in a [toast al
161164
See the [toast alert considerations](/components/alert/accessibility#toast-alerts) section of the alert accessibility documentation to understand the accessibility risks associated with using toast alerts.
162165
163166
```ts
167+
import { Fragment } from 'react';
164168
import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core';
165169

166-
<React.Fragment>
170+
<Fragment>
167171
<Alert
168172
isExpandable
169173
variant="success"
@@ -179,7 +183,7 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac
179183
variant="success"
180184
title="Success alert title"
181185
actionLinks={
182-
<React.Fragment>
186+
<Fragment>
183187
<AlertActionLink component="a" href="#">
184188
View details
185189
</AlertActionLink>
@@ -188,22 +192,23 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac
188192
>
189193
Ignore
190194
</AlertActionLink>
191-
</React.Fragment>
195+
</Fragment>
192196
}
193197
>
194198
<p>Success alert description. This should tell the user more information about the alert.</p>
195199
</Alert>
196-
</React.Fragment>;
200+
</Fragment>;
197201
```
198202
199203
### Truncated alerts
200204
201205
Use the `truncateTitle` property to shorten a long `title`. Set `truncateTitle` equal to a number (passed in as `{n}`) to reduce the number of lines of text in the alert's `title`. Users may hover over or tab to a truncated `title` to see the full message in a tooltip.
202206
203207
```ts
208+
import { Fragment } from 'react';
204209
import { Alert } from '@patternfly/react-core';
205210

206-
<React.Fragment>
211+
<Fragment>
207212
<Alert
208213
variant="info"
209214
truncateTitle={1}
@@ -225,58 +230,61 @@ import { Alert } from '@patternfly/react-core';
225230
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.
226231
`}
227232
/>
228-
</React.Fragment>;
233+
</Fragment>;
229234
```
230235
231236
### Custom icons
232237
233238
Use the `customIcon` property to replace a default alert icon with a custom icon.
234239
235240
```ts
241+
import { Fragment } from 'react';
236242
import { Alert } from '@patternfly/react-core';
237243
import UsersIcon from '@patternfly/react-icons/dist/esm/icons/users-icon';
238244
import BoxIcon from '@patternfly/react-icons/dist/esm/icons/box-icon';
239245
import DatabaseIcon from '@patternfly/react-icons/dist/esm/icons/database-icon';
240246
import ServerIcon from '@patternfly/react-icons/dist/esm/icons/server-icon';
241247
import LaptopIcon from '@patternfly/react-icons/dist/esm/icons/laptop-icon';
242248

243-
<React.Fragment>
249+
<Fragment>
244250
<Alert customIcon={<UsersIcon />} title="Default alert title" />
245251
<Alert customIcon={<BoxIcon />} variant="info" title="Info alert title" />
246252
<Alert customIcon={<DatabaseIcon />} variant="success" title="Success alert title" />
247253
<Alert customIcon={<ServerIcon />} variant="warning" title="Warning alert title" />
248254
<Alert customIcon={<LaptopIcon />} variant="danger" title="Danger alert title" />
249-
</React.Fragment>;
255+
</Fragment>;
250256
```
251257
252258
### Inline alerts variants
253259
254260
Use inline alerts to display an alert inline with content. All alert variants may use the `isInline` property to position alerts in content-heavy areas, such as within forms, wizards, or drawers.
255261
256262
```ts
263+
import { Fragment } from 'react';
257264
import { Alert } from '@patternfly/react-core';
258-
<React.Fragment>
265+
<Fragment>
259266
<Alert variant="custom" isInline title="Custom inline alert title" />
260267
<Alert variant="info" isInline title="Info inline alert title" />
261268
<Alert variant="success" isInline title="Success inline alert title" />
262269
<Alert variant="warning" isInline title="Warning inline alert title" />
263270
<Alert variant="danger" isInline title="Danger inline alert title" />
264-
</React.Fragment>;
271+
</Fragment>;
265272
```
266273
267274
### Inline alert variations
268275
269276
All general alert variations can use the `isInline` property to apply inline styling.
270277
271278
```ts
279+
import { Fragment } from 'react';
272280
import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core';
273-
<React.Fragment>
281+
<Fragment>
274282
<Alert
275283
isInline
276284
variant="success"
277285
title="Success alert title"
278286
actionLinks={
279-
<React.Fragment>
287+
<Fragment>
280288
<AlertActionLink component="a" href="#">
281289
View details
282290
</AlertActionLink>
@@ -285,7 +293,7 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac
285293
>
286294
Ignore
287295
</AlertActionLink>
288-
</React.Fragment>
296+
</Fragment>
289297
}
290298
>
291299
<p>Success alert description. This should tell the user more information about the alert.</p>
@@ -309,22 +317,23 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac
309317
<Alert isInline variant="success" title="h6 Success alert title" component="h6">
310318
<p>Short alert description.</p>
311319
</Alert>
312-
</React.Fragment>;
320+
</Fragment>;
313321
```
314322
315323
### Plain inline alert variants
316324
317325
Use the `isPlain` property to make any inline alert plain. Plain styling removes the colored background but keeps colored text and icons.
318326
319327
```ts
328+
import { Fragment } from 'react';
320329
import { Alert } from '@patternfly/react-core';
321-
<React.Fragment>
330+
<Fragment>
322331
<Alert variant="custom" isInline isPlain title="Custom inline alert title" />
323332
<Alert variant="info" isInline isPlain title="Info inline alert title" />
324333
<Alert variant="success" isInline isPlain title="Success inline alert title" />
325334
<Alert variant="warning" isInline isPlain title="Warning inline alert title" />
326335
<Alert variant="danger" isInline isPlain title="Danger inline alert title" />
327-
</React.Fragment>;
336+
</Fragment>;
328337
```
329338
330339
### Plain inline alert variations
@@ -345,9 +354,10 @@ Live region alerts allow you to expose dynamic content changes in a way that can
345354
By default, `isLiveRegion`alerts are static.
346355
347356
```ts
357+
import { Fragment } from 'react';
348358
import { Alert, AlertActionCloseButton } from '@patternfly/react-core';
349359

350-
<React.Fragment>
360+
<Fragment>
351361
<Alert
352362
isLiveRegion
353363
variant="info"
@@ -369,7 +379,7 @@ import { Alert, AlertActionCloseButton } from '@patternfly/react-core';
369379
You can alternatively omit the <code>isLiveRegion</code> prop to specify ARIA attributes and CSS manually on the
370380
containing element.
371381
</Alert>
372-
</React.Fragment>;
382+
</Fragment>;
373383
```
374384
375385
### Dynamic live region alerts

packages/react-core/src/components/Alert/examples/AlertAsyncLiveRegion.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fragment } from 'react';
1+
import { Fragment, useEffect, useState } from 'react';
22
import { Alert, AlertGroup, AlertVariant, ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
33

44
interface AlertInfo {
@@ -8,15 +8,15 @@ interface AlertInfo {
88
}
99

1010
export const AsyncLiveRegionAlert: React.FunctionComponent = () => {
11-
const [alerts, setAlerts] = React.useState<AlertInfo[]>([]);
12-
const [isActive, setIsActive] = React.useState(false);
11+
const [alerts, setAlerts] = useState<AlertInfo[]>([]);
12+
const [isActive, setIsActive] = useState(false);
1313
const getUniqueId: () => number = () => new Date().getTime();
1414

1515
const addAlert = (alertInfo: AlertInfo) => {
1616
setAlerts((prevAlertInfo) => [...prevAlertInfo, alertInfo]);
1717
};
1818

19-
React.useEffect(() => {
19+
useEffect(() => {
2020
let timer = null;
2121
if (isActive) {
2222
timer = setInterval(() => {

packages/react-core/src/components/Alert/examples/AlertGroupAsync.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fragment } from 'react';
1+
import { Fragment, useState } from 'react';
22
import {
33
Alert,
44
AlertProps,
@@ -12,8 +12,8 @@ import {
1212
import buttonStyles from '@patternfly/react-styles/css/components/Button/button';
1313

1414
export const AlertGroupAsync: React.FunctionComponent = () => {
15-
const [alerts, setAlerts] = React.useState<Partial<AlertProps>[]>([]);
16-
const [isRunning, setIsRunning] = React.useState(false);
15+
const [alerts, setAlerts] = useState<Partial<AlertProps>[]>([]);
16+
const [isRunning, setIsRunning] = useState(false);
1717

1818
const btnClasses = [buttonStyles.button, buttonStyles.modifiers.secondary].join(' ');
1919

packages/react-core/src/components/Alert/examples/AlertGroupMultipleDynamic.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fragment } from 'react';
1+
import { Fragment, useState } from 'react';
22
import {
33
Alert,
44
AlertProps,
@@ -11,7 +11,7 @@ import {
1111
import buttonStyles from '@patternfly/react-styles/css/components/Button/button';
1212

1313
export const AlertGroupMultipleDynamic: React.FunctionComponent = () => {
14-
const [alerts, setAlerts] = React.useState<Partial<AlertProps>[]>([]);
14+
const [alerts, setAlerts] = useState<Partial<AlertProps>[]>([]);
1515

1616
const addAlerts = (incomingAlerts: Partial<AlertProps>[]) => {
1717
setAlerts((prevAlerts) => [...prevAlerts, ...incomingAlerts]);

packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamic.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fragment } from 'react';
1+
import { Fragment, useState } from 'react';
22
import {
33
Alert,
44
AlertProps,
@@ -11,7 +11,7 @@ import {
1111
import buttonStyles from '@patternfly/react-styles/css/components/Button/button';
1212

1313
export const AlertGroupSingularDynamic: React.FunctionComponent = () => {
14-
const [alerts, setAlerts] = React.useState<Partial<AlertProps>[]>([]);
14+
const [alerts, setAlerts] = useState<Partial<AlertProps>[]>([]);
1515

1616
const addAlert = (title: string, variant: AlertProps['variant'], key: React.Key) => {
1717
setAlerts((prevAlerts) => [...prevAlerts, { title, variant, key }]);

0 commit comments

Comments
 (0)