diff --git a/packages/react-core/src/components/Accordion/examples/Accordion.md b/packages/react-core/src/components/Accordion/examples/Accordion.md index 93037f27f6b..56fe2e7231d 100644 --- a/packages/react-core/src/components/Accordion/examples/Accordion.md +++ b/packages/react-core/src/components/Accordion/examples/Accordion.md @@ -5,6 +5,7 @@ cssPrefix: pf-v6-c-accordion propComponents: ['Accordion', 'AccordionItem', 'AccordionContent', 'AccordionToggle', AccordionExpandableContentBody] --- +import { useState } from 'react'; import ArrowRightIcon from '@patternfly/react-icons/dist/esm/icons/arrow-right-icon'; ## Examples diff --git a/packages/react-core/src/components/Accordion/examples/AccordionBordered.tsx b/packages/react-core/src/components/Accordion/examples/AccordionBordered.tsx index 7cd0a01ba40..45b4c6a4272 100644 --- a/packages/react-core/src/components/Accordion/examples/AccordionBordered.tsx +++ b/packages/react-core/src/components/Accordion/examples/AccordionBordered.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Accordion, AccordionItem, @@ -10,8 +11,8 @@ import { import ArrowRightIcon from '@patternfly/react-icons/dist/esm/icons/arrow-right-icon'; export const AccordionBordered: React.FunctionComponent = () => { - const [expanded, setExpanded] = React.useState('bordered-toggle4'); - const [isDisplayLarge, setIsDisplayLarge] = React.useState(false); + const [expanded, setExpanded] = useState('bordered-toggle4'); + const [isDisplayLarge, setIsDisplayLarge] = useState(false); const displaySize = isDisplayLarge ? 'lg' : 'default'; const onToggle = (id: string) => { diff --git a/packages/react-core/src/components/Accordion/examples/AccordionDefinitionList.tsx b/packages/react-core/src/components/Accordion/examples/AccordionDefinitionList.tsx index 938877aa888..c0cf781da5d 100644 --- a/packages/react-core/src/components/Accordion/examples/AccordionDefinitionList.tsx +++ b/packages/react-core/src/components/Accordion/examples/AccordionDefinitionList.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Accordion, AccordionItem, AccordionContent, AccordionToggle } from '@patternfly/react-core'; export const AccordionDefinitionList: React.FunctionComponent = () => { - const [expanded, setExpanded] = React.useState('def-list-toggle2'); + const [expanded, setExpanded] = useState('def-list-toggle2'); const onToggle = (id: string) => { if (id === expanded) { diff --git a/packages/react-core/src/components/Accordion/examples/AccordionFixedWithMultipleExpandBehavior.tsx b/packages/react-core/src/components/Accordion/examples/AccordionFixedWithMultipleExpandBehavior.tsx index b4f68eba239..2ae7cdd7605 100644 --- a/packages/react-core/src/components/Accordion/examples/AccordionFixedWithMultipleExpandBehavior.tsx +++ b/packages/react-core/src/components/Accordion/examples/AccordionFixedWithMultipleExpandBehavior.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Accordion, AccordionItem, AccordionContent, AccordionToggle } from '@patternfly/react-core'; export const AccordionFixedWithMultipleExpandBehavior: React.FunctionComponent = () => { - const [expanded, setExpanded] = React.useState(['ex2-toggle4']); + const [expanded, setExpanded] = useState(['ex2-toggle4']); const toggle = (id) => { const index = expanded.indexOf(id); diff --git a/packages/react-core/src/components/Accordion/examples/AccordionSingleExpandBehavior.tsx b/packages/react-core/src/components/Accordion/examples/AccordionSingleExpandBehavior.tsx index a39ebad4578..64e4755485a 100644 --- a/packages/react-core/src/components/Accordion/examples/AccordionSingleExpandBehavior.tsx +++ b/packages/react-core/src/components/Accordion/examples/AccordionSingleExpandBehavior.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Accordion, AccordionItem, AccordionContent, AccordionToggle } from '@patternfly/react-core'; export const AccordionSingleExpandBehavior: React.FunctionComponent = () => { - const [expanded, setExpanded] = React.useState('ex-toggle2'); + const [expanded, setExpanded] = useState('ex-toggle2'); const onToggle = (id: string) => { if (id === expanded) { diff --git a/packages/react-core/src/components/Accordion/examples/AccordionToggleIconAtStart.tsx b/packages/react-core/src/components/Accordion/examples/AccordionToggleIconAtStart.tsx index 4da46e0f1d2..9519d2a8870 100644 --- a/packages/react-core/src/components/Accordion/examples/AccordionToggleIconAtStart.tsx +++ b/packages/react-core/src/components/Accordion/examples/AccordionToggleIconAtStart.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Accordion, AccordionItem, AccordionContent, AccordionToggle } from '@patternfly/react-core'; export const AccordionToggleIconAtStart: React.FunctionComponent = () => { - const [expanded, setExpanded] = React.useState('start-toggle-toggle2'); + const [expanded, setExpanded] = useState('start-toggle-toggle2'); const onToggle = (id: string) => { if (id === expanded) { diff --git a/packages/react-core/src/components/ActionList/examples/ActionList.md b/packages/react-core/src/components/ActionList/examples/ActionList.md index ff1e7fb698e..e23eba3e738 100644 --- a/packages/react-core/src/components/ActionList/examples/ActionList.md +++ b/packages/react-core/src/components/ActionList/examples/ActionList.md @@ -5,7 +5,7 @@ cssPrefix: pf-v6-c-action-list propComponents: ['ActionList', 'ActionListGroup', 'ActionListItem'] --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import TimesIcon from '@patternfly/react-icons/dist/js/icons/times-icon'; import CheckIcon from '@patternfly/react-icons/dist/js/icons/check-icon'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; diff --git a/packages/react-core/src/components/ActionList/examples/ActionListSingleGroup.tsx b/packages/react-core/src/components/ActionList/examples/ActionListSingleGroup.tsx index 9d4ca00a6dc..75fa07880a8 100644 --- a/packages/react-core/src/components/ActionList/examples/ActionListSingleGroup.tsx +++ b/packages/react-core/src/components/ActionList/examples/ActionListSingleGroup.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { ActionList, ActionListGroup, @@ -14,7 +14,7 @@ import { import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const ActionListSingleGroup: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggle = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Alert/Alert.tsx b/packages/react-core/src/components/Alert/Alert.tsx index f14cdee9e51..fe2086c0bc3 100644 --- a/packages/react-core/src/components/Alert/Alert.tsx +++ b/packages/react-core/src/components/Alert/Alert.tsx @@ -1,4 +1,4 @@ -import { Fragment, useEffect, useRef, useState, type JSX } from 'react'; +import { Fragment, useEffect, useRef, useState } from 'react'; import { css } from '@patternfly/react-styles'; import styles from '@patternfly/react-styles/css/components/Alert/alert'; import { AlertIcon } from './AlertIcon'; @@ -22,7 +22,7 @@ export interface AlertProps extends Omit, 'actio /** Close button; use the alert action close button component. */ actionClose?: React.ReactNode; /** Action links; use a single alert action link component or multiple wrapped in an array - * or React.Fragment. + * or React fragment. */ actionLinks?: React.ReactNode; /** Content rendered inside the alert. */ @@ -54,7 +54,7 @@ export interface AlertProps extends Omit, 'actio /** Title of the alert. */ title: React.ReactNode; /** Sets the element to use as the alert title. Default is h4. */ - component?: keyof JSX.IntrinsicElements; + component?: keyof React.JSX.IntrinsicElements; /** Adds accessible text to the alert toggle. */ toggleAriaLabel?: string; /** Position of the tooltip which is displayed if text is truncated. */ diff --git a/packages/react-core/src/components/Alert/examples/Alert.md b/packages/react-core/src/components/Alert/examples/Alert.md index 2a7b436bac9..bacf683bb8a 100644 --- a/packages/react-core/src/components/Alert/examples/Alert.md +++ b/packages/react-core/src/components/Alert/examples/Alert.md @@ -7,7 +7,7 @@ ouia: true --- import './alert.css'; -import { Fragment, useState } from 'react'; +import { Fragment, useEffect, useState } from 'react'; import UsersIcon from '@patternfly/react-icons/dist/esm/icons/users-icon'; import BoxIcon from '@patternfly/react-icons/dist/esm/icons/box-icon'; 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 | Danger | Use to indicate that a critical or blocking error has occurred | ```ts +import { Fragment } from 'react'; import { Alert } from '@patternfly/react-core'; - + -; +; ``` ### Alert variations @@ -56,14 +57,15 @@ PatternFly supports several properties and variations that can be used to add ex - 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`. ```ts +import { Fragment } from 'react'; import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core'; - + + View details @@ -72,7 +74,7 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac > Ignore - + } >

Success alert description. This should tell the user more information about the alert.

@@ -95,7 +97,7 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac

Short alert description.

-; +; ``` ### Alert timeout @@ -103,11 +105,12 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac 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. ```ts +import { Fragment, useState } from 'react'; import { Alert, AlertActionLink, AlertGroup, Button } from '@patternfly/react-core'; const AlertTimeout: React.FunctionComponent = () => { - const [alerts, setAlerts] = React.useState([]); - const [newAlertKey, setNewAlertKey] = React.useState(0); + const [alerts, setAlerts] = useState([]); + const [newAlertKey, setNewAlertKey] = useState(0); const onClick = () => { const timeout = 8000; @@ -119,7 +122,7 @@ const AlertTimeout: React.FunctionComponent = () => { title="Default timeout Alert" timeout={timeout} actionLinks={ - + View details @@ -128,7 +131,7 @@ const AlertTimeout: React.FunctionComponent = () => { > Ignore - + } key={newAlertKey} > @@ -139,7 +142,7 @@ const AlertTimeout: React.FunctionComponent = () => { }; return ( - + @@ -147,7 +150,7 @@ const AlertTimeout: React.FunctionComponent = () => { Remove all alerts {alerts} - + ); }; ``` @@ -161,9 +164,10 @@ It is not recommended to use an expandable alert with a `timeout` in a [toast al 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. ```ts +import { Fragment } from 'react'; import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core'; - + + View details @@ -188,12 +192,12 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac > Ignore - + } >

Success alert description. This should tell the user more information about the alert.

-; +; ``` ### Truncated alerts @@ -201,9 +205,10 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac 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. ```ts +import { Fragment } from 'react'; import { Alert } from '@patternfly/react-core'; - + -; +; ``` ### Custom icons @@ -233,6 +238,7 @@ import { Alert } from '@patternfly/react-core'; Use the `customIcon` property to replace a default alert icon with a custom icon. ```ts +import { Fragment } from 'react'; import { Alert } from '@patternfly/react-core'; import UsersIcon from '@patternfly/react-icons/dist/esm/icons/users-icon'; import BoxIcon from '@patternfly/react-icons/dist/esm/icons/box-icon'; @@ -240,13 +246,13 @@ import DatabaseIcon from '@patternfly/react-icons/dist/esm/icons/database-icon'; import ServerIcon from '@patternfly/react-icons/dist/esm/icons/server-icon'; import LaptopIcon from '@patternfly/react-icons/dist/esm/icons/laptop-icon'; - + } title="Default alert title" /> } variant="info" title="Info alert title" /> } variant="success" title="Success alert title" /> } variant="warning" title="Warning alert title" /> } variant="danger" title="Danger alert title" /> -; +; ``` ### Inline alerts variants @@ -254,14 +260,15 @@ import LaptopIcon from '@patternfly/react-icons/dist/esm/icons/laptop-icon'; 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. ```ts +import { Fragment } from 'react'; import { Alert } from '@patternfly/react-core'; - + -; +; ``` ### Inline alert variations @@ -269,14 +276,15 @@ import { Alert } from '@patternfly/react-core'; All general alert variations can use the `isInline` property to apply inline styling. ```ts +import { Fragment } from 'react'; import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core'; - + + View details @@ -285,7 +293,7 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac > Ignore - + } >

Success alert description. This should tell the user more information about the alert.

@@ -309,7 +317,7 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac

Short alert description.

-; +; ``` ### Plain inline alert variants @@ -317,14 +325,15 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac Use the `isPlain` property to make any inline alert plain. Plain styling removes the colored background but keeps colored text and icons. ```ts +import { Fragment } from 'react'; import { Alert } from '@patternfly/react-core'; - + -; +; ``` ### Plain inline alert variations @@ -345,9 +354,10 @@ Live region alerts allow you to expose dynamic content changes in a way that can By default, `isLiveRegion`alerts are static. ```ts +import { Fragment } from 'react'; import { Alert, AlertActionCloseButton } from '@patternfly/react-core'; - + isLiveRegion prop to specify ARIA attributes and CSS manually on the containing element. -; +; ``` ### Dynamic live region alerts diff --git a/packages/react-core/src/components/Alert/examples/AlertAsyncLiveRegion.tsx b/packages/react-core/src/components/Alert/examples/AlertAsyncLiveRegion.tsx index d80bdaa8c7d..6fe11a82222 100644 --- a/packages/react-core/src/components/Alert/examples/AlertAsyncLiveRegion.tsx +++ b/packages/react-core/src/components/Alert/examples/AlertAsyncLiveRegion.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useEffect, useState } from 'react'; import { Alert, AlertGroup, AlertVariant, ToggleGroup, ToggleGroupItem } from '@patternfly/react-core'; interface AlertInfo { @@ -8,15 +8,15 @@ interface AlertInfo { } export const AsyncLiveRegionAlert: React.FunctionComponent = () => { - const [alerts, setAlerts] = React.useState([]); - const [isActive, setIsActive] = React.useState(false); + const [alerts, setAlerts] = useState([]); + const [isActive, setIsActive] = useState(false); const getUniqueId: () => number = () => new Date().getTime(); const addAlert = (alertInfo: AlertInfo) => { setAlerts((prevAlertInfo) => [...prevAlertInfo, alertInfo]); }; - React.useEffect(() => { + useEffect(() => { let timer = null; if (isActive) { timer = setInterval(() => { diff --git a/packages/react-core/src/components/Alert/examples/AlertGroupAsync.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupAsync.tsx index b608134f040..610d4fc0581 100644 --- a/packages/react-core/src/components/Alert/examples/AlertGroupAsync.tsx +++ b/packages/react-core/src/components/Alert/examples/AlertGroupAsync.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Alert, AlertProps, @@ -12,8 +12,8 @@ import { import buttonStyles from '@patternfly/react-styles/css/components/Button/button'; export const AlertGroupAsync: React.FunctionComponent = () => { - const [alerts, setAlerts] = React.useState[]>([]); - const [isRunning, setIsRunning] = React.useState(false); + const [alerts, setAlerts] = useState[]>([]); + const [isRunning, setIsRunning] = useState(false); const btnClasses = [buttonStyles.button, buttonStyles.modifiers.secondary].join(' '); diff --git a/packages/react-core/src/components/Alert/examples/AlertGroupMultipleDynamic.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupMultipleDynamic.tsx index 9d98bd923e6..451252c4160 100644 --- a/packages/react-core/src/components/Alert/examples/AlertGroupMultipleDynamic.tsx +++ b/packages/react-core/src/components/Alert/examples/AlertGroupMultipleDynamic.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Alert, AlertProps, @@ -11,7 +11,7 @@ import { import buttonStyles from '@patternfly/react-styles/css/components/Button/button'; export const AlertGroupMultipleDynamic: React.FunctionComponent = () => { - const [alerts, setAlerts] = React.useState[]>([]); + const [alerts, setAlerts] = useState[]>([]); const addAlerts = (incomingAlerts: Partial[]) => { setAlerts((prevAlerts) => [...prevAlerts, ...incomingAlerts]); diff --git a/packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamic.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamic.tsx index 1df8dc6296c..8f471476121 100644 --- a/packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamic.tsx +++ b/packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamic.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Alert, AlertProps, @@ -11,7 +11,7 @@ import { import buttonStyles from '@patternfly/react-styles/css/components/Button/button'; export const AlertGroupSingularDynamic: React.FunctionComponent = () => { - const [alerts, setAlerts] = React.useState[]>([]); + const [alerts, setAlerts] = useState[]>([]); const addAlert = (title: string, variant: AlertProps['variant'], key: React.Key) => { setAlerts((prevAlerts) => [...prevAlerts, { title, variant, key }]); diff --git a/packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamicOverflow.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamicOverflow.tsx index f7736ad4d42..1e26d95465e 100644 --- a/packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamicOverflow.tsx +++ b/packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamicOverflow.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Alert, AlertProps, @@ -11,8 +11,8 @@ import { import buttonStyles from '@patternfly/react-styles/css/components/Button/button'; export const AlertGroupSingularDynamicOverflow: React.FunctionComponent = () => { - const [alerts, setAlerts] = React.useState[]>([]); - const [overflowMessage, setOverflowMessage] = React.useState(''); + const [alerts, setAlerts] = useState[]>([]); + const [overflowMessage, setOverflowMessage] = useState(''); const maxDisplayed = 4; diff --git a/packages/react-core/src/components/Alert/examples/AlertGroupToast.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupToast.tsx index 1d38f86308b..1c5613ef0a6 100644 --- a/packages/react-core/src/components/Alert/examples/AlertGroupToast.tsx +++ b/packages/react-core/src/components/Alert/examples/AlertGroupToast.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Alert, AlertProps, @@ -11,7 +11,7 @@ import { import buttonStyles from '@patternfly/react-styles/css/components/Button/button'; export const AlertGroupToast: React.FunctionComponent = () => { - const [alerts, setAlerts] = React.useState[]>([]); + const [alerts, setAlerts] = useState[]>([]); const addAlert = (title: string, variant: AlertProps['variant'], key: React.Key) => { setAlerts((prevAlerts) => [...prevAlerts, { title, variant, key }]); diff --git a/packages/react-core/src/components/Alert/examples/AlertGroupToastOverflowCapture.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupToastOverflowCapture.tsx index b8ddd9cd611..3d68793a3b9 100644 --- a/packages/react-core/src/components/Alert/examples/AlertGroupToastOverflowCapture.tsx +++ b/packages/react-core/src/components/Alert/examples/AlertGroupToastOverflowCapture.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Alert, AlertProps, @@ -11,8 +11,8 @@ import { import buttonStyles from '@patternfly/react-styles/css/components/Button/button'; export const AlertGroupToastOverflowCapture: React.FunctionComponent = () => { - const [alerts, setAlerts] = React.useState[]>([]); - const [overflowMessage, setOverflowMessage] = React.useState(''); + const [alerts, setAlerts] = useState[]>([]); + const [overflowMessage, setOverflowMessage] = useState(''); const maxDisplayed = 4; diff --git a/packages/react-core/src/components/Breadcrumb/examples/Breadcrumb.md b/packages/react-core/src/components/Breadcrumb/examples/Breadcrumb.md index 3309609ff97..fdc6975e649 100644 --- a/packages/react-core/src/components/Breadcrumb/examples/Breadcrumb.md +++ b/packages/react-core/src/components/Breadcrumb/examples/Breadcrumb.md @@ -6,6 +6,7 @@ propComponents: ['Breadcrumb', 'BreadcrumbItem', 'BreadcrumbHeading'] ouia: true --- +import { useRef, useState } from 'react'; import AngleLeftIcon from '@patternfly/react-icons/dist/esm/icons/angle-left-icon'; import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon'; diff --git a/packages/react-core/src/components/Breadcrumb/examples/BreadcrumbDropdown.tsx b/packages/react-core/src/components/Breadcrumb/examples/BreadcrumbDropdown.tsx index 6d1fc2266a6..87e0ec6541e 100644 --- a/packages/react-core/src/components/Breadcrumb/examples/BreadcrumbDropdown.tsx +++ b/packages/react-core/src/components/Breadcrumb/examples/BreadcrumbDropdown.tsx @@ -1,3 +1,4 @@ +import { useRef, useState } from 'react'; import { Breadcrumb, BreadcrumbItem, @@ -46,8 +47,8 @@ const dropdownItems = [ ]; export const BreadcrumbDropdown: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const badgeToggleRef = React.useRef(undefined); + const [isOpen, setIsOpen] = useState(false); + const badgeToggleRef = useRef(undefined); const onToggle = () => setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Button/examples/Button.md b/packages/react-core/src/components/Button/examples/Button.md index a082ee23279..b816256151f 100644 --- a/packages/react-core/src/components/Button/examples/Button.md +++ b/packages/react-core/src/components/Button/examples/Button.md @@ -6,7 +6,7 @@ propComponents: ['Button', 'BadgeCountObject'] ouia: true --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon'; import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon'; import ExternalLinkSquareAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-square-alt-icon'; diff --git a/packages/react-core/src/components/Button/examples/ButtonProgress.tsx b/packages/react-core/src/components/Button/examples/ButtonProgress.tsx index 44b07f44e3b..fd78b5fb8db 100644 --- a/packages/react-core/src/components/Button/examples/ButtonProgress.tsx +++ b/packages/react-core/src/components/Button/examples/ButtonProgress.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Button, Flex } from '@patternfly/react-core'; import UploadIcon from '@patternfly/react-icons/dist/esm/icons/upload-icon'; @@ -9,10 +10,10 @@ interface LoadingPropsType { } export const ButtonProgress: React.FunctionComponent = () => { - const [isPrimaryLoading, setIsPrimaryLoading] = React.useState(true); - const [isSecondaryLoading, setIsSecondaryLoading] = React.useState(true); - const [isInlineLoading, setIsInlineLoading] = React.useState(true); - const [isUploading, setIsUploading] = React.useState(false); + const [isPrimaryLoading, setIsPrimaryLoading] = useState(true); + const [isSecondaryLoading, setIsSecondaryLoading] = useState(true); + const [isInlineLoading, setIsInlineLoading] = useState(true); + const [isUploading, setIsUploading] = useState(false); const primaryLoadingProps = {} as LoadingPropsType; primaryLoadingProps.spinnerAriaValueText = 'Loading'; diff --git a/packages/react-core/src/components/CalendarMonth/CalendarMonth.tsx b/packages/react-core/src/components/CalendarMonth/CalendarMonth.tsx index 08f75672704..ebfd522ff90 100644 --- a/packages/react-core/src/components/CalendarMonth/CalendarMonth.tsx +++ b/packages/react-core/src/components/CalendarMonth/CalendarMonth.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useRef, useState, type JSX } from 'react'; +import { useEffect, useMemo, useRef, useState } from 'react'; import { TextInput } from '../TextInput'; import { Button } from '../Button'; import { Select, SelectList, SelectOption } from '../Select'; @@ -23,7 +23,7 @@ export enum Weekday { export interface CalendarMonthInlineProps { /** Component wrapping the calendar month when used inline. Recommended to be 'article'. */ - component?: keyof JSX.IntrinsicElements; + component?: keyof React.JSX.IntrinsicElements; /** Title of the calendar rendered above the inline calendar month. Recommended to be a 'title' component. */ title?: React.ReactNode; /** Id of the accessible label of the calendar month. Recommended to map to the title. */ diff --git a/packages/react-core/src/components/CalendarMonth/examples/CalendarMonth.md b/packages/react-core/src/components/CalendarMonth/examples/CalendarMonth.md index 2b784e4f5f9..ab5a6a3005e 100644 --- a/packages/react-core/src/components/CalendarMonth/examples/CalendarMonth.md +++ b/packages/react-core/src/components/CalendarMonth/examples/CalendarMonth.md @@ -5,6 +5,7 @@ subsection: date-and-time cssPrefix: pf-v6-c-calendar-month propComponents: ['CalendarMonth', 'CalendarFormat', 'CalendarMonthInlineProps'] --- +import { useState } from 'react'; ## Examples diff --git a/packages/react-core/src/components/CalendarMonth/examples/CalendarMonthSelectableDate.tsx b/packages/react-core/src/components/CalendarMonth/examples/CalendarMonthSelectableDate.tsx index 0e9d49a1065..876f2b3dda0 100644 --- a/packages/react-core/src/components/CalendarMonth/examples/CalendarMonthSelectableDate.tsx +++ b/packages/react-core/src/components/CalendarMonth/examples/CalendarMonthSelectableDate.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { CalendarMonth, Title, CalendarMonthInlineProps } from '@patternfly/react-core'; export const CalendarMonthSelectableDate: React.FunctionComponent = () => { - const [date, setDate] = React.useState(new Date(2020, 10, 24)); + const [date, setDate] = useState(new Date(2020, 10, 24)); const onMonthChange = ( _event: React.MouseEvent | React.ChangeEvent | React.FormEvent | undefined, diff --git a/packages/react-core/src/components/Card/Card.tsx b/packages/react-core/src/components/Card/Card.tsx index d78c9b40544..5e7b7e73de0 100644 --- a/packages/react-core/src/components/Card/Card.tsx +++ b/packages/react-core/src/components/Card/Card.tsx @@ -1,4 +1,4 @@ -import { createContext, type JSX } from 'react'; +import { createContext } from 'react'; import styles from '@patternfly/react-styles/css/components/Card/card'; import { css } from '@patternfly/react-styles'; import { useOUIAProps, OUIAProps } from '../../helpers'; @@ -11,7 +11,7 @@ export interface CardProps extends React.HTMLProps, OUIAProps { /** Additional classes added to the Card */ className?: string; /** Sets the base component to render. defaults to div */ - component?: keyof JSX.IntrinsicElements; + component?: keyof React.JSX.IntrinsicElements; /** Modifies the card to include compact styling. Should not be used with isLarge. */ isCompact?: boolean; /** Flag indicating that the card is selectable. */ diff --git a/packages/react-core/src/components/Card/CardTitle.tsx b/packages/react-core/src/components/Card/CardTitle.tsx index f5b48e82953..2df2ced37f7 100644 --- a/packages/react-core/src/components/Card/CardTitle.tsx +++ b/packages/react-core/src/components/Card/CardTitle.tsx @@ -1,4 +1,4 @@ -import { useContext, type JSX } from 'react'; +import { useContext } from 'react'; import { css } from '@patternfly/react-styles'; import styles from '@patternfly/react-styles/css/components/Card/card'; import { CardContext } from './Card'; @@ -9,7 +9,7 @@ export interface CardTitleProps extends React.HTMLProps { /** Additional classes added to the CardTitle */ className?: string; /** Sets the base component to render. defaults to div */ - component?: keyof JSX.IntrinsicElements; + component?: keyof React.JSX.IntrinsicElements; } export const CardTitle: React.FunctionComponent = ({ diff --git a/packages/react-core/src/components/Card/__tests__/Card.test.tsx b/packages/react-core/src/components/Card/__tests__/Card.test.tsx index fa73fbbed70..9a11e584111 100644 --- a/packages/react-core/src/components/Card/__tests__/Card.test.tsx +++ b/packages/react-core/src/components/Card/__tests__/Card.test.tsx @@ -1,5 +1,3 @@ -import { type JSX } from 'react'; - import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; @@ -33,7 +31,7 @@ describe('Card', () => { test('allows passing in a React Component as the component', () => { const Component = () =>
im a div
; - render(); + render(); expect(screen.getByText('im a div')).toBeInTheDocument(); }); diff --git a/packages/react-core/src/components/Card/__tests__/CardBody.test.tsx b/packages/react-core/src/components/Card/__tests__/CardBody.test.tsx index 41e176eef5a..a1e6478c633 100644 --- a/packages/react-core/src/components/Card/__tests__/CardBody.test.tsx +++ b/packages/react-core/src/components/Card/__tests__/CardBody.test.tsx @@ -1,4 +1,3 @@ -import { type JSX } from 'react'; import { render, screen } from '@testing-library/react'; import { CardBody } from '../CardBody'; @@ -30,7 +29,7 @@ describe('CardBody', () => { test('allows passing in a React Component as the component', () => { const Component = () =>
im a div
; - render(); + render(); expect(screen.getByText('im a div')).toBeInTheDocument(); }); diff --git a/packages/react-core/src/components/Card/__tests__/CardFooter.test.tsx b/packages/react-core/src/components/Card/__tests__/CardFooter.test.tsx index 1b2c44ed4a7..ed7a55d67c2 100644 --- a/packages/react-core/src/components/Card/__tests__/CardFooter.test.tsx +++ b/packages/react-core/src/components/Card/__tests__/CardFooter.test.tsx @@ -1,4 +1,3 @@ -import { type JSX } from 'react'; import { render, screen } from '@testing-library/react'; import { CardFooter } from '../CardFooter'; @@ -27,7 +26,7 @@ describe('CardFooter', () => { test('allows passing in a React Component as the component', () => { const Component = () =>
im a div
; - render(); + render(); expect(screen.getByText('im a div')).toBeInTheDocument(); }); }); diff --git a/packages/react-core/src/components/Card/examples/Card.md b/packages/react-core/src/components/Card/examples/Card.md index 11928543aee..b183c06b1b8 100644 --- a/packages/react-core/src/components/Card/examples/Card.md +++ b/packages/react-core/src/components/Card/examples/Card.md @@ -16,7 +16,7 @@ propComponents: ouia: true --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import pfLogo from '../../assets/PF-HorizontalLogo-Color.svg'; import pfLogoSmall from '../../assets/PF-IconLogo.svg'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; diff --git a/packages/react-core/src/components/Card/examples/CardClickable.tsx b/packages/react-core/src/components/Card/examples/CardClickable.tsx index 654d8736202..5bb2506535d 100644 --- a/packages/react-core/src/components/Card/examples/CardClickable.tsx +++ b/packages/react-core/src/components/Card/examples/CardClickable.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Card, CardHeader, CardTitle, CardBody, Checkbox, Gallery } from '@patternfly/react-core'; export const CardClickable: React.FunctionComponent = () => { - const [isSecondary, setIsSecondary] = React.useState(false); + const [isSecondary, setIsSecondary] = useState(false); const toggleVariant = (checked: boolean) => { setIsSecondary(checked); diff --git a/packages/react-core/src/components/Card/examples/CardClickableSelectable.tsx b/packages/react-core/src/components/Card/examples/CardClickableSelectable.tsx index 0e2c57537ae..6bad412a5c1 100644 --- a/packages/react-core/src/components/Card/examples/CardClickableSelectable.tsx +++ b/packages/react-core/src/components/Card/examples/CardClickableSelectable.tsx @@ -1,11 +1,12 @@ +import { useState } from 'react'; import { Card, CardHeader, CardTitle, CardBody, Button, Checkbox, Gallery } from '@patternfly/react-core'; export const CardClickable: React.FunctionComponent = () => { - const [isChecked1, setIsChecked1] = React.useState(false); - const [isChecked2, setIsChecked2] = React.useState(false); - const [isChecked3, setIsChecked3] = React.useState(false); - const [isClicked, setIsClicked] = React.useState(false); - const [isSecondary, setIsSecondary] = React.useState(false); + const [isChecked1, setIsChecked1] = useState(false); + const [isChecked2, setIsChecked2] = useState(false); + const [isChecked3, setIsChecked3] = useState(false); + const [isClicked, setIsClicked] = useState(false); + const [isSecondary, setIsSecondary] = useState(false); const id1 = 'clickable-selectable-card-input-1'; const id2 = 'clickable-selectable-card-input-2'; diff --git a/packages/react-core/src/components/Card/examples/CardExpandable.tsx b/packages/react-core/src/components/Card/examples/CardExpandable.tsx index 39378dfe660..54c05beed7d 100644 --- a/packages/react-core/src/components/Card/examples/CardExpandable.tsx +++ b/packages/react-core/src/components/Card/examples/CardExpandable.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Card, CardHeader, @@ -17,10 +17,10 @@ import { import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const CardExpandable: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [isChecked, setIsChecked] = React.useState(false); - const [isExpanded, setIsExpanded] = React.useState(false); - const [isToggleRightAligned, setIsToggleRightAligned] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); + const [isChecked, setIsChecked] = useState(false); + const [isExpanded, setIsExpanded] = useState(false); + const [isToggleRightAligned, setIsToggleRightAligned] = useState(false); const onSelect = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Card/examples/CardExpandableWithIcon.tsx b/packages/react-core/src/components/Card/examples/CardExpandableWithIcon.tsx index fb3a227622a..19a706791c0 100644 --- a/packages/react-core/src/components/Card/examples/CardExpandableWithIcon.tsx +++ b/packages/react-core/src/components/Card/examples/CardExpandableWithIcon.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Card, CardHeader, @@ -16,9 +17,9 @@ import pfLogoSmall from '../../PF-IconLogo.svg'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const CardExpandableWithIcon: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [isChecked, setIsChecked] = React.useState(false); - const [isExpanded, setIsExpanded] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); + const [isChecked, setIsChecked] = useState(false); + const [isExpanded, setIsExpanded] = useState(false); const onSelect = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Card/examples/CardHeaderInCardHead.tsx b/packages/react-core/src/components/Card/examples/CardHeaderInCardHead.tsx index 59ce8254bcc..ab7ef1f7ba3 100644 --- a/packages/react-core/src/components/Card/examples/CardHeaderInCardHead.tsx +++ b/packages/react-core/src/components/Card/examples/CardHeaderInCardHead.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Card, CardHeader, @@ -15,8 +16,8 @@ import { import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const CardTitleInHeader: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [isChecked, setIsChecked] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); + const [isChecked, setIsChecked] = useState(false); const onSelect = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Card/examples/CardOnlyActionsInCardHead.tsx b/packages/react-core/src/components/Card/examples/CardOnlyActionsInCardHead.tsx index e955f1c5c18..e6d7db885dc 100644 --- a/packages/react-core/src/components/Card/examples/CardOnlyActionsInCardHead.tsx +++ b/packages/react-core/src/components/Card/examples/CardOnlyActionsInCardHead.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Checkbox, Card, @@ -13,8 +14,8 @@ import { import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const CardOnlyActionsInCardHead: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [isChecked, setIsChecked] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); + const [isChecked, setIsChecked] = useState(false); const onSelect = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Card/examples/CardSelectable.tsx b/packages/react-core/src/components/Card/examples/CardSelectable.tsx index 26c3aca9393..2d32bcdedaf 100644 --- a/packages/react-core/src/components/Card/examples/CardSelectable.tsx +++ b/packages/react-core/src/components/Card/examples/CardSelectable.tsx @@ -1,10 +1,11 @@ +import { useState } from 'react'; import { Card, CardHeader, CardTitle, CardBody, Checkbox, Gallery } from '@patternfly/react-core'; export const SelectableCard: React.FunctionComponent = () => { - const [isChecked1, setIsChecked1] = React.useState(false); - const [isChecked2, setIsChecked2] = React.useState(false); - const [isChecked3, setIsChecked3] = React.useState(false); - const [isSecondary, setIsSecondary] = React.useState(false); + const [isChecked1, setIsChecked1] = useState(false); + const [isChecked2, setIsChecked2] = useState(false); + const [isChecked3, setIsChecked3] = useState(false); + const [isSecondary, setIsSecondary] = useState(false); const id1 = 'selectable-card-input-1'; const id2 = 'selectable-card-input-2'; diff --git a/packages/react-core/src/components/Card/examples/CardSingleSelectable.tsx b/packages/react-core/src/components/Card/examples/CardSingleSelectable.tsx index f6073dd47de..83f116e40c0 100644 --- a/packages/react-core/src/components/Card/examples/CardSingleSelectable.tsx +++ b/packages/react-core/src/components/Card/examples/CardSingleSelectable.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Card, CardHeader, CardTitle, CardBody, Gallery } from '@patternfly/react-core'; export const SingleSelectableCard: React.FunctionComponent = () => { - const [isChecked, setIsChecked] = React.useState(''); + const [isChecked, setIsChecked] = useState(''); const id1 = 'single-selectable-card-input-1'; const id2 = 'single-selectable-card-input-2'; const id3 = 'single-selectable-card-input-3'; diff --git a/packages/react-core/src/components/Card/examples/CardTile.tsx b/packages/react-core/src/components/Card/examples/CardTile.tsx index 24f0f41c0ec..2ed07685ba1 100644 --- a/packages/react-core/src/components/Card/examples/CardTile.tsx +++ b/packages/react-core/src/components/Card/examples/CardTile.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Card, CardHeader, CardBody, Gallery, Flex } from '@patternfly/react-core'; import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; export const CardTile: React.FunctionComponent = () => { - const [isChecked, setIsChecked] = React.useState(''); + const [isChecked, setIsChecked] = useState(''); const id1 = 'tile-1'; const id2 = 'tile-2'; const id3 = 'tile-3'; diff --git a/packages/react-core/src/components/Card/examples/CardTileMulti.tsx b/packages/react-core/src/components/Card/examples/CardTileMulti.tsx index 310e037dd1e..c41816b5ba6 100644 --- a/packages/react-core/src/components/Card/examples/CardTileMulti.tsx +++ b/packages/react-core/src/components/Card/examples/CardTileMulti.tsx @@ -1,10 +1,11 @@ +import { useState } from 'react'; import { Card, CardHeader, CardBody, Gallery, Flex } from '@patternfly/react-core'; import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; export const CardTileMulti: React.FunctionComponent = () => { - const [isChecked1, setIsChecked1] = React.useState(false); - const [isChecked2, setIsChecked2] = React.useState(false); - const [isChecked3, setIsChecked3] = React.useState(false); + const [isChecked1, setIsChecked1] = useState(false); + const [isChecked2, setIsChecked2] = useState(false); + const [isChecked3, setIsChecked3] = useState(false); const id1 = 'multi-tile-1'; const id2 = 'multi-tile-2'; const id3 = 'multi-tile-3'; diff --git a/packages/react-core/src/components/Card/examples/CardWithImageAndActions.tsx b/packages/react-core/src/components/Card/examples/CardWithImageAndActions.tsx index de361622506..d77fc82a0f7 100644 --- a/packages/react-core/src/components/Card/examples/CardWithImageAndActions.tsx +++ b/packages/react-core/src/components/Card/examples/CardWithImageAndActions.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Brand, Card, @@ -17,9 +18,9 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico import pfLogo from '../../assets/PF-HorizontalLogo-Color.svg'; export const CardWithImageAndActions: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [isChecked, setIsChecked] = React.useState(false); - const [hasNoOffset, setHasNoOffset] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); + const [isChecked, setIsChecked] = useState(false); + const [hasNoOffset, setHasNoOffset] = useState(false); const onSelect = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Card/examples/CardWithModifiers.tsx b/packages/react-core/src/components/Card/examples/CardWithModifiers.tsx index 9b18185f07d..637a868f10a 100644 --- a/packages/react-core/src/components/Card/examples/CardWithModifiers.tsx +++ b/packages/react-core/src/components/Card/examples/CardWithModifiers.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Card, CardTitle, CardBody, CardFooter, Checkbox } from '@patternfly/react-core'; export const CardWithModifiers: React.FunctionComponent = () => { const mods = ['isCompact', 'isLarge', 'isFullHeight', 'isPlain']; - const [modifiers, setModifiers] = React.useState({}); + const [modifiers, setModifiers] = useState({}); return ( diff --git a/packages/react-core/src/components/Checkbox/examples/Checkbox.md b/packages/react-core/src/components/Checkbox/examples/Checkbox.md index c7a87545404..d860af1e4eb 100644 --- a/packages/react-core/src/components/Checkbox/examples/Checkbox.md +++ b/packages/react-core/src/components/Checkbox/examples/Checkbox.md @@ -6,7 +6,7 @@ cssPrefix: pf-v6-c-check propComponents: ['Checkbox'] --- -import { Fragment } from 'react'; +import { Fragment, useEffect, useState } from 'react'; ## Examples diff --git a/packages/react-core/src/components/Checkbox/examples/CheckboxControlled.tsx b/packages/react-core/src/components/Checkbox/examples/CheckboxControlled.tsx index d91da501c2a..ed125618496 100644 --- a/packages/react-core/src/components/Checkbox/examples/CheckboxControlled.tsx +++ b/packages/react-core/src/components/Checkbox/examples/CheckboxControlled.tsx @@ -1,11 +1,11 @@ -import { Fragment } from 'react'; +import { Fragment, useEffect, useState } from 'react'; import { Checkbox } from '@patternfly/react-core'; export const CheckboxControlled: React.FunctionComponent = () => { - const [isChecked1, setIsChecked1] = React.useState(false); - const [isChecked2, setIsChecked2] = React.useState(false); - const [isChecked3, setIsChecked3] = React.useState(false); - const [isChecked4, setIsChecked4] = React.useState(false); + const [isChecked1, setIsChecked1] = useState(false); + const [isChecked2, setIsChecked2] = useState(false); + const [isChecked3, setIsChecked3] = useState(false); + const [isChecked4, setIsChecked4] = useState(false); const handleChange = (event: React.FormEvent, checked: boolean) => { const target = event.currentTarget; @@ -30,14 +30,14 @@ export const CheckboxControlled: React.FunctionComponent = () => { } }; - React.useEffect(() => { + useEffect(() => { if (isChecked1 !== null) { setIsChecked2(isChecked1); setIsChecked3(isChecked1); } }, [isChecked1]); - React.useEffect(() => { + useEffect(() => { setIsChecked1((isChecked2 && isChecked3) || (isChecked2 || isChecked3 ? null : false)); }, [isChecked2, isChecked3]); diff --git a/packages/react-core/src/components/DescriptionList/examples/DescriptionList.md b/packages/react-core/src/components/DescriptionList/examples/DescriptionList.md index dc3b730c942..ebbde9e5bf0 100644 --- a/packages/react-core/src/components/DescriptionList/examples/DescriptionList.md +++ b/packages/react-core/src/components/DescriptionList/examples/DescriptionList.md @@ -15,6 +15,7 @@ propComponents: ] --- +import { useState } from 'react'; import { Button, DescriptionList, DescriptionListTerm, DescriptionListDescription, DescriptionListGroup, DescriptionListTermHelpText, DescriptionListTermHelpTextButton, Popover, Checkbox, Card } from '@patternfly/react-core'; import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon'; import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; diff --git a/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithCard.tsx b/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithCard.tsx index 63ad0076a42..3c9f75ef828 100644 --- a/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithCard.tsx +++ b/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithCard.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Button, DescriptionList, @@ -9,8 +10,8 @@ import { import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon'; export const DescriptionListWithCard: React.FunctionComponent = () => { - const [isChecked, setIsChecked] = React.useState(false); - const [isSelectable, setSelectable] = React.useState(false); + const [isChecked, setIsChecked] = useState(false); + const [isSelectable, setSelectable] = useState(false); const toggleSelectable = (checked: boolean) => { setSelectable(checked ? true : false); diff --git a/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithLargeDisplaySize.tsx b/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithLargeDisplaySize.tsx index 22e3962bf4f..2c41c0e454a 100644 --- a/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithLargeDisplaySize.tsx +++ b/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithLargeDisplaySize.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Button, DescriptionList, @@ -9,8 +10,8 @@ import { import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon'; export const DescriptionListWithLargeDisplaySize: React.FunctionComponent = () => { - const [isChecked, setIsChecked] = React.useState(false); - const [displaySize, setDisplaySize] = React.useState<'lg' | '2xl'>('lg'); + const [isChecked, setIsChecked] = useState(false); + const [displaySize, setDisplaySize] = useState<'lg' | '2xl'>('lg'); const toggleDisplaySize = (checked: boolean) => { setDisplaySize(checked ? '2xl' : 'lg'); diff --git a/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithLargeDisplaySizeAndCard.tsx b/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithLargeDisplaySizeAndCard.tsx index 238990874ea..53c798206a4 100644 --- a/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithLargeDisplaySizeAndCard.tsx +++ b/packages/react-core/src/components/DescriptionList/examples/DescriptionListWithLargeDisplaySizeAndCard.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Button, DescriptionList, @@ -9,8 +10,8 @@ import { import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon'; export const DescriptionListWithLargeDisplaySizeAndCard: React.FunctionComponent = () => { - const [isChecked, setIsChecked] = React.useState(false); - const [displaySize, setDisplaySize] = React.useState<'lg' | '2xl'>('lg'); + const [isChecked, setIsChecked] = useState(false); + const [displaySize, setDisplaySize] = useState<'lg' | '2xl'>('lg'); const toggleDisplaySize = (checked: boolean) => { setDisplaySize(checked ? '2xl' : 'lg'); diff --git a/packages/react-core/src/components/Dropdown/examples/Dropdown.md b/packages/react-core/src/components/Dropdown/examples/Dropdown.md index 2c05cc4a652..7db5e2ad906 100644 --- a/packages/react-core/src/components/Dropdown/examples/Dropdown.md +++ b/packages/react-core/src/components/Dropdown/examples/Dropdown.md @@ -16,6 +16,7 @@ propComponents: ] --- +import { useState } from 'react'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; ## Examples diff --git a/packages/react-core/src/components/Dropdown/examples/DropdownBasic.tsx b/packages/react-core/src/components/Dropdown/examples/DropdownBasic.tsx index adfbe3080e5..846a846a0b4 100644 --- a/packages/react-core/src/components/Dropdown/examples/DropdownBasic.tsx +++ b/packages/react-core/src/components/Dropdown/examples/DropdownBasic.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Dropdown, DropdownItem, DropdownList, Divider, MenuToggle, MenuToggleElement } from '@patternfly/react-core'; export const DropdownBasic: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggleClick = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Dropdown/examples/DropdownWithDescriptions.tsx b/packages/react-core/src/components/Dropdown/examples/DropdownWithDescriptions.tsx index 3cb1f12e9d6..2cd8eb484a0 100644 --- a/packages/react-core/src/components/Dropdown/examples/DropdownWithDescriptions.tsx +++ b/packages/react-core/src/components/Dropdown/examples/DropdownWithDescriptions.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Dropdown, DropdownItem, DropdownList, MenuToggle, MenuToggleElement } from '@patternfly/react-core'; export const DropdownWithDescriptions: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggleClick = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Dropdown/examples/DropdownWithGroups.tsx b/packages/react-core/src/components/Dropdown/examples/DropdownWithGroups.tsx index cdd53aed518..7a68605eda1 100644 --- a/packages/react-core/src/components/Dropdown/examples/DropdownWithGroups.tsx +++ b/packages/react-core/src/components/Dropdown/examples/DropdownWithGroups.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Dropdown, DropdownGroup, @@ -9,7 +10,7 @@ import { } from '@patternfly/react-core'; export const DropdownWithGroups: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggleClick = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Dropdown/examples/DropdownWithKebabToggle.tsx b/packages/react-core/src/components/Dropdown/examples/DropdownWithKebabToggle.tsx index c195359b0c2..6dc43da0604 100644 --- a/packages/react-core/src/components/Dropdown/examples/DropdownWithKebabToggle.tsx +++ b/packages/react-core/src/components/Dropdown/examples/DropdownWithKebabToggle.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Dropdown, DropdownItem, DropdownList, Divider, MenuToggle, MenuToggleElement } from '@patternfly/react-core'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const DropdownWithKebab: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggleClick = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/EmptyState/examples/EmptyState.md b/packages/react-core/src/components/EmptyState/examples/EmptyState.md index 1654b7325bc..3966abfa196 100644 --- a/packages/react-core/src/components/EmptyState/examples/EmptyState.md +++ b/packages/react-core/src/components/EmptyState/examples/EmptyState.md @@ -4,6 +4,8 @@ section: components cssPrefix: pf-v6-c-empty-state propComponents: ['EmptyState', 'EmptyStateBody', 'EmptyStateFooter', 'EmptyStateActions'] --- + +import { useState } from 'react'; import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon'; import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; diff --git a/packages/react-core/src/components/EmptyState/examples/EmptyStateWithStatus.tsx b/packages/react-core/src/components/EmptyState/examples/EmptyStateWithStatus.tsx index 81765806961..c9b3a9bceca 100644 --- a/packages/react-core/src/components/EmptyState/examples/EmptyStateWithStatus.tsx +++ b/packages/react-core/src/components/EmptyState/examples/EmptyStateWithStatus.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { EmptyState, EmptyStateBody, @@ -8,7 +9,7 @@ import { } from '@patternfly/react-core'; export const EmptyStateWithStatus: React.FunctionComponent = () => { - const [status, setStatus] = React.useState(EmptyStateStatus.success); + const [status, setStatus] = useState(EmptyStateStatus.success); const toggleStatus = () => { interface StatusToggleMap { diff --git a/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionBasic.tsx b/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionBasic.tsx index ff77ba98af2..9d76f6e10b9 100644 --- a/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionBasic.tsx +++ b/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionBasic.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { ExpandableSection } from '@patternfly/react-core'; export const ExpandableSectionBasic: React.FunctionComponent = () => { - const [isExpanded, setIsExpanded] = React.useState(false); + const [isExpanded, setIsExpanded] = useState(false); const onToggle = (_event: React.MouseEvent, isExpanded: boolean) => { setIsExpanded(isExpanded); diff --git a/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionCustomToggle.tsx b/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionCustomToggle.tsx index 7c6b5f99a83..3f9048722da 100644 --- a/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionCustomToggle.tsx +++ b/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionCustomToggle.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { ExpandableSection, Badge } from '@patternfly/react-core'; import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; export const ExpandableSectionCustomToggle: React.FunctionComponent = () => { - const [isExpanded, setIsExpanded] = React.useState(false); + const [isExpanded, setIsExpanded] = useState(false); const onToggle = (_event: React.MouseEvent, isExpanded: boolean) => { setIsExpanded(isExpanded); diff --git a/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionDetached.tsx b/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionDetached.tsx index 21d17d0e74a..3f7f9042e96 100644 --- a/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionDetached.tsx +++ b/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionDetached.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { ExpandableSection, ExpandableSectionToggle, Stack, StackItem } from '@patternfly/react-core'; export const ExpandableSectionDetached: React.FunctionComponent = () => { - const [isExpanded, setIsExpanded] = React.useState(false); + const [isExpanded, setIsExpanded] = useState(false); const onToggle = (isExpanded: boolean) => { setIsExpanded(isExpanded); diff --git a/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionDisclosure.tsx b/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionDisclosure.tsx index 2990fe52bf5..e9360aa5b13 100644 --- a/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionDisclosure.tsx +++ b/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionDisclosure.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { ExpandableSection } from '@patternfly/react-core'; export const ExpandableSectionDisclosure: React.FunctionComponent = () => { - const [isExpanded, setIsExpanded] = React.useState(false); + const [isExpanded, setIsExpanded] = useState(false); const onToggle = (_event: React.MouseEvent, isExpanded: boolean) => { setIsExpanded(isExpanded); diff --git a/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionTruncateExpansion.tsx b/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionTruncateExpansion.tsx index 83de90fb416..fd0f687bceb 100644 --- a/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionTruncateExpansion.tsx +++ b/packages/react-core/src/components/ExpandableSection/examples/ExpandableSectionTruncateExpansion.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { ExpandableSection, ExpandableSectionVariant } from '@patternfly/react-core'; export const ExpandableSectionTruncateExpansion: React.FunctionComponent = () => { - const [isExpanded, setIsExpanded] = React.useState(false); + const [isExpanded, setIsExpanded] = useState(false); const onToggle = (_event: React.MouseEvent, isExpanded: boolean) => { setIsExpanded(isExpanded); diff --git a/packages/react-core/src/components/FileUpload/examples/FileUpload.md b/packages/react-core/src/components/FileUpload/examples/FileUpload.md index 4280d6a22c3..e6b86e780cb 100644 --- a/packages/react-core/src/components/FileUpload/examples/FileUpload.md +++ b/packages/react-core/src/components/FileUpload/examples/FileUpload.md @@ -6,6 +6,7 @@ section: components subsection: file-upload --- +import { useState } from 'react'; import FileUploadIcon from '@patternfly/react-icons/dist/esm/icons/file-upload-icon'; import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon'; diff --git a/packages/react-core/src/components/FileUpload/examples/FileUploadCustomPreview.tsx b/packages/react-core/src/components/FileUpload/examples/FileUploadCustomPreview.tsx index c0aa86c7e67..0a33f46eb75 100644 --- a/packages/react-core/src/components/FileUpload/examples/FileUploadCustomPreview.tsx +++ b/packages/react-core/src/components/FileUpload/examples/FileUploadCustomPreview.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { FileUpload } from '@patternfly/react-core'; import FileUploadIcon from '@patternfly/react-icons/dist/esm/icons/file-upload-icon'; export const CustomPreviewFileUpload: React.FunctionComponent = () => { - const [value, setValue] = React.useState(); - const [filename, setFilename] = React.useState(''); + const [value, setValue] = useState(); + const [filename, setFilename] = useState(''); const handleFileInputChange = (_, file: File) => { setValue(file); diff --git a/packages/react-core/src/components/FileUpload/examples/FileUploadCustomUpload.tsx b/packages/react-core/src/components/FileUpload/examples/FileUploadCustomUpload.tsx index 27e4d3bffe8..159b26dc5a2 100644 --- a/packages/react-core/src/components/FileUpload/examples/FileUploadCustomUpload.tsx +++ b/packages/react-core/src/components/FileUpload/examples/FileUploadCustomUpload.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { FileUploadField, FileUploadHelperText, HelperText, HelperTextItem, Checkbox } from '@patternfly/react-core'; export const CustomPreviewFileUpload: React.FunctionComponent = () => { @@ -13,17 +14,17 @@ export const CustomPreviewFileUpload: React.FunctionComponent = () => { 'hasPlaceholderText' ]; - const [value, setValue] = React.useState(''); - const [filename, setFilename] = React.useState(false); - const [isBrowseButtonDisabled, setIsBrowseButtonDisabled] = React.useState(true); - const [isClearButtonDisabled, setIsClearButtonDisabled] = React.useState(true); - const [isLoading, setIsLoading] = React.useState(false); - const [isDragActive, setIsDragActive] = React.useState(false); - const [hideDefaultPreview, setHideDefaultPreview] = React.useState(false); - const [hasCustomFilePreview, setHasCustomFilePreview] = React.useState(false); - const [hasHelperText, setHasHelperText] = React.useState(false); - const [hasPlaceholderText, setHasPlaceholderText] = React.useState(false); - const [checkedState, setCheckedState] = React.useState([ + const [value, setValue] = useState(''); + const [filename, setFilename] = useState(false); + const [isBrowseButtonDisabled, setIsBrowseButtonDisabled] = useState(true); + const [isClearButtonDisabled, setIsClearButtonDisabled] = useState(true); + const [isLoading, setIsLoading] = useState(false); + const [isDragActive, setIsDragActive] = useState(false); + const [hideDefaultPreview, setHideDefaultPreview] = useState(false); + const [hasCustomFilePreview, setHasCustomFilePreview] = useState(false); + const [hasHelperText, setHasHelperText] = useState(false); + const [hasPlaceholderText, setHasPlaceholderText] = useState(false); + const [checkedState, setCheckedState] = useState([ filename, isBrowseButtonDisabled, isClearButtonDisabled, diff --git a/packages/react-core/src/components/FileUpload/examples/FileUploadSimpleFile.tsx b/packages/react-core/src/components/FileUpload/examples/FileUploadSimpleFile.tsx index d8d5fae2610..f9e9fea9dcf 100644 --- a/packages/react-core/src/components/FileUpload/examples/FileUploadSimpleFile.tsx +++ b/packages/react-core/src/components/FileUpload/examples/FileUploadSimpleFile.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { FileUpload } from '@patternfly/react-core'; export const SimpleFileUpload: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); - const [filename, setFilename] = React.useState(''); + const [value, setValue] = useState(''); + const [filename, setFilename] = useState(''); const handleFileInputChange = (_, file: File) => { setFilename(file.name); diff --git a/packages/react-core/src/components/FileUpload/examples/FileUploadSimpleText.tsx b/packages/react-core/src/components/FileUpload/examples/FileUploadSimpleText.tsx index 876d6f773ee..ee28f15bd27 100644 --- a/packages/react-core/src/components/FileUpload/examples/FileUploadSimpleText.tsx +++ b/packages/react-core/src/components/FileUpload/examples/FileUploadSimpleText.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { FileUpload, DropEvent } from '@patternfly/react-core'; export const SimpleTextFileUpload: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); - const [filename, setFilename] = React.useState(''); - const [isLoading, setIsLoading] = React.useState(false); + const [value, setValue] = useState(''); + const [filename, setFilename] = useState(''); + const [isLoading, setIsLoading] = useState(false); const handleFileInputChange = (_, file: File) => { setFilename(file.name); diff --git a/packages/react-core/src/components/FileUpload/examples/FileUploadTextWithEdits.tsx b/packages/react-core/src/components/FileUpload/examples/FileUploadTextWithEdits.tsx index 18e3a368019..013e5eb9a09 100644 --- a/packages/react-core/src/components/FileUpload/examples/FileUploadTextWithEdits.tsx +++ b/packages/react-core/src/components/FileUpload/examples/FileUploadTextWithEdits.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { FileUpload, DropEvent } from '@patternfly/react-core'; export const TextFileWithEditsAllowed: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); - const [filename, setFilename] = React.useState(''); - const [isLoading, setIsLoading] = React.useState(false); + const [value, setValue] = useState(''); + const [filename, setFilename] = useState(''); + const [isLoading, setIsLoading] = useState(false); const handleFileInputChange = (_, file: File) => { setFilename(file.name); diff --git a/packages/react-core/src/components/FileUpload/examples/FileUploadTextWithRestrictions.tsx b/packages/react-core/src/components/FileUpload/examples/FileUploadTextWithRestrictions.tsx index d0284856406..5f4f9f3c726 100644 --- a/packages/react-core/src/components/FileUpload/examples/FileUploadTextWithRestrictions.tsx +++ b/packages/react-core/src/components/FileUpload/examples/FileUploadTextWithRestrictions.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { FileUpload, DropzoneErrorCode, @@ -10,11 +11,11 @@ import { } from '@patternfly/react-core'; export const TextFileUploadWithRestrictions: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); - const [filename, setFilename] = React.useState(''); - const [isLoading, setIsLoading] = React.useState(false); - const [isRejected, setIsRejected] = React.useState(false); - const [message, setMessage] = React.useState('Must be a CSV file no larger than 1 KB'); + const [value, setValue] = useState(''); + const [filename, setFilename] = useState(''); + const [isLoading, setIsLoading] = useState(false); + const [isRejected, setIsRejected] = useState(false); + const [message, setMessage] = useState('Must be a CSV file no larger than 1 KB'); const handleFileInputChange = (_, file: File) => { setFilename(file.name); diff --git a/packages/react-core/src/components/FileUpload/examples/FileUploadWithHelperText.tsx b/packages/react-core/src/components/FileUpload/examples/FileUploadWithHelperText.tsx index ddeb124b14e..38b8bf5eb67 100644 --- a/packages/react-core/src/components/FileUpload/examples/FileUploadWithHelperText.tsx +++ b/packages/react-core/src/components/FileUpload/examples/FileUploadWithHelperText.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { FileUpload, FileUploadHelperText, HelperText, HelperTextItem, DropEvent } from '@patternfly/react-core'; export const FileUploadWithHelperText: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); - const [filename, setFilename] = React.useState(''); - const [isLoading, setIsLoading] = React.useState(false); + const [value, setValue] = useState(''); + const [filename, setFilename] = useState(''); + const [isLoading, setIsLoading] = useState(false); const handleFileInputChange = (_, file: File) => { setFilename(file.name); diff --git a/packages/react-core/src/components/FormSelect/examples/FormSelect.md b/packages/react-core/src/components/FormSelect/examples/FormSelect.md index ba075ff4a6d..0a2d572af92 100644 --- a/packages/react-core/src/components/FormSelect/examples/FormSelect.md +++ b/packages/react-core/src/components/FormSelect/examples/FormSelect.md @@ -6,6 +6,7 @@ cssPrefix: pf-v6-c-form-control propComponents: ['FormSelect', 'FormSelectOption', 'FormSelectOptionGroup'] ouia: true --- +import { useState } from 'react'; ## Examples diff --git a/packages/react-core/src/components/FormSelect/examples/FormSelectBasic.tsx b/packages/react-core/src/components/FormSelect/examples/FormSelectBasic.tsx index cf70afb039d..0ee1d7749ad 100644 --- a/packages/react-core/src/components/FormSelect/examples/FormSelectBasic.tsx +++ b/packages/react-core/src/components/FormSelect/examples/FormSelectBasic.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { FormSelect, FormSelectOption } from '@patternfly/react-core'; export const FormSelectBasic: React.FunctionComponent = () => { - const [formSelectValue, setFormSelectValue] = React.useState('mrs'); + const [formSelectValue, setFormSelectValue] = useState('mrs'); const onChange = (_event: React.FormEvent, value: string) => { setFormSelectValue(value); diff --git a/packages/react-core/src/components/FormSelect/examples/FormSelectDisabled.tsx b/packages/react-core/src/components/FormSelect/examples/FormSelectDisabled.tsx index 257a8e8cd4a..d8508fc079f 100644 --- a/packages/react-core/src/components/FormSelect/examples/FormSelectDisabled.tsx +++ b/packages/react-core/src/components/FormSelect/examples/FormSelectDisabled.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { FormSelect, FormSelectOption } from '@patternfly/react-core'; export const FormSelectDisabled: React.FunctionComponent = () => { - const [formSelectValue, setFormSelectValue] = React.useState('mrs'); + const [formSelectValue, setFormSelectValue] = useState('mrs'); const onChange = (_event: React.FormEvent, value: string) => { setFormSelectValue(value); diff --git a/packages/react-core/src/components/FormSelect/examples/FormSelectGrouped.tsx b/packages/react-core/src/components/FormSelect/examples/FormSelectGrouped.tsx index 9aafd8a6c5c..c45d0f41ea9 100644 --- a/packages/react-core/src/components/FormSelect/examples/FormSelectGrouped.tsx +++ b/packages/react-core/src/components/FormSelect/examples/FormSelectGrouped.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { FormSelect, FormSelectOption, FormSelectOptionGroup } from '@patternfly/react-core'; export const FormSelectGrouped: React.FunctionComponent = () => { - const [formSelectValue, setFormSelectValue] = React.useState('2'); + const [formSelectValue, setFormSelectValue] = useState('2'); const onChange = (_event: React.FormEvent, value: string) => { setFormSelectValue(value); diff --git a/packages/react-core/src/components/FormSelect/examples/FormSelectValidated.tsx b/packages/react-core/src/components/FormSelect/examples/FormSelectValidated.tsx index 0ccd5624d33..a8acfbaf972 100644 --- a/packages/react-core/src/components/FormSelect/examples/FormSelectValidated.tsx +++ b/packages/react-core/src/components/FormSelect/examples/FormSelectValidated.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Form, FormGroup, @@ -10,9 +11,9 @@ import { } from '@patternfly/react-core'; export const FormSelectValidated: React.FunctionComponent = () => { - const [formValue, setFormValue] = React.useState(''); - const [helperText, setHelperText] = React.useState(''); - const [validated, setValidated] = React.useState(ValidatedOptions.default); + const [formValue, setFormValue] = useState(''); + const [helperText, setHelperText] = useState(''); + const [validated, setValidated] = useState(ValidatedOptions.default); const simulateNetworkCall = (callback: () => void) => { setTimeout(callback, 2000); diff --git a/packages/react-core/src/components/Hint/examples/Hint.md b/packages/react-core/src/components/Hint/examples/Hint.md index 57aa3740de1..28fd2e21b1a 100644 --- a/packages/react-core/src/components/Hint/examples/Hint.md +++ b/packages/react-core/src/components/Hint/examples/Hint.md @@ -5,7 +5,7 @@ cssPrefix: pf-v6-c-hint propComponents: ['Hint', 'HintTitle', 'HintBody', 'HintFooter'] --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; ## Examples diff --git a/packages/react-core/src/components/Hint/examples/HintActionsWithNoOffset.tsx b/packages/react-core/src/components/Hint/examples/HintActionsWithNoOffset.tsx index 96e8259a5af..841fb4d6b95 100644 --- a/packages/react-core/src/components/Hint/examples/HintActionsWithNoOffset.tsx +++ b/packages/react-core/src/components/Hint/examples/HintActionsWithNoOffset.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Hint, HintTitle, HintBody, Button, Checkbox } from '@patternfly/react-core'; export const HintActionsWithNoOffset: React.FunctionComponent = () => { - const [hasNoActionsOffset, setHasNoActionsOffset] = React.useState(false); + const [hasNoActionsOffset, setHasNoActionsOffset] = useState(false); const toggleOffset = (checked: boolean) => { setHasNoActionsOffset(checked); diff --git a/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx b/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx index 1d7997114b2..47740a26ec6 100644 --- a/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx +++ b/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Hint, HintTitle, @@ -14,7 +15,7 @@ import { import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const HintBasicWithTitle: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggle = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx b/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx index 7884dc245fa..313a6c1c184 100644 --- a/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx +++ b/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Hint, HintBody, @@ -14,7 +14,7 @@ import { import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const HintBasicWithoutTitle: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggle = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Icon/examples/Icon.md b/packages/react-core/src/components/Icon/examples/Icon.md index fcdef78bfb5..172ad48183c 100644 --- a/packages/react-core/src/components/Icon/examples/Icon.md +++ b/packages/react-core/src/components/Icon/examples/Icon.md @@ -5,7 +5,7 @@ cssPrefix: pf-v6-c-icon propComponents: ['Icon'] --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import LongArrowAltDownIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-down-icon'; import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon'; import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon'; diff --git a/packages/react-core/src/components/Icon/examples/IconCustomProgress.tsx b/packages/react-core/src/components/Icon/examples/IconCustomProgress.tsx index 9e319fc0191..e03bd578d4f 100644 --- a/packages/react-core/src/components/Icon/examples/IconCustomProgress.tsx +++ b/packages/react-core/src/components/Icon/examples/IconCustomProgress.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Icon, Spinner, Checkbox } from '@patternfly/react-core'; import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; export const IconProgress: React.FunctionComponent = () => { - const [isInProgress, setIsInProgress] = React.useState(false); + const [isInProgress, setIsInProgress] = useState(false); return (
diff --git a/packages/react-core/src/components/Icon/examples/IconProgress.tsx b/packages/react-core/src/components/Icon/examples/IconProgress.tsx index b9889989a84..f0c59f0cd1e 100644 --- a/packages/react-core/src/components/Icon/examples/IconProgress.tsx +++ b/packages/react-core/src/components/Icon/examples/IconProgress.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Icon, Checkbox } from '@patternfly/react-core'; import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; export const IconProgress: React.FunctionComponent = () => { - const [isInProgress, setIsInProgress] = React.useState(false); + const [isInProgress, setIsInProgress] = useState(false); return (
diff --git a/packages/react-core/src/components/InputGroup/examples/InputGroup.md b/packages/react-core/src/components/InputGroup/examples/InputGroup.md index 6d0d89210e6..901f61cc80c 100644 --- a/packages/react-core/src/components/InputGroup/examples/InputGroup.md +++ b/packages/react-core/src/components/InputGroup/examples/InputGroup.md @@ -5,7 +5,7 @@ cssPrefix: pf-v6-c-input-group propComponents: ['InputGroup', 'InputGroupItem', 'InputGroupText'] --- -import { Fragment } from 'react'; +import { Fragment, useRef, useState } from 'react'; import AtIcon from '@patternfly/react-icons/dist/esm/icons/at-icon'; import DollarSignIcon from '@patternfly/react-icons/dist/esm/icons/dollar-sign-icon'; import CalendarAltIcon from '@patternfly/react-icons/dist/esm/icons/calendar-alt-icon'; diff --git a/packages/react-core/src/components/InputGroup/examples/InputGroupWithDropdown.tsx b/packages/react-core/src/components/InputGroup/examples/InputGroupWithDropdown.tsx index a74d789c126..cf6a38718ee 100644 --- a/packages/react-core/src/components/InputGroup/examples/InputGroupWithDropdown.tsx +++ b/packages/react-core/src/components/InputGroup/examples/InputGroupWithDropdown.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, InputGroup, @@ -12,7 +12,7 @@ import { } from '@patternfly/react-core'; export const InputGroupWithDropdown: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggle = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/InputGroup/examples/InputGroupWithPopover.tsx b/packages/react-core/src/components/InputGroup/examples/InputGroupWithPopover.tsx index 4f4927e7042..3ca507dba39 100644 --- a/packages/react-core/src/components/InputGroup/examples/InputGroupWithPopover.tsx +++ b/packages/react-core/src/components/InputGroup/examples/InputGroupWithPopover.tsx @@ -1,10 +1,10 @@ -import { Fragment } from 'react'; +import { Fragment, useRef } from 'react'; import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon'; import { Button, InputGroup, InputGroupItem, TextInput, Popover, PopoverPosition } from '@patternfly/react-core'; export const InputGroupWithPopover: React.FunctionComponent = () => { - const inputGroupRef1 = React.useRef(null); - const inputGroupRef2 = React.useRef(null); + const inputGroupRef1 = useRef(null); + const inputGroupRef2 = useRef(null); return ( diff --git a/packages/react-core/src/components/Label/examples/Label.md b/packages/react-core/src/components/Label/examples/Label.md index 122b6764cd6..4110ebdf4a1 100644 --- a/packages/react-core/src/components/Label/examples/Label.md +++ b/packages/react-core/src/components/Label/examples/Label.md @@ -5,7 +5,7 @@ cssPrefix: ['pf-v6-c-label', 'pf-v6-c-label-group'] propComponents: ['Label', 'LabelGroup'] --- -import { Fragment } from 'react'; +import { Fragment, useEffect, useRef, useState } from 'react'; import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; import './Label.css'; diff --git a/packages/react-core/src/components/Label/examples/LabelEditable.tsx b/packages/react-core/src/components/Label/examples/LabelEditable.tsx index 75cca9015be..762ff42b076 100644 --- a/packages/react-core/src/components/Label/examples/LabelEditable.tsx +++ b/packages/react-core/src/components/Label/examples/LabelEditable.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Label } from '@patternfly/react-core'; export const LabelEditable: React.FunctionComponent = () => { - const [labelText, setLabelText] = React.useState('Editable label'); - const [compactLabelText, setCompactLabelText] = React.useState('Compact editable label'); + const [labelText, setLabelText] = useState('Editable label'); + const [compactLabelText, setCompactLabelText] = useState('Compact editable label'); const onEditCancel = (_event: KeyboardEvent, prevText: string) => { setLabelText(prevText); diff --git a/packages/react-core/src/components/Label/examples/LabelGroupCategoryRemovable.tsx b/packages/react-core/src/components/Label/examples/LabelGroupCategoryRemovable.tsx index 7b2a67c1cd8..d4435e94f70 100644 --- a/packages/react-core/src/components/Label/examples/LabelGroupCategoryRemovable.tsx +++ b/packages/react-core/src/components/Label/examples/LabelGroupCategoryRemovable.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Label, LabelGroup, LabelProps } from '@patternfly/react-core'; import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; export const LabelGroupCategoryRemovable: React.FunctionComponent = () => { - const [labels, setLabels] = React.useState([ + const [labels, setLabels] = useState([ ['Label 1', 'grey'], ['Label 2', 'blue'], ['Label 3', 'green'], diff --git a/packages/react-core/src/components/Label/examples/LabelGroupEditableAdd.tsx b/packages/react-core/src/components/Label/examples/LabelGroupEditableAdd.tsx index 9038b17a0e2..99ee3b6e653 100644 --- a/packages/react-core/src/components/Label/examples/LabelGroupEditableAdd.tsx +++ b/packages/react-core/src/components/Label/examples/LabelGroupEditableAdd.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { LabelGroup, Label } from '@patternfly/react-core'; export const LabelGroupEditableAdd: React.FunctionComponent = () => { - const [idIndex, setIdIndex] = React.useState(3); - const [labels, setLabels] = React.useState([ + const [idIndex, setIdIndex] = useState(3); + const [labels, setLabels] = useState([ { name: 'Label 1', id: 0 }, { name: 'Label 2', id: 1 }, { diff --git a/packages/react-core/src/components/Label/examples/LabelGroupEditableAddDropdown.tsx b/packages/react-core/src/components/Label/examples/LabelGroupEditableAddDropdown.tsx index 9fa281067b5..51d1d78b976 100644 --- a/packages/react-core/src/components/Label/examples/LabelGroupEditableAddDropdown.tsx +++ b/packages/react-core/src/components/Label/examples/LabelGroupEditableAddDropdown.tsx @@ -1,13 +1,14 @@ +import { useEffect, useRef, useState } from 'react'; import { LabelGroup, Label, Menu, MenuContent, MenuList, MenuItem, Popper } from '@patternfly/react-core'; export const LabelGroupEditableAddDropdown: React.FunctionComponent = () => { - const toggleRef = React.useRef(undefined); - const menuRef = React.useRef(undefined); - const containerRef = React.useRef(undefined); + const toggleRef = useRef(undefined); + const menuRef = useRef(undefined); + const containerRef = useRef(undefined); - const [idIndex, setIdIndex] = React.useState(3); - const [isOpen, setIsOpen] = React.useState(false); - const [labels, setLabels] = React.useState([ + const [idIndex, setIdIndex] = useState(3); + const [isOpen, setIsOpen] = useState(false); + const [labels, setLabels] = useState([ { name: 'Label 1', id: 0 }, { name: 'Label 2', id: 1 }, { @@ -67,7 +68,7 @@ export const LabelGroupEditableAddDropdown: React.FunctionComponent = () => { } }; - React.useEffect(() => { + useEffect(() => { window.addEventListener('keydown', handleMenuKeys); window.addEventListener('click', handleClickOutside); return () => { diff --git a/packages/react-core/src/components/Label/examples/LabelGroupEditableAddModal.tsx b/packages/react-core/src/components/Label/examples/LabelGroupEditableAddModal.tsx index 2ef1ff016b9..d641a5fd0ec 100644 --- a/packages/react-core/src/components/Label/examples/LabelGroupEditableAddModal.tsx +++ b/packages/react-core/src/components/Label/examples/LabelGroupEditableAddModal.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef, useState } from 'react'; import { LabelGroup, Label, @@ -17,27 +18,27 @@ import { Modal as ModalDeprecated, ModalVariant as ModalVariantDeprecated } from import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; export const LabelGroupEditableAddModal: React.FunctionComponent = () => { - const [isModalOpen, setModalOpen] = React.useState(false); - const [idIndex, setIdIndex] = React.useState(7); - const [labelText, setLabelText] = React.useState(''); - const [color, setColor] = React.useState(); - const [icon, setIcon] = React.useState(); - const [labelType, setLabelType] = React.useState('filled'); - const [isClosable, setIsCloseable] = React.useState(false); - const [isEditable, setIsEditable] = React.useState(false); - const labelInputRef = React.useRef(null); + const [isModalOpen, setModalOpen] = useState(false); + const [idIndex, setIdIndex] = useState(7); + const [labelText, setLabelText] = useState(''); + const [color, setColor] = useState(); + const [icon, setIcon] = useState(); + const [labelType, setLabelType] = useState('filled'); + const [isClosable, setIsCloseable] = useState(false); + const [isEditable, setIsEditable] = useState(false); + const labelInputRef = useRef(null); - const [isColorOpen, setIsColorOpen] = React.useState(false); - const colorMenuRef = React.useRef(null); - const colorContainerRef = React.useRef(null); - const colorToggleRef = React.useRef(null); + const [isColorOpen, setIsColorOpen] = useState(false); + const colorMenuRef = useRef(null); + const colorContainerRef = useRef(null); + const colorToggleRef = useRef(null); - const [isIconOpen, setIsIconOpen] = React.useState(false); - const iconMenuRef = React.useRef(null); - const iconContainerRef = React.useRef(null); - const iconToggleRef = React.useRef(null); + const [isIconOpen, setIsIconOpen] = useState(false); + const iconMenuRef = useRef(null); + const iconContainerRef = useRef(null); + const iconToggleRef = useRef(null); - const [labels, setLabels] = React.useState([ + const [labels, setLabels] = useState([ { name: 'Label 1', id: 4 }, { name: 'Label 2', id: 5 }, { @@ -106,7 +107,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => { setModalOpen(!isModalOpen); }; - React.useEffect(() => { + useEffect(() => { if (isModalOpen && labelInputRef && labelInputRef.current) { (labelInputRef.current as HTMLInputElement).focus(); } @@ -136,7 +137,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => { } }; - React.useEffect(() => { + useEffect(() => { window.addEventListener('keydown', handleMenuKeys); window.addEventListener('click', handleClickOutside); return () => { diff --git a/packages/react-core/src/components/Label/examples/LabelGroupEditableLabels.tsx b/packages/react-core/src/components/Label/examples/LabelGroupEditableLabels.tsx index 4e35edd9341..de97126c99a 100644 --- a/packages/react-core/src/components/Label/examples/LabelGroupEditableLabels.tsx +++ b/packages/react-core/src/components/Label/examples/LabelGroupEditableLabels.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { LabelGroup, Label } from '@patternfly/react-core'; export const LabelGroupEditableLabels: React.FunctionComponent = () => { - const [label1, setLabel1] = React.useState('Editable label'); - const [label2, setLabel2] = React.useState('Editable label 2'); - const [label3, setLabel3] = React.useState('Editable label 3'); + const [label1, setLabel1] = useState('Editable label'); + const [label2, setLabel2] = useState('Editable label 2'); + const [label3, setLabel3] = useState('Editable label 3'); return ( diff --git a/packages/react-core/src/components/Label/examples/LabelGroupVerticalCategoryOverflowRemovable.tsx b/packages/react-core/src/components/Label/examples/LabelGroupVerticalCategoryOverflowRemovable.tsx index d0836b118e1..494bf74b96f 100644 --- a/packages/react-core/src/components/Label/examples/LabelGroupVerticalCategoryOverflowRemovable.tsx +++ b/packages/react-core/src/components/Label/examples/LabelGroupVerticalCategoryOverflowRemovable.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Label, LabelGroup, LabelProps } from '@patternfly/react-core'; import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; export const LabelGroupVerticalCategoryOverflowRemovable: React.FunctionComponent = () => { - const [labels, setLabels] = React.useState([ + const [labels, setLabels] = useState([ ['Label 1', 'grey'], ['Label 2', 'blue'], ['Label 3', 'green'], diff --git a/packages/react-core/src/components/LoginPage/examples/LoginPage.md b/packages/react-core/src/components/LoginPage/examples/LoginPage.md index c191d6dff15..7443ce7e6e8 100644 --- a/packages/react-core/src/components/LoginPage/examples/LoginPage.md +++ b/packages/react-core/src/components/LoginPage/examples/LoginPage.md @@ -18,7 +18,7 @@ propComponents: ] --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import brandImg from '../../assets/PF-IconLogo.svg'; import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon'; import GoogleIcon from '@patternfly/react-icons/dist/esm/icons/google-icon'; diff --git a/packages/react-core/src/components/LoginPage/examples/LoginPageBasic.tsx b/packages/react-core/src/components/LoginPage/examples/LoginPageBasic.tsx index a13fcb66a6e..d75d069582a 100644 --- a/packages/react-core/src/components/LoginPage/examples/LoginPageBasic.tsx +++ b/packages/react-core/src/components/LoginPage/examples/LoginPageBasic.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import brandImg from '../../assets/PF-IconLogo.svg'; import { LoginFooterItem, @@ -18,12 +18,12 @@ import FacebookSquareIcon from '@patternfly/react-icons/dist/esm/icons/facebook- import GitlabIcon from '@patternfly/react-icons/dist/esm/icons/gitlab-icon'; export const SimpleLoginPage: React.FunctionComponent = () => { - const [showHelperText, setShowHelperText] = React.useState(false); - const [username, setUsername] = React.useState(''); - const [isValidUsername, setIsValidUsername] = React.useState(true); - const [password, setPassword] = React.useState(''); - const [isValidPassword, setIsValidPassword] = React.useState(true); - const [isRememberMeChecked, setIsRememberMeChecked] = React.useState(false); + const [showHelperText, setShowHelperText] = useState(false); + const [username, setUsername] = useState(''); + const [isValidUsername, setIsValidUsername] = useState(true); + const [password, setPassword] = useState(''); + const [isValidPassword, setIsValidPassword] = useState(true); + const [isRememberMeChecked, setIsRememberMeChecked] = useState(false); const handleUsernameChange = (_event: React.FormEvent, value: string) => { setUsername(value); diff --git a/packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx b/packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx index 23ce6b7a56e..ddb32c8c6a6 100644 --- a/packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx +++ b/packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import brandImg from '../../assets/PF-IconLogo.svg'; import { LoginFooterItem, @@ -23,14 +23,14 @@ import FacebookSquareIcon from '@patternfly/react-icons/dist/esm/icons/facebook- import GitlabIcon from '@patternfly/react-icons/dist/esm/icons/gitlab-icon'; export const LoginPageLanguageSelect: React.FunctionComponent = () => { - const [showHelperText, setShowHelperText] = React.useState(false); - const [username, setUsername] = React.useState(''); - const [isValidUsername, setIsValidUsername] = React.useState(true); - const [password, setPassword] = React.useState(''); - const [isValidPassword, setIsValidPassword] = React.useState(true); - const [isRememberMeChecked, setIsRememberMeChecked] = React.useState(false); - const [isHeaderUtilsOpen, setIsHeaderUtilsOpen] = React.useState(false); - const [selectedHeaderUtils, setSelectedHeaderUtils] = React.useState('English'); + const [showHelperText, setShowHelperText] = useState(false); + const [username, setUsername] = useState(''); + const [isValidUsername, setIsValidUsername] = useState(true); + const [password, setPassword] = useState(''); + const [isValidPassword, setIsValidPassword] = useState(true); + const [isRememberMeChecked, setIsRememberMeChecked] = useState(false); + const [isHeaderUtilsOpen, setIsHeaderUtilsOpen] = useState(false); + const [selectedHeaderUtils, setSelectedHeaderUtils] = useState('English'); /** i18n object is used to simulate i18n integration of native language translation */ const i18n = { diff --git a/packages/react-core/src/components/LoginPage/examples/LoginPageShowHidePassword.tsx b/packages/react-core/src/components/LoginPage/examples/LoginPageShowHidePassword.tsx index 1abf80bbcaa..88f7bead8f3 100644 --- a/packages/react-core/src/components/LoginPage/examples/LoginPageShowHidePassword.tsx +++ b/packages/react-core/src/components/LoginPage/examples/LoginPageShowHidePassword.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import brandImg from '../../assets/PF-IconLogo.svg'; import { LoginFooterItem, @@ -18,12 +18,12 @@ import FacebookSquareIcon from '@patternfly/react-icons/dist/esm/icons/facebook- import GitlabIcon from '@patternfly/react-icons/dist/esm/icons/gitlab-icon'; export const LoginPageHideShowPassword: React.FunctionComponent = () => { - const [showHelperText, setShowHelperText] = React.useState(false); - const [username, setUsername] = React.useState(''); - const [isValidUsername, setIsValidUsername] = React.useState(true); - const [password, setPassword] = React.useState(''); - const [isValidPassword, setIsValidPassword] = React.useState(true); - const [isRememberMeChecked, setIsRememberMeChecked] = React.useState(false); + const [showHelperText, setShowHelperText] = useState(false); + const [username, setUsername] = useState(''); + const [isValidUsername, setIsValidUsername] = useState(true); + const [password, setPassword] = useState(''); + const [isValidPassword, setIsValidPassword] = useState(true); + const [isRememberMeChecked, setIsRememberMeChecked] = useState(false); const handleUsernameChange = (_event: React.FormEvent, value: string) => { setUsername(value); diff --git a/packages/react-core/src/components/Menu/examples/Menu.md b/packages/react-core/src/components/Menu/examples/Menu.md index 105e82ad476..cc7453a89c4 100644 --- a/packages/react-core/src/components/Menu/examples/Menu.md +++ b/packages/react-core/src/components/Menu/examples/Menu.md @@ -20,7 +20,7 @@ propComponents: ouia: true --- -import { Fragment } from 'react'; +import { Fragment, createRef, useEffect, useRef, useState } from 'react'; import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; import ClipboardIcon from '@patternfly/react-icons/dist/esm/icons/clipboard-icon'; import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; diff --git a/packages/react-core/src/components/Menu/examples/MenuBasic.tsx b/packages/react-core/src/components/Menu/examples/MenuBasic.tsx index 9cfd8c6f48f..adbe88058c4 100644 --- a/packages/react-core/src/components/Menu/examples/MenuBasic.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuBasic.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem, Checkbox } from '@patternfly/react-core'; export const MenuBasic: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); - const [isPlain, setIsPlain] = React.useState(false); + const [activeItem, setActiveItem] = useState(0); + const [isPlain, setIsPlain] = useState(false); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; // eslint-disable-next-line no-console diff --git a/packages/react-core/src/components/Menu/examples/MenuDangerMenuItem.tsx b/packages/react-core/src/components/Menu/examples/MenuDangerMenuItem.tsx index cbe5cca57fc..231c75f3f88 100644 --- a/packages/react-core/src/components/Menu/examples/MenuDangerMenuItem.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuDangerMenuItem.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Divider, Menu, MenuContent, MenuItem, MenuList } from '@patternfly/react-core'; export const MenuDangerMenuItem: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; diff --git a/packages/react-core/src/components/Menu/examples/MenuFilterDrilldown.tsx b/packages/react-core/src/components/Menu/examples/MenuFilterDrilldown.tsx index de9925cc349..512db494d7c 100644 --- a/packages/react-core/src/components/Menu/examples/MenuFilterDrilldown.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuFilterDrilldown.tsx @@ -1,3 +1,4 @@ +import { createRef, useState } from 'react'; import { Menu, MenuContent, @@ -11,10 +12,10 @@ import { } from '@patternfly/react-core'; export const MenuWithDrilldown: React.FunctionComponent = () => { - const [menuDrilledIn, setMenuDrilledIn] = React.useState([]); - const [drilldownPath, setDrilldownPath] = React.useState([]); - const [menuHeights, setMenuHeights] = React.useState({}); - const [activeMenu, setActiveMenu] = React.useState('filter_drilldown-rootMenu'); + const [menuDrilledIn, setMenuDrilledIn] = useState([]); + const [drilldownPath, setDrilldownPath] = useState([]); + const [menuHeights, setMenuHeights] = useState({}); + const [activeMenu, setActiveMenu] = useState('filter_drilldown-rootMenu'); const drillIn = ( _event: React.KeyboardEvent | React.MouseEvent, @@ -44,8 +45,8 @@ export const MenuWithDrilldown: React.FunctionComponent = () => { } }; - const searchRef = React.createRef(); - const [startInput, setStartInput] = React.useState(''); + const searchRef = createRef(); + const [startInput, setStartInput] = useState(''); const handleStartTextInputChange = (value: string) => { setStartInput(value); diff --git a/packages/react-core/src/components/Menu/examples/MenuFilteringWithSearchInput.tsx b/packages/react-core/src/components/Menu/examples/MenuFilteringWithSearchInput.tsx index 7e650dcfdd1..af9bc152f98 100644 --- a/packages/react-core/src/components/Menu/examples/MenuFilteringWithSearchInput.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuFilteringWithSearchInput.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Menu, MenuList, @@ -10,8 +11,8 @@ import { } from '@patternfly/react-core'; export const MenuFilteringWithSearchInput: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); - const [input, setInput] = React.useState(''); + const [activeItem, setActiveItem] = useState(0); + const [input, setInput] = useState(''); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; // eslint-disable-next-line no-console diff --git a/packages/react-core/src/components/Menu/examples/MenuOptionMultiSelect.tsx b/packages/react-core/src/components/Menu/examples/MenuOptionMultiSelect.tsx index 7f04d95f6c4..55f6a21ce87 100644 --- a/packages/react-core/src/components/Menu/examples/MenuOptionMultiSelect.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuOptionMultiSelect.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; import TableIcon from '@patternfly/react-icons/dist/esm/icons/table-icon'; export const MenuOptionMultiSelect: React.FunctionComponent = () => { - const [selectedItems, setSelectedItems] = React.useState([]); + const [selectedItems, setSelectedItems] = useState([]); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; diff --git a/packages/react-core/src/components/Menu/examples/MenuOptionSingleSelect.tsx b/packages/react-core/src/components/Menu/examples/MenuOptionSingleSelect.tsx index f0933e56841..14dfd07279d 100644 --- a/packages/react-core/src/components/Menu/examples/MenuOptionSingleSelect.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuOptionSingleSelect.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; import TableIcon from '@patternfly/react-icons/dist/esm/icons/table-icon'; export const MenuOptionSingleSelect: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); - const [selectedItem, setSelectedItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); + const [selectedItem, setSelectedItem] = useState(0); const onSelect = (_event, itemId) => { setActiveItem(itemId); diff --git a/packages/react-core/src/components/Menu/examples/MenuScrollable.tsx b/packages/react-core/src/components/Menu/examples/MenuScrollable.tsx index 14fa48aef16..187c79cc5a5 100644 --- a/packages/react-core/src/components/Menu/examples/MenuScrollable.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuScrollable.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; export const MenuScrollable: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event, itemId) => { // eslint-disable-next-line no-console diff --git a/packages/react-core/src/components/Menu/examples/MenuScrollableCustomMenuHeight.tsx b/packages/react-core/src/components/Menu/examples/MenuScrollableCustomMenuHeight.tsx index 0cb266f0a26..eb5d8129ccb 100644 --- a/packages/react-core/src/components/Menu/examples/MenuScrollableCustomMenuHeight.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuScrollableCustomMenuHeight.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; export const MenuScrollableCustomMenuHeight: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event, itemId) => { // eslint-disable-next-line no-console diff --git a/packages/react-core/src/components/Menu/examples/MenuWithActions.tsx b/packages/react-core/src/components/Menu/examples/MenuWithActions.tsx index c36a34ab9ac..00f47e38e8e 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithActions.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithActions.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuGroup, MenuList, MenuItem, MenuItemAction } from '@patternfly/react-core'; import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; import ClipboardIcon from '@patternfly/react-icons/dist/esm/icons/clipboard-icon'; @@ -5,7 +6,7 @@ import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-i import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; export const MenuWithActions: React.FunctionComponent = () => { - const [selectedItems, setSelectedItems] = React.useState([0, 2, 3]); + const [selectedItems, setSelectedItems] = useState([0, 2, 3]); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; diff --git a/packages/react-core/src/components/Menu/examples/MenuWithCheckbox.tsx b/packages/react-core/src/components/Menu/examples/MenuWithCheckbox.tsx index 7669eaa4d73..b90e3bd45d3 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithCheckbox.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithCheckbox.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; export const MenuWithCheckbox: React.FunctionComponent = () => { - const [selectedItems, setSelectedItems] = React.useState([]); + const [selectedItems, setSelectedItems] = useState([]); /* eslint no-unused-vars: ["error", {"args": "after-used"}] */ const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { diff --git a/packages/react-core/src/components/Menu/examples/MenuWithDescription.tsx b/packages/react-core/src/components/Menu/examples/MenuWithDescription.tsx index a7010bece52..c260665fec2 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithDescription.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithDescription.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; export const MenuWithDescription: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; // eslint-disable-next-line no-console diff --git a/packages/react-core/src/components/Menu/examples/MenuWithDrilldown.tsx b/packages/react-core/src/components/Menu/examples/MenuWithDrilldown.tsx index dfffc827a9b..5dd3e848c7a 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithDrilldown.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithDrilldown.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem, Divider, DrilldownMenu } from '@patternfly/react-core'; import StorageDomainIcon from '@patternfly/react-icons/dist/esm/icons/storage-domain-icon'; import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; @@ -5,10 +6,10 @@ import LayerGroupIcon from '@patternfly/react-icons/dist/esm/icons/layer-group-i import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; export const MenuWithDrilldown: React.FunctionComponent = () => { - const [menuDrilledIn, setMenuDrilledIn] = React.useState([]); - const [drilldownPath, setDrilldownPath] = React.useState([]); - const [menuHeights, setMenuHeights] = React.useState({}); - const [activeMenu, setActiveMenu] = React.useState('drilldown-rootMenu'); + const [menuDrilledIn, setMenuDrilledIn] = useState([]); + const [drilldownPath, setDrilldownPath] = useState([]); + const [menuHeights, setMenuHeights] = useState({}); + const [activeMenu, setActiveMenu] = useState('drilldown-rootMenu'); const drillIn = ( _event: React.KeyboardEvent | React.MouseEvent, diff --git a/packages/react-core/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx b/packages/react-core/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx index d6ec14ffefb..34f706fad8b 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx @@ -1,4 +1,4 @@ -import { type JSX, useState } from 'react'; +import { useState } from 'react'; import { Badge, Breadcrumb, @@ -30,7 +30,7 @@ export const MenuWithDrilldownBreadcrumbs: React.FunctionComponent = () => { const [drilldownPath, setDrilldownPath] = useState([]); const [menuHeights, setMenuHeights] = useState({}); const [activeMenu, setActiveMenu] = useState('breadcrumbs-rootMenu'); - const [breadcrumb, setBreadcrumb] = useState(); + const [breadcrumb, setBreadcrumb] = useState(); const [withMaxMenuHeight, setWithMaxMenuHeight] = useState(false); const onToggle = (isOpen: boolean, key: string) => { @@ -60,7 +60,7 @@ export const MenuWithDrilldownBreadcrumbs: React.FunctionComponent = () => { _event: React.KeyboardEvent | MouseEvent | React.MouseEvent, toMenuId: string, fromPathId: string, - breadcrumb: JSX.Element | null + breadcrumb: React.JSX.Element | null ) => { setMenuDrilledIn((prevMenuDrilledIn) => { const indexOfMenuId = prevMenuDrilledIn.indexOf(toMenuId); diff --git a/packages/react-core/src/components/Menu/examples/MenuWithDrilldownInitialState.tsx b/packages/react-core/src/components/Menu/examples/MenuWithDrilldownInitialState.tsx index 69d8909fbe9..fc6864134c6 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithDrilldownInitialState.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithDrilldownInitialState.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem, Divider, DrilldownMenu } from '@patternfly/react-core'; import StorageDomainIcon from '@patternfly/react-icons/dist/esm/icons/storage-domain-icon'; import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; @@ -5,13 +6,13 @@ import LayerGroupIcon from '@patternfly/react-icons/dist/esm/icons/layer-group-i import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; export const MenuDrilldownInitialState: React.FunctionComponent = () => { - const [menuDrilledIn, setMenuDrilledIn] = React.useState([ + const [menuDrilledIn, setMenuDrilledIn] = useState([ 'initial-state-rootMenu', 'initial-state-drilldownMenuStart' ]); - const [drilldownPath, setDrilldownPath] = React.useState(['group:start_rollout', 'group:app_grouping']); - const [menuHeights, setMenuHeights] = React.useState({ 'initial-state-rootMenu': 216 }); // The root menu height must be defined when starting from a drilled in state - const [activeMenu, setActiveMenu] = React.useState('initial-state-drilldownMenuStartGrouping'); + const [drilldownPath, setDrilldownPath] = useState(['group:start_rollout', 'group:app_grouping']); + const [menuHeights, setMenuHeights] = useState({ 'initial-state-rootMenu': 216 }); // The root menu height must be defined when starting from a drilled in state + const [activeMenu, setActiveMenu] = useState('initial-state-drilldownMenuStartGrouping'); const drillIn = ( _event: React.KeyboardEvent | React.MouseEvent, diff --git a/packages/react-core/src/components/Menu/examples/MenuWithDrilldownSubmenuFunctions.tsx b/packages/react-core/src/components/Menu/examples/MenuWithDrilldownSubmenuFunctions.tsx index d868155abdd..013ad5039bb 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithDrilldownSubmenuFunctions.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithDrilldownSubmenuFunctions.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem, Divider, DrilldownMenu } from '@patternfly/react-core'; import StorageDomainIcon from '@patternfly/react-icons/dist/esm/icons/storage-domain-icon'; import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; @@ -5,10 +6,10 @@ import LayerGroupIcon from '@patternfly/react-icons/dist/esm/icons/layer-group-i import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; export const MenuWithDrilldownSubmenuFunctions: React.FunctionComponent = () => { - const [menuDrilledIn, setMenuDrilledIn] = React.useState([]); - const [drilldownPath, setDrilldownPath] = React.useState([]); - const [menuHeights, setMenuHeights] = React.useState({}); - const [activeMenu, setActiveMenu] = React.useState('functions-rootMenu'); + const [menuDrilledIn, setMenuDrilledIn] = useState([]); + const [drilldownPath, setDrilldownPath] = useState([]); + const [menuHeights, setMenuHeights] = useState({}); + const [activeMenu, setActiveMenu] = useState('functions-rootMenu'); const drillIn = ( _event: React.KeyboardEvent | React.MouseEvent, diff --git a/packages/react-core/src/components/Menu/examples/MenuWithFavorites.tsx b/packages/react-core/src/components/Menu/examples/MenuWithFavorites.tsx index a5de6ba02d8..638168bfd0b 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithFavorites.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithFavorites.tsx @@ -1,12 +1,12 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Menu, MenuContent, MenuItem, MenuItemAction, MenuGroup, MenuList, Divider } from '@patternfly/react-core'; import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; import ClipboardIcon from '@patternfly/react-icons/dist/esm/icons/clipboard-icon'; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; export const MenuWithFavorites: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); - const [favorites, setFavorites] = React.useState([]); + const [activeItem, setActiveItem] = useState(0); + const [favorites, setFavorites] = useState([]); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; // eslint-disable-next-line no-console diff --git a/packages/react-core/src/components/Menu/examples/MenuWithFooter.tsx b/packages/react-core/src/components/Menu/examples/MenuWithFooter.tsx index eff3431967d..1302c5cda6e 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithFooter.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithFooter.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Menu, MenuList, MenuItem, MenuContent, MenuFooter, Button } from '@patternfly/react-core'; export const MenuWithFooter: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; diff --git a/packages/react-core/src/components/Menu/examples/MenuWithIcons.tsx b/packages/react-core/src/components/Menu/examples/MenuWithIcons.tsx index ab9fdb780c1..32f91f9f7d8 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithIcons.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithIcons.tsx @@ -1,10 +1,11 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; import LayerGroupIcon from '@patternfly/react-icons/dist/esm/icons/layer-group-icon'; import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; export const MenuWithIcons: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; // eslint-disable-next-line no-console diff --git a/packages/react-core/src/components/Menu/examples/MenuWithLinks.tsx b/packages/react-core/src/components/Menu/examples/MenuWithLinks.tsx index 9fafd131a14..111ff3b93bc 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithLinks.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithLinks.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; export const MenuWithLinks: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; // eslint-disable-next-line no-console diff --git a/packages/react-core/src/components/Menu/examples/MenuWithSeparators.tsx b/packages/react-core/src/components/Menu/examples/MenuWithSeparators.tsx index 6c319da9bc0..87b9ff12a2d 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithSeparators.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithSeparators.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Divider, Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; export const MenuWithSeparators: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; diff --git a/packages/react-core/src/components/Menu/examples/MenuWithTitledGroups.tsx b/packages/react-core/src/components/Menu/examples/MenuWithTitledGroups.tsx index 1ea4f912309..beac4de49eb 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithTitledGroups.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithTitledGroups.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Menu, MenuContent, MenuGroup, MenuList, MenuItem, Divider } from '@patternfly/react-core'; export const MenuWithTitledGroups: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.MouseEvent | undefined, itemId: number | string | undefined) => { const item = itemId as number; // eslint-disable-next-line no-console diff --git a/packages/react-core/src/components/Menu/examples/MenuWithViewMore.tsx b/packages/react-core/src/components/Menu/examples/MenuWithViewMore.tsx index f856a0968ad..481c16f50c5 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithViewMore.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithViewMore.tsx @@ -1,11 +1,12 @@ +import { useEffect, useRef, useState } from 'react'; import { Menu, MenuList, MenuItem, MenuContent, Spinner } from '@patternfly/react-core'; export const MenuWithViewMore: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); - const [isLoading, setIsLoading] = React.useState(false); - const [numOptions, setNumOptions] = React.useState(3); + const [activeItem, setActiveItem] = useState(0); + const [isLoading, setIsLoading] = useState(false); + const [numOptions, setNumOptions] = useState(3); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [menuOptions, setMenuOptions] = React.useState([ + const [menuOptions, setMenuOptions] = useState([ Action , @@ -40,12 +41,12 @@ export const MenuWithViewMore: React.FunctionComponent = () => { Final option ]); - const [visibleOptions, setVisibleOptions] = React.useState(menuOptions.slice(0, numOptions)); + const [visibleOptions, setVisibleOptions] = useState(menuOptions.slice(0, numOptions)); - const activeItemRef = React.useRef(null); - const viewMoreRef = React.useRef(null); + const activeItemRef = useRef(null); + const viewMoreRef = useRef(null); - React.useEffect(() => { + useEffect(() => { activeItemRef.current?.focus(); }, [visibleOptions]); diff --git a/packages/react-core/src/components/MenuToggle/examples/MenuToggle.md b/packages/react-core/src/components/MenuToggle/examples/MenuToggle.md index 83bcbb26024..bed5edd7cae 100644 --- a/packages/react-core/src/components/MenuToggle/examples/MenuToggle.md +++ b/packages/react-core/src/components/MenuToggle/examples/MenuToggle.md @@ -6,7 +6,7 @@ cssPrefix: pf-v6-c-menu-toggle propComponents: ['MenuToggle', 'MenuToggleAction', 'MenuToggleCheckbox'] --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import './MenuToggle.css' import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; @@ -61,12 +61,13 @@ import { MenuToggle } from '@patternfly/react-core'; To display a count of selected items in a toggle, use the `badge` property. You can also pass in `variant="plainText"` for a badge only toggle. ```ts +import { Fragment } from 'react'; import { MenuToggle, Badge } from '@patternfly/react-core'; - + 4 selected}>Count 4} /> - + ``` ### With icons @@ -76,10 +77,11 @@ To add a recognizable icon to a menu toggle, use the `icon` property. The follow For most basic icons, it is recommended to wrap it inside our [icon component](/components/icon). ```ts +import { Fragment } from 'react'; import { MenuToggle } from '@patternfly/react-core'; import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; - + } variant="primary" @@ -99,7 +101,7 @@ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; > Icon -; +; ``` ### With avatar and text @@ -109,14 +111,15 @@ You can also pass images into the `icon` property. The following example passes This can be used alongside a text label that provides more context for the image. ```ts +import { Fragment } from 'react'; import { MenuToggle, Avatar } from '@patternfly/react-core'; import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg'; - + }>Ned Username{' '} } isExpanded>Ned Username{' '} } isDisabled>Ned Username - + ``` ### Variant styles @@ -124,10 +127,11 @@ import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.sv Variant styling can be applied to menu toggles. In the following example, the toggle uses primary styling by passing `variant="primary"` into the `` component. Additional variant options include “default”, “plain”, “plainText”, “secondary”, and “typeahead”. ```ts +import { Fragment } from 'react'; import { MenuToggle } from '@patternfly/react-core'; import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; - + Collapsed{' '} Expanded @@ -135,7 +139,7 @@ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; Disabled - + ``` @@ -146,16 +150,17 @@ To apply plain styling to a menu toggle with an icon, pass in `variant="plain"`. If the toggle does not have any visible text content, use the `aria-label` property to provide an accessible name. ```ts +import { Fragment } from 'react'; import { MenuToggle } from '@patternfly/react-core'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; - + } variant="plain" aria-label="plain kebab"/> {' '} } variant="plain" isExpanded aria-label="plain expanded kebab"/> {' '} } variant="plain" isDisabled aria-label="disabled plain kebab"/> - + ``` ### Plain toggle with text label @@ -163,9 +168,10 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico To apply plain styling to a menu toggle with a text label, pass in `variant="plainText"`. Unlike the “plain” variant, “plainText” adds a caret pointing down in the toggle. ```ts +import { Fragment } from 'react'; import { MenuToggle } from '@patternfly/react-core'; - + Disabled {' '} @@ -175,7 +181,7 @@ import { MenuToggle } from '@patternfly/react-core'; Custom text (expanded) - + ``` ### Split toggle with checkbox diff --git a/packages/react-core/src/components/MenuToggle/examples/MenuToggleTypeahead.tsx b/packages/react-core/src/components/MenuToggle/examples/MenuToggleTypeahead.tsx index 6cb4f054a31..6358c1a6566 100644 --- a/packages/react-core/src/components/MenuToggle/examples/MenuToggleTypeahead.tsx +++ b/packages/react-core/src/components/MenuToggle/examples/MenuToggleTypeahead.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { MenuToggle, TextInputGroup, @@ -8,7 +9,7 @@ import { import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon'; export const MenuToggleTypeahead: React.FunctionComponent = () => { - const [inputValue, setInputValue] = React.useState(''); + const [inputValue, setInputValue] = useState(''); const onTextInputChange = (_event: React.FormEvent, value: string) => { setInputValue(value); diff --git a/packages/react-core/src/components/Modal/examples/Modal.md b/packages/react-core/src/components/Modal/examples/Modal.md index 245ec9176b5..9577b2ede69 100644 --- a/packages/react-core/src/components/Modal/examples/Modal.md +++ b/packages/react-core/src/components/Modal/examples/Modal.md @@ -6,7 +6,7 @@ propComponents: ['Modal', 'ModalBody', 'ModalHeader', 'ModalFooter'] ouia: true --- -import { Fragment } from 'react'; +import { Fragment, useRef, useState } from 'react'; import WarningTriangleIcon from '@patternfly/react-icons/dist/esm/icons/warning-triangle-icon'; import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon'; import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon'; diff --git a/packages/react-core/src/components/Modal/examples/ModalBasic.tsx b/packages/react-core/src/components/Modal/examples/ModalBasic.tsx index d5ab9b2b079..7ebec3da305 100644 --- a/packages/react-core/src/components/Modal/examples/ModalBasic.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalBasic.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from '@patternfly/react-core'; export const ModalBasic: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalCustomFocus.tsx b/packages/react-core/src/components/Modal/examples/ModalCustomFocus.tsx index 53f53e349d2..883594a06c7 100644 --- a/packages/react-core/src/components/Modal/examples/ModalCustomFocus.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalCustomFocus.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from '@patternfly/react-core'; export const ModalCustomFocus: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalCustomHeader.tsx b/packages/react-core/src/components/Modal/examples/ModalCustomHeader.tsx index ae88353ee72..419af47efa8 100644 --- a/packages/react-core/src/components/Modal/examples/ModalCustomHeader.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalCustomHeader.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, @@ -15,7 +15,7 @@ import { import WarningTriangleIcon from '@patternfly/react-icons/dist/esm/icons/warning-triangle-icon'; export const ModalCustomHeaderFooter: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalCustomTitleIcon.tsx b/packages/react-core/src/components/Modal/examples/ModalCustomTitleIcon.tsx index 8741d4c68a6..97b292605a9 100644 --- a/packages/react-core/src/components/Modal/examples/ModalCustomTitleIcon.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalCustomTitleIcon.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from '@patternfly/react-core'; import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon'; export const ModalCustomTitleIcon: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalCustomWidth.tsx b/packages/react-core/src/components/Modal/examples/ModalCustomWidth.tsx index d464c5f4e1d..174eb56d57c 100644 --- a/packages/react-core/src/components/Modal/examples/ModalCustomWidth.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalCustomWidth.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from '@patternfly/react-core'; export const ModalCustomWidth: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalNoHeaderFooter.tsx b/packages/react-core/src/components/Modal/examples/ModalNoHeaderFooter.tsx index 730782aaa6e..beccbdd3df6 100644 --- a/packages/react-core/src/components/Modal/examples/ModalNoHeaderFooter.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalNoHeaderFooter.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalVariant } from '@patternfly/react-core'; export const ModalNoHeaderFooter: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalSize.tsx b/packages/react-core/src/components/Modal/examples/ModalSize.tsx index caef963c893..9898430d55a 100644 --- a/packages/react-core/src/components/Modal/examples/ModalSize.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalSize.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalFooter, ModalHeader, ModalVariant, Radio } from '@patternfly/react-core'; export const ModalSize: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); - const [selectedVariant, setSelectedVariant] = React.useState(ModalVariant.small); + const [isModalOpen, setIsModalOpen] = useState(false); + const [selectedVariant, setSelectedVariant] = useState(ModalVariant.small); const capitalize = (input: string) => input[0].toUpperCase() + input.substring(1); const formatSizeVariantName = (variant: string) => capitalize(variant); diff --git a/packages/react-core/src/components/Modal/examples/ModalTitleIcon.tsx b/packages/react-core/src/components/Modal/examples/ModalTitleIcon.tsx index d422124089b..d9e13b60229 100644 --- a/packages/react-core/src/components/Modal/examples/ModalTitleIcon.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalTitleIcon.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from '@patternfly/react-core'; export const ModalTitleIcon: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalTopAligned.tsx b/packages/react-core/src/components/Modal/examples/ModalTopAligned.tsx index 99d021475f1..a710ec1baa4 100644 --- a/packages/react-core/src/components/Modal/examples/ModalTopAligned.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalTopAligned.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from '@patternfly/react-core'; export const ModalTopAligned: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalWithDescription.tsx b/packages/react-core/src/components/Modal/examples/ModalWithDescription.tsx index d92739aa7c6..b84a848cf0d 100644 --- a/packages/react-core/src/components/Modal/examples/ModalWithDescription.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalWithDescription.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalHeader, ModalFooter, ModalVariant } from '@patternfly/react-core'; export const ModalWithDescription: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalWithDropdown.tsx b/packages/react-core/src/components/Modal/examples/ModalWithDropdown.tsx index 2425c07aab1..1e2104dbb69 100644 --- a/packages/react-core/src/components/Modal/examples/ModalWithDropdown.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalWithDropdown.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Dropdown, @@ -14,8 +14,8 @@ import { } from '@patternfly/react-core'; export const ModalWithDropdown: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); - const [isDropdownOpen, setIsDropdownOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); + const [isDropdownOpen, setIsDropdownOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalWithForm.tsx b/packages/react-core/src/components/Modal/examples/ModalWithForm.tsx index 50820630501..14283a69025 100644 --- a/packages/react-core/src/components/Modal/examples/ModalWithForm.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalWithForm.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useRef, useState } from 'react'; import { Button, Form, @@ -14,13 +14,13 @@ import { } from '@patternfly/react-core'; export const ModalWithForm: React.FunctionComponent = () => { - const [isModalOpen, setModalOpen] = React.useState(false); - const [nameValue, setNameValue] = React.useState(''); - const [emailValue, setEmailValue] = React.useState(''); - const [addressValue, setAddressValue] = React.useState(''); - const nameLabelHelpRef = React.useRef(null); - const emailLabelHelpRef = React.useRef(null); - const addressLabelHelpRef = React.useRef(null); + const [isModalOpen, setModalOpen] = useState(false); + const [nameValue, setNameValue] = useState(''); + const [emailValue, setEmailValue] = useState(''); + const [addressValue, setAddressValue] = useState(''); + const nameLabelHelpRef = useRef(null); + const emailLabelHelpRef = useRef(null); + const addressLabelHelpRef = useRef(null); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalWithHelp.tsx b/packages/react-core/src/components/Modal/examples/ModalWithHelp.tsx index 5d526d9fcdc..3e7a01ce6c0 100644 --- a/packages/react-core/src/components/Modal/examples/ModalWithHelp.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalWithHelp.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalFooter, ModalHeader, Popover } from '@patternfly/react-core'; import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon'; export const ModalWithHelp: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen(!isModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalWithOverflowingContent.tsx b/packages/react-core/src/components/Modal/examples/ModalWithOverflowingContent.tsx index 1efb9ca744c..ec40b93d228 100644 --- a/packages/react-core/src/components/Modal/examples/ModalWithOverflowingContent.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalWithOverflowingContent.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalBody, ModalHeader, ModalFooter, ModalVariant } from '@patternfly/react-core'; export const ModalWithOverflowingContent: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen((prevIsModalOpen) => !prevIsModalOpen); diff --git a/packages/react-core/src/components/Modal/examples/ModalWithWizard.tsx b/packages/react-core/src/components/Modal/examples/ModalWithWizard.tsx index 6aae60a84d1..cbf745b2316 100644 --- a/packages/react-core/src/components/Modal/examples/ModalWithWizard.tsx +++ b/packages/react-core/src/components/Modal/examples/ModalWithWizard.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Button, Modal, ModalVariant, Wizard, WizardHeader, WizardStep } from '@patternfly/react-core'; export const ModalWithWizard: React.FunctionComponent = () => { - const [isModalOpen, setIsModalOpen] = React.useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { setIsModalOpen((prevIsModalOpen) => !prevIsModalOpen); diff --git a/packages/react-core/src/components/MultipleFileUpload/examples/MultipleFileUpload.md b/packages/react-core/src/components/MultipleFileUpload/examples/MultipleFileUpload.md index d704d98f25a..9ded7604897 100644 --- a/packages/react-core/src/components/MultipleFileUpload/examples/MultipleFileUpload.md +++ b/packages/react-core/src/components/MultipleFileUpload/examples/MultipleFileUpload.md @@ -7,6 +7,7 @@ propComponents: ['MultipleFileUpload', 'MultipleFileUploadMain', 'MultipleFileUploadStatus', 'MultipleFileUploadStatusItem'] --- +import { useEffect, useState } from 'react'; import UploadIcon from '@patternfly/react-icons/dist/esm/icons/upload-icon'; Multiple file upload is able to: diff --git a/packages/react-core/src/components/MultipleFileUpload/examples/MultipleFileUploadBasic.tsx b/packages/react-core/src/components/MultipleFileUpload/examples/MultipleFileUploadBasic.tsx index a26be260968..db53acd016d 100644 --- a/packages/react-core/src/components/MultipleFileUpload/examples/MultipleFileUploadBasic.tsx +++ b/packages/react-core/src/components/MultipleFileUpload/examples/MultipleFileUploadBasic.tsx @@ -1,3 +1,4 @@ +import { useEffect, useState } from 'react'; import { MultipleFileUpload, MultipleFileUploadMain, @@ -18,12 +19,12 @@ interface readFile { } export const MultipleFileUploadBasic: React.FunctionComponent = () => { - const [isHorizontal, setIsHorizontal] = React.useState(false); - const [fileUploadShouldFail, setFileUploadShouldFail] = React.useState(false); - const [currentFiles, setCurrentFiles] = React.useState([]); - const [readFileData, setReadFileData] = React.useState([]); - const [showStatus, setShowStatus] = React.useState(false); - const [statusIcon, setStatusIcon] = React.useState('inProgress'); + const [isHorizontal, setIsHorizontal] = useState(false); + const [fileUploadShouldFail, setFileUploadShouldFail] = useState(false); + const [currentFiles, setCurrentFiles] = useState([]); + const [readFileData, setReadFileData] = useState([]); + const [showStatus, setShowStatus] = useState(false); + const [statusIcon, setStatusIcon] = useState('inProgress'); // only show the status component once a file has been uploaded, but keep the status list component itself even if all files are removed if (!showStatus && currentFiles.length > 0) { @@ -31,7 +32,7 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => { } // determine the icon that should be shown for the overall status list - React.useEffect(() => { + useEffect(() => { if (readFileData.length < currentFiles.length) { setStatusIcon('inProgress'); } else if (readFileData.every((file) => file.loadResult === 'success')) { diff --git a/packages/react-core/src/components/Nav/examples/Nav.md b/packages/react-core/src/components/Nav/examples/Nav.md index 093e99d6083..df18298f17b 100644 --- a/packages/react-core/src/components/Nav/examples/Nav.md +++ b/packages/react-core/src/components/Nav/examples/Nav.md @@ -6,6 +6,7 @@ propComponents: ['Nav', 'NavList', 'NavGroup', 'NavItem', 'NavItemSeparator', 'N ouia: true --- +import { useState } from 'react'; import './nav.css'; import ArrowRightIcon from '@patternfly/react-icons/dist/esm/icons/arrow-right-icon'; import UserIcon from '@patternfly/react-icons/dist/esm/icons/user-icon'; diff --git a/packages/react-core/src/components/Nav/examples/NavDefault.tsx b/packages/react-core/src/components/Nav/examples/NavDefault.tsx index c3bc1386532..fd9beb83fd0 100644 --- a/packages/react-core/src/components/Nav/examples/NavDefault.tsx +++ b/packages/react-core/src/components/Nav/examples/NavDefault.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Nav, NavItem, NavList } from '@patternfly/react-core'; export const NavDefault: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.FormEvent, result: { itemId: number | string }) => { setActiveItem(result.itemId as number); diff --git a/packages/react-core/src/components/Nav/examples/NavDrilldown.tsx b/packages/react-core/src/components/Nav/examples/NavDrilldown.tsx index f4217edc458..ecb4366a7b7 100644 --- a/packages/react-core/src/components/Nav/examples/NavDrilldown.tsx +++ b/packages/react-core/src/components/Nav/examples/NavDrilldown.tsx @@ -1,12 +1,10 @@ -import { type JSX, useState } from 'react'; - import { Nav, MenuContent, MenuItem, MenuList, DrilldownMenu, Menu } from '@patternfly/react-core'; interface MenuHeights { [menuId: string]: number; } -const subMenuTwo: JSX.Element = ( +const subMenuTwo: React.JSX.Element = ( SubMenu 1 - Item 1 @@ -23,7 +21,7 @@ const subMenuTwo: JSX.Element = ( ); -const subMenuOne: JSX.Element = ( +const subMenuOne: React.JSX.Element = ( Item 1 diff --git a/packages/react-core/src/components/Nav/examples/NavExpandable.tsx b/packages/react-core/src/components/Nav/examples/NavExpandable.tsx index 3461449e6fc..8fc66179cb6 100644 --- a/packages/react-core/src/components/Nav/examples/NavExpandable.tsx +++ b/packages/react-core/src/components/Nav/examples/NavExpandable.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Nav, NavExpandable, NavItem, NavList } from '@patternfly/react-core'; export const NavExpandableExample: React.FunctionComponent = () => { - const [activeGroup, setActiveGroup] = React.useState('nav-expandable-group-1'); - const [activeItem, setActiveItem] = React.useState('nav-expandable-group-1_item-1'); + const [activeGroup, setActiveGroup] = useState('nav-expandable-group-1'); + const [activeItem, setActiveItem] = useState('nav-expandable-group-1_item-1'); const onSelect = ( _event: React.FormEvent, diff --git a/packages/react-core/src/components/Nav/examples/NavExpandableThirdLevel.tsx b/packages/react-core/src/components/Nav/examples/NavExpandableThirdLevel.tsx index 5c50aef9d32..d832d1d31ad 100644 --- a/packages/react-core/src/components/Nav/examples/NavExpandableThirdLevel.tsx +++ b/packages/react-core/src/components/Nav/examples/NavExpandableThirdLevel.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Nav, NavExpandable, NavItem, NavList } from '@patternfly/react-core'; export const NavExpandableThirdLevel: React.FunctionComponent = () => { - const [activeGroup, setActiveGroup] = React.useState('nav-expand3rd-group-1'); - const [activeItem, setActiveItem] = React.useState('nav-expand3rd-group-1_item-1'); + const [activeGroup, setActiveGroup] = useState('nav-expand3rd-group-1'); + const [activeItem, setActiveItem] = useState('nav-expand3rd-group-1_item-1'); const onSelect = ( _event: React.FormEvent, diff --git a/packages/react-core/src/components/Nav/examples/NavFlyout.tsx b/packages/react-core/src/components/Nav/examples/NavFlyout.tsx index a0d42e028d7..27a5f1a9ec7 100644 --- a/packages/react-core/src/components/Nav/examples/NavFlyout.tsx +++ b/packages/react-core/src/components/Nav/examples/NavFlyout.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Nav, NavItem, NavList, Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; export const NavFlyout: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState('nav-flyout-default-link-1'); + const [activeItem, setActiveItem] = useState('nav-flyout-default-link-1'); const onSelect = (event: React.FormEvent, result: { itemId: number | string }) => { setActiveItem(result.itemId as string); diff --git a/packages/react-core/src/components/Nav/examples/NavGrouped.tsx b/packages/react-core/src/components/Nav/examples/NavGrouped.tsx index e6288c70a61..e13dd402471 100644 --- a/packages/react-core/src/components/Nav/examples/NavGrouped.tsx +++ b/packages/react-core/src/components/Nav/examples/NavGrouped.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Nav, NavItem, NavGroup } from '@patternfly/react-core'; export const NavGrouped: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState('group-1_item-1'); + const [activeItem, setActiveItem] = useState('group-1_item-1'); const onSelect = (_event: React.FormEvent, result: { itemId: number | string }) => { setActiveItem(result.itemId as string); diff --git a/packages/react-core/src/components/Nav/examples/NavHorizontalNav.tsx b/packages/react-core/src/components/Nav/examples/NavHorizontalNav.tsx index 3ed10875e86..e998f9332ea 100644 --- a/packages/react-core/src/components/Nav/examples/NavHorizontalNav.tsx +++ b/packages/react-core/src/components/Nav/examples/NavHorizontalNav.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Nav, NavItem, NavList } from '@patternfly/react-core'; export const NavHorizontalNav: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.FormEvent, result: { itemId: number | string }) => { setActiveItem(result.itemId as number); diff --git a/packages/react-core/src/components/Nav/examples/NavHorizontalSubNav.tsx b/packages/react-core/src/components/Nav/examples/NavHorizontalSubNav.tsx index 85f0c8726a7..5eb4823580e 100644 --- a/packages/react-core/src/components/Nav/examples/NavHorizontalSubNav.tsx +++ b/packages/react-core/src/components/Nav/examples/NavHorizontalSubNav.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Nav, NavItem, NavList } from '@patternfly/react-core'; export const NavHorizontalSubNav: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.FormEvent, result: { itemId: number | string }) => { setActiveItem(result.itemId as number); diff --git a/packages/react-core/src/components/Nav/examples/NavIcons.tsx b/packages/react-core/src/components/Nav/examples/NavIcons.tsx index 8650cf9a922..47e7cbf4098 100644 --- a/packages/react-core/src/components/Nav/examples/NavIcons.tsx +++ b/packages/react-core/src/components/Nav/examples/NavIcons.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Nav, NavItem, NavList } from '@patternfly/react-core'; import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; import FolderIcon from '@patternfly/react-icons/dist/esm/icons/folder-icon'; @@ -5,7 +6,7 @@ import CloudIcon from '@patternfly/react-icons/dist/esm/icons/cloud-icon'; import LinkIcon from '@patternfly/react-icons/dist/esm/icons/link-icon'; export const NavIcons: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = (_event: React.FormEvent, result: { itemId: number | string }) => { setActiveItem(result.itemId as number); diff --git a/packages/react-core/src/components/Nav/examples/NavMixed.tsx b/packages/react-core/src/components/Nav/examples/NavMixed.tsx index a53de216055..c867d0a4cd9 100644 --- a/packages/react-core/src/components/Nav/examples/NavMixed.tsx +++ b/packages/react-core/src/components/Nav/examples/NavMixed.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Nav, NavExpandable, NavItem, NavItemSeparator, NavList } from '@patternfly/react-core'; export const NavMixed: React.FunctionComponent = () => { - const [activeGroup, setActiveGroup] = React.useState(''); - const [activeItem, setActiveItem] = React.useState('ungrouped_item-1'); + const [activeGroup, setActiveGroup] = useState(''); + const [activeItem, setActiveItem] = useState('ungrouped_item-1'); const onSelect = ( _event: React.FormEvent, diff --git a/packages/react-core/src/components/NotificationBadge/examples/NotificationBadge.md b/packages/react-core/src/components/NotificationBadge/examples/NotificationBadge.md index b6fa9eb01b6..4d0d3b7a662 100644 --- a/packages/react-core/src/components/NotificationBadge/examples/NotificationBadge.md +++ b/packages/react-core/src/components/NotificationBadge/examples/NotificationBadge.md @@ -5,6 +5,7 @@ cssPrefix: pf-v6-c-notification-badge propComponents: ['NotificationBadge'] --- +import { useState } from 'react'; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; ## Examples diff --git a/packages/react-core/src/components/NotificationBadge/examples/NotificationBadgeBasic.tsx b/packages/react-core/src/components/NotificationBadge/examples/NotificationBadgeBasic.tsx index 24a86c1b1dd..29992671144 100644 --- a/packages/react-core/src/components/NotificationBadge/examples/NotificationBadgeBasic.tsx +++ b/packages/react-core/src/components/NotificationBadge/examples/NotificationBadgeBasic.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { NotificationBadge, NotificationBadgeVariant } from '@patternfly/react-core'; export const NotificationBadgeBasic: React.FunctionComponent = () => { - const [readExpanded, setReadExpanded] = React.useState(false); - const [unreadExpanded, setUnreadExpanded] = React.useState(false); - const [attentionExpanded, setAttentionExpanded] = React.useState(false); + const [readExpanded, setReadExpanded] = useState(false); + const [unreadExpanded, setUnreadExpanded] = useState(false); + const [attentionExpanded, setAttentionExpanded] = useState(false); const onReadClick = () => { setReadExpanded(!readExpanded); diff --git a/packages/react-core/src/components/NotificationBadge/examples/NotificationBadgeWithCount.tsx b/packages/react-core/src/components/NotificationBadge/examples/NotificationBadgeWithCount.tsx index 6fc325742eb..eea9b881358 100644 --- a/packages/react-core/src/components/NotificationBadge/examples/NotificationBadgeWithCount.tsx +++ b/packages/react-core/src/components/NotificationBadge/examples/NotificationBadgeWithCount.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { NotificationBadge, NotificationBadgeVariant } from '@patternfly/react-core'; export const NotificationBadgeWithCount: React.FunctionComponent = () => { - const [readExpanded, setReadExpanded] = React.useState(false); - const [unreadExpanded, setUnreadExpanded] = React.useState(false); - const [attentionExpanded, setAttentionExpanded] = React.useState(false); + const [readExpanded, setReadExpanded] = useState(false); + const [unreadExpanded, setUnreadExpanded] = useState(false); + const [attentionExpanded, setAttentionExpanded] = useState(false); const onReadClick = () => { setReadExpanded(!readExpanded); diff --git a/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawer.md b/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawer.md index 9b8d1c1797c..c437ed981ce 100644 --- a/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawer.md +++ b/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawer.md @@ -16,6 +16,7 @@ propComponents: ] --- +import { useState } from 'react'; import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; diff --git a/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerBasic.tsx b/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerBasic.tsx index 778f977b477..90c4a1d907b 100644 --- a/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerBasic.tsx +++ b/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerBasic.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { NotificationDrawer, NotificationDrawerBody, @@ -15,7 +16,7 @@ import { import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const NotificationDrawerBasic: React.FunctionComponent = () => { - const [isOpenMap, setIsOpenMap] = React.useState(new Array(7).fill(false)); + const [isOpenMap, setIsOpenMap] = useState(new Array(7).fill(false)); const onToggle = (index: number) => () => { const newState = [...isOpenMap.slice(0, index), !isOpenMap[index], ...isOpenMap.slice(index + 1)]; diff --git a/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerGroups.tsx b/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerGroups.tsx index b3c05e21b35..5c857d7cf2d 100644 --- a/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerGroups.tsx +++ b/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerGroups.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Button, EmptyState, @@ -24,10 +25,10 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; export const NotificationDrawerGroups: React.FunctionComponent = () => { - const [firstGroupExpanded, setFirstGroupExpanded] = React.useState(false); - const [secondGroupExpanded, setSecondGroupExpanded] = React.useState(true); - const [thirdGroupExpanded, setThirdGroupExpanded] = React.useState(false); - const [isOpenMap, setIsOpenMap] = React.useState({}); + const [firstGroupExpanded, setFirstGroupExpanded] = useState(false); + const [secondGroupExpanded, setSecondGroupExpanded] = useState(true); + const [thirdGroupExpanded, setThirdGroupExpanded] = useState(false); + const [isOpenMap, setIsOpenMap] = useState({}); const onToggle = (id: string) => { setIsOpenMap((prevState) => ({ ...prevState, [id]: !prevState[id] })); diff --git a/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerLightweight.tsx b/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerLightweight.tsx index 5d28f124e69..ebb1d9da483 100644 --- a/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerLightweight.tsx +++ b/packages/react-core/src/components/NotificationDrawer/examples/NotificationDrawerLightweight.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Button, EmptyState, @@ -18,9 +19,9 @@ import { import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; export const NotificationDrawerLightweight: React.FunctionComponent = () => { - const [firstGroupExpanded, setFirstGroupExpanded] = React.useState(false); - const [secondGroupExpanded, setSecondGroupExpanded] = React.useState(true); - const [thirdGroupExpanded, setThirdGroupExpanded] = React.useState(false); + const [firstGroupExpanded, setFirstGroupExpanded] = useState(false); + const [secondGroupExpanded, setSecondGroupExpanded] = useState(true); + const [thirdGroupExpanded, setThirdGroupExpanded] = useState(false); const toggleFirstDrawer = (_event: any, value: boolean) => { setFirstGroupExpanded(value); diff --git a/packages/react-core/src/components/NumberInput/examples/NumberInput.md b/packages/react-core/src/components/NumberInput/examples/NumberInput.md index aae81092837..c2336cc9481 100644 --- a/packages/react-core/src/components/NumberInput/examples/NumberInput.md +++ b/packages/react-core/src/components/NumberInput/examples/NumberInput.md @@ -5,7 +5,7 @@ cssPrefix: pf-v6-c-number-input propComponents: ['NumberInput'] --- -import { Fragment } from 'react'; +import { Fragment, useReducer, useState } from 'react'; ## Examples diff --git a/packages/react-core/src/components/NumberInput/examples/NumberInputCustomStep.tsx b/packages/react-core/src/components/NumberInput/examples/NumberInputCustomStep.tsx index 1fee41baee3..8c2810c6895 100644 --- a/packages/react-core/src/components/NumberInput/examples/NumberInputCustomStep.tsx +++ b/packages/react-core/src/components/NumberInput/examples/NumberInputCustomStep.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { NumberInput } from '@patternfly/react-core'; export const NumberInputCustomStep: React.FunctionComponent = () => { - const [value, setValue] = React.useState(90); + const [value, setValue] = useState(90); const step = 3; const stepper = (stepValue: number) => { diff --git a/packages/react-core/src/components/NumberInput/examples/NumberInputCustomStepAndThreshold.tsx b/packages/react-core/src/components/NumberInput/examples/NumberInputCustomStepAndThreshold.tsx index 09f79ff90e5..311e21ee7fa 100644 --- a/packages/react-core/src/components/NumberInput/examples/NumberInputCustomStepAndThreshold.tsx +++ b/packages/react-core/src/components/NumberInput/examples/NumberInputCustomStepAndThreshold.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { NumberInput } from '@patternfly/react-core'; export const NumberInputCustomStepAndThreshold: React.FunctionComponent = () => { - const [value, setValue] = React.useState(90); + const [value, setValue] = useState(90); const minValue = 90; const maxValue = 100; const step = 3; diff --git a/packages/react-core/src/components/NumberInput/examples/NumberInputDefault.tsx b/packages/react-core/src/components/NumberInput/examples/NumberInputDefault.tsx index b4581a34533..3d8aa925f3e 100644 --- a/packages/react-core/src/components/NumberInput/examples/NumberInputDefault.tsx +++ b/packages/react-core/src/components/NumberInput/examples/NumberInputDefault.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { NumberInput } from '@patternfly/react-core'; export const NumberInputDefault: React.FunctionComponent = () => { - const [value, setValue] = React.useState(90); + const [value, setValue] = useState(90); const onMinus = () => { const newValue = (value || 0) - 1; diff --git a/packages/react-core/src/components/NumberInput/examples/NumberInputDisabled.tsx b/packages/react-core/src/components/NumberInput/examples/NumberInputDisabled.tsx index 92f56e999c8..cdf7d216f50 100644 --- a/packages/react-core/src/components/NumberInput/examples/NumberInputDisabled.tsx +++ b/packages/react-core/src/components/NumberInput/examples/NumberInputDisabled.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { NumberInput } from '@patternfly/react-core'; export const NumberInputDisabled: React.FunctionComponent = () => { - const [value, setValue] = React.useState(100); + const [value, setValue] = useState(100); const minValue = 0; const maxValue = 100; diff --git a/packages/react-core/src/components/NumberInput/examples/NumberInputUnit.tsx b/packages/react-core/src/components/NumberInput/examples/NumberInputUnit.tsx index 18c9ae808cb..888cde28ffb 100644 --- a/packages/react-core/src/components/NumberInput/examples/NumberInputUnit.tsx +++ b/packages/react-core/src/components/NumberInput/examples/NumberInputUnit.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { NumberInput } from '@patternfly/react-core'; export const NumberInputUnit: React.FunctionComponent = () => { - const [value1, setValue1] = React.useState(90); - const [value2, setValue2] = React.useState(Number((1.0).toFixed(2))); + const [value1, setValue1] = useState(90); + const [value2, setValue2] = useState(Number((1.0).toFixed(2))); const onMinus1 = () => setValue1((value1 || 0) - 1); const onChange1 = (event: React.FormEvent) => { diff --git a/packages/react-core/src/components/NumberInput/examples/NumberInputUnitThreshold.tsx b/packages/react-core/src/components/NumberInput/examples/NumberInputUnitThreshold.tsx index c52cef28436..8341c9d8dc1 100644 --- a/packages/react-core/src/components/NumberInput/examples/NumberInputUnitThreshold.tsx +++ b/packages/react-core/src/components/NumberInput/examples/NumberInputUnitThreshold.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { NumberInput } from '@patternfly/react-core'; export const NumberInputUnitThreshold: React.FunctionComponent = () => { - const [value, setValue] = React.useState(0); + const [value, setValue] = useState(0); const minValue = 0; const maxValue = 10; diff --git a/packages/react-core/src/components/NumberInput/examples/NumberInputVaryingSizes.tsx b/packages/react-core/src/components/NumberInput/examples/NumberInputVaryingSizes.tsx index e06ba3c14bc..5735a850ff8 100644 --- a/packages/react-core/src/components/NumberInput/examples/NumberInputVaryingSizes.tsx +++ b/packages/react-core/src/components/NumberInput/examples/NumberInputVaryingSizes.tsx @@ -1,11 +1,11 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { NumberInput } from '@patternfly/react-core'; export const NumberInputVaryingSizes: React.FunctionComponent = () => { - const [input1Value, setInput1Value] = React.useState(1); - const [input2Value, setInput2Value] = React.useState(1234567890); - const [input3Value, setInput3Value] = React.useState(5); - const [input4Value, setInput4Value] = React.useState(12345); + const [input1Value, setInput1Value] = useState(1); + const [input2Value, setInput2Value] = useState(1234567890); + const [input3Value, setInput3Value] = useState(5); + const [input4Value, setInput4Value] = useState(12345); const onChange = ( event: React.FormEvent, diff --git a/packages/react-core/src/components/NumberInput/examples/NumberInputWithStatus.tsx b/packages/react-core/src/components/NumberInput/examples/NumberInputWithStatus.tsx index 95a9c18e942..bbf2b9eb7a5 100644 --- a/packages/react-core/src/components/NumberInput/examples/NumberInputWithStatus.tsx +++ b/packages/react-core/src/components/NumberInput/examples/NumberInputWithStatus.tsx @@ -1,11 +1,12 @@ +import { useReducer, useState } from 'react'; import { NumberInput, ValidatedOptions } from '@patternfly/react-core'; export const NumberInputWithStatus: React.FunctionComponent = () => { const max = 10; const min = 0; - const [validated, setValidated] = React.useState(ValidatedOptions.success); - const [value, setValue] = React.useReducer((state, newVal) => Math.max(min, Math.min(max, Number(newVal))), 5); + const [validated, setValidated] = useState(ValidatedOptions.success); + const [value, setValue] = useReducer((state, newVal) => Math.max(min, Math.min(max, Number(newVal))), 5); const onPlus = () => { const newVal = (value || 0) + 1; diff --git a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenu.md b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenu.md index 06ad970c385..e73498c856d 100644 --- a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenu.md +++ b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenu.md @@ -13,6 +13,7 @@ propComponents: ] --- +import { useRef, useState } from 'react'; import AlignLeftIcon from '@patternfly/react-icons/dist/esm/icons/align-left-icon'; import AlignCenterIcon from '@patternfly/react-icons/dist/esm/icons/align-center-icon'; import AlignRightIcon from '@patternfly/react-icons/dist/esm/icons/align-right-icon'; diff --git a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuBreakpointOnContainer.tsx b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuBreakpointOnContainer.tsx index bf7da51a3fc..e124e07a507 100644 --- a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuBreakpointOnContainer.tsx +++ b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuBreakpointOnContainer.tsx @@ -1,3 +1,4 @@ +import { useRef, useState } from 'react'; import { OverflowMenu, OverflowMenuControl, @@ -14,9 +15,9 @@ import { import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const OverflowMenuBreakpointOnContainer: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [containerWidth, setContainerWidth] = React.useState(100); - const containerRef = React.useRef(null); + const [isOpen, setIsOpen] = useState(false); + const [containerWidth, setContainerWidth] = useState(100); + const containerRef = useRef(null); const onToggle = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuGroupTypes.tsx b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuGroupTypes.tsx index 146fd403b0a..4b2b93c271a 100644 --- a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuGroupTypes.tsx +++ b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuGroupTypes.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { OverflowMenu, OverflowMenuControl, @@ -17,7 +18,7 @@ import AlignCenterIcon from '@patternfly/react-icons/dist/esm/icons/align-center import AlignRightIcon from '@patternfly/react-icons/dist/esm/icons/align-right-icon'; export const OverflowMenuGroupTypes: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggle = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuMultiGroup.tsx b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuMultiGroup.tsx index 7af612a39db..0484322ebfa 100644 --- a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuMultiGroup.tsx +++ b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuMultiGroup.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { OverflowMenu, OverflowMenuControl, @@ -17,7 +18,7 @@ import AlignCenterIcon from '@patternfly/react-icons/dist/esm/icons/align-center import AlignRightIcon from '@patternfly/react-icons/dist/esm/icons/align-right-icon'; export const OverflowMenuMultiGroup: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggle = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuPersistent.tsx b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuPersistent.tsx index 734ba6b8d0e..508b9dccc7b 100644 --- a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuPersistent.tsx +++ b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuPersistent.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { OverflowMenu, OverflowMenuControl, @@ -14,7 +15,7 @@ import { import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const OverflowMenuPersistent: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggle = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuSimple.tsx b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuSimple.tsx index 92069de66eb..25998691118 100644 --- a/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuSimple.tsx +++ b/packages/react-core/src/components/OverflowMenu/examples/OverflowMenuSimple.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { OverflowMenu, OverflowMenuControl, @@ -12,7 +13,7 @@ import { import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; export const OverflowMenuBreakpointOnContainer: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); const onToggle = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Page/Page.tsx b/packages/react-core/src/components/Page/Page.tsx index 31bed9618e7..00fb8080b65 100644 --- a/packages/react-core/src/components/Page/Page.tsx +++ b/packages/react-core/src/components/Page/Page.tsx @@ -1,4 +1,4 @@ -import { Component, createRef, type JSX } from 'react'; +import { Component, createRef } from 'react'; import styles from '@patternfly/react-styles/css/components/Page/page'; import { css } from '@patternfly/react-styles'; import globalBreakpointXl from '@patternfly/react-tokens/dist/esm/t_global_breakpoint_xl'; @@ -299,7 +299,7 @@ class Page extends Component { ) : null; - const Component: keyof JSX.IntrinsicElements = mainComponent; + const Component: keyof React.JSX.IntrinsicElements = mainComponent; const main = (
diff --git a/packages/react-core/src/components/Page/PageSection.tsx b/packages/react-core/src/components/Page/PageSection.tsx index 774ba67a3c3..f1f829ac2da 100644 --- a/packages/react-core/src/components/Page/PageSection.tsx +++ b/packages/react-core/src/components/Page/PageSection.tsx @@ -1,4 +1,4 @@ -import { useContext, useEffect, type JSX } from 'react'; +import { useContext, useEffect } from 'react'; import styles from '@patternfly/react-styles/css/components/Page/page'; import { css } from '@patternfly/react-styles'; import { formatBreakpointMods } from '../../helpers/util'; @@ -66,7 +66,7 @@ export interface PageSectionProps extends React.HTMLProps { */ 'aria-label'?: string; /** Sets the base component to render. Defaults to section */ - component?: keyof JSX.IntrinsicElements; + component?: keyof React.JSX.IntrinsicElements; } const variantType = { diff --git a/packages/react-core/src/components/Page/examples/Page.md b/packages/react-core/src/components/Page/examples/Page.md index cf653fe4899..59f0f02fb7b 100644 --- a/packages/react-core/src/components/Page/examples/Page.md +++ b/packages/react-core/src/components/Page/examples/Page.md @@ -6,6 +6,7 @@ propComponents: ['Page', 'PageSidebar', 'PageSidebarBody', 'PageSection', 'PageGroup', 'PageBreadcrumb', 'PageToggleButton'] --- +import { useState } from 'react'; import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon'; import c_page_section_m_limit_width_MaxWidth from '@patternfly/react-tokens/dist/esm/c_page_section_m_limit_width_MaxWidth'; diff --git a/packages/react-core/src/components/Page/examples/PageCenteredSection.tsx b/packages/react-core/src/components/Page/examples/PageCenteredSection.tsx index f7cd297809d..b475f1da08d 100644 --- a/packages/react-core/src/components/Page/examples/PageCenteredSection.tsx +++ b/packages/react-core/src/components/Page/examples/PageCenteredSection.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Page, Masthead, @@ -21,7 +22,7 @@ import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; import c_page_section_m_limit_width_MaxWidth from '@patternfly/react-tokens/dist/esm/c_page_section_m_limit_width_MaxWidth'; export const PageCenteredSection: React.FunctionComponent = () => { - const [isSidebarOpen, setIsSidebarOpen] = React.useState(true); + const [isSidebarOpen, setIsSidebarOpen] = useState(true); const onSidebarToggle = () => { setIsSidebarOpen(!isSidebarOpen); diff --git a/packages/react-core/src/components/Page/examples/PageGroupSection.tsx b/packages/react-core/src/components/Page/examples/PageGroupSection.tsx index fea37838ef4..4c113527085 100644 --- a/packages/react-core/src/components/Page/examples/PageGroupSection.tsx +++ b/packages/react-core/src/components/Page/examples/PageGroupSection.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Page, Masthead, @@ -24,7 +25,7 @@ import { import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; export const PageGroupSection: React.FunctionComponent = () => { - const [isSidebarOpen, setIsSidebarOpen] = React.useState(true); + const [isSidebarOpen, setIsSidebarOpen] = useState(true); const onSidebarToggle = () => { setIsSidebarOpen(!isSidebarOpen); diff --git a/packages/react-core/src/components/Page/examples/PageMainSectionPadding.tsx b/packages/react-core/src/components/Page/examples/PageMainSectionPadding.tsx index 8e88b709566..96eabf69958 100644 --- a/packages/react-core/src/components/Page/examples/PageMainSectionPadding.tsx +++ b/packages/react-core/src/components/Page/examples/PageMainSectionPadding.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Page, Masthead, @@ -17,7 +18,7 @@ import { import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; export const PageMainSectionPadding: React.FunctionComponent = () => { - const [isSidebarOpen, setIsSidebarOpen] = React.useState(true); + const [isSidebarOpen, setIsSidebarOpen] = useState(true); const onSidebarToggle = () => { setIsSidebarOpen(!isSidebarOpen); diff --git a/packages/react-core/src/components/Page/examples/PageMainSectionVariations.tsx b/packages/react-core/src/components/Page/examples/PageMainSectionVariations.tsx index 6e7713c6e64..a510177e9d3 100644 --- a/packages/react-core/src/components/Page/examples/PageMainSectionVariations.tsx +++ b/packages/react-core/src/components/Page/examples/PageMainSectionVariations.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Page, Masthead, @@ -17,7 +18,7 @@ import { import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; export const PageMainSectionPadding: React.FunctionComponent = () => { - const [isSidebarOpen, setIsSidebarOpen] = React.useState(true); + const [isSidebarOpen, setIsSidebarOpen] = useState(true); const onSidebarToggle = () => { setIsSidebarOpen(!isSidebarOpen); diff --git a/packages/react-core/src/components/Page/examples/PageMultipleSidebarBody.tsx b/packages/react-core/src/components/Page/examples/PageMultipleSidebarBody.tsx index ac4135dd7c8..9b4943792bb 100644 --- a/packages/react-core/src/components/Page/examples/PageMultipleSidebarBody.tsx +++ b/packages/react-core/src/components/Page/examples/PageMultipleSidebarBody.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Page, Masthead, @@ -17,7 +18,7 @@ import { import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; export const PageMultipleSidebarBody: React.FunctionComponent = () => { - const [isSidebarOpen, setIsSidebarOpen] = React.useState(true); + const [isSidebarOpen, setIsSidebarOpen] = useState(true); const onSidebarToggle = () => { setIsSidebarOpen(!isSidebarOpen); diff --git a/packages/react-core/src/components/Page/examples/PageVerticalNav.tsx b/packages/react-core/src/components/Page/examples/PageVerticalNav.tsx index 299d572b90e..f14baa5cc15 100644 --- a/packages/react-core/src/components/Page/examples/PageVerticalNav.tsx +++ b/packages/react-core/src/components/Page/examples/PageVerticalNav.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Page, Masthead, @@ -17,7 +18,7 @@ import { import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; export const PageVerticalNav: React.FunctionComponent = () => { - const [isSidebarOpen, setIsSidebarOpen] = React.useState(true); + const [isSidebarOpen, setIsSidebarOpen] = useState(true); const onSidebarToggle = () => { setIsSidebarOpen(!isSidebarOpen); diff --git a/packages/react-core/src/components/Page/examples/PageWithOrWithoutFill.tsx b/packages/react-core/src/components/Page/examples/PageWithOrWithoutFill.tsx index 21927ad8bfb..10286dc1fc5 100644 --- a/packages/react-core/src/components/Page/examples/PageWithOrWithoutFill.tsx +++ b/packages/react-core/src/components/Page/examples/PageWithOrWithoutFill.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Page, Masthead, @@ -17,7 +18,7 @@ import { import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; export const PageWithOrWithoutFill: React.FunctionComponent = () => { - const [isSidebarOpen, setIsSidebarOpen] = React.useState(true); + const [isSidebarOpen, setIsSidebarOpen] = useState(true); const onSidebarToggle = () => { setIsSidebarOpen(!isSidebarOpen); diff --git a/packages/react-core/src/components/Pagination/examples/Pagination.md b/packages/react-core/src/components/Pagination/examples/Pagination.md index 2ba27a5a928..569167327a9 100644 --- a/packages/react-core/src/components/Pagination/examples/Pagination.md +++ b/packages/react-core/src/components/Pagination/examples/Pagination.md @@ -6,7 +6,7 @@ propComponents: ['Pagination', PaginationTitles, PerPageOptions, PaginationToggl ouia: true --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; ## Examples diff --git a/packages/react-core/src/components/Pagination/examples/PaginationBottom.tsx b/packages/react-core/src/components/Pagination/examples/PaginationBottom.tsx index eed56b6cf43..de343bfb221 100644 --- a/packages/react-core/src/components/Pagination/examples/PaginationBottom.tsx +++ b/packages/react-core/src/components/Pagination/examples/PaginationBottom.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Pagination, PaginationVariant } from '@patternfly/react-core'; export const PaginationBottom: React.FunctionComponent = () => { - const [page, setPage] = React.useState(1); - const [perPage, setPerPage] = React.useState(10); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(10); const onSetPage = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => { setPage(newPage); diff --git a/packages/react-core/src/components/Pagination/examples/PaginationCompact.tsx b/packages/react-core/src/components/Pagination/examples/PaginationCompact.tsx index afa53d3b0a6..d59928fbae0 100644 --- a/packages/react-core/src/components/Pagination/examples/PaginationCompact.tsx +++ b/packages/react-core/src/components/Pagination/examples/PaginationCompact.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Pagination } from '@patternfly/react-core'; export const PaginationCompact: React.FunctionComponent = () => { - const [page, setPage] = React.useState(1); - const [perPage, setPerPage] = React.useState(20); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(20); const onSetPage = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => { setPage(newPage); diff --git a/packages/react-core/src/components/Pagination/examples/PaginationDisabled.tsx b/packages/react-core/src/components/Pagination/examples/PaginationDisabled.tsx index 61abb5a270c..27d120356a5 100644 --- a/packages/react-core/src/components/Pagination/examples/PaginationDisabled.tsx +++ b/packages/react-core/src/components/Pagination/examples/PaginationDisabled.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Pagination } from '@patternfly/react-core'; export const PaginationDisabled: React.FunctionComponent = () => { - const [page, setPage] = React.useState(1); - const [perPage, setPerPage] = React.useState(20); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(20); const onSetPage = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => { setPage(newPage); diff --git a/packages/react-core/src/components/Pagination/examples/PaginationIndeterminate.tsx b/packages/react-core/src/components/Pagination/examples/PaginationIndeterminate.tsx index 584b91198ef..957321f57fc 100644 --- a/packages/react-core/src/components/Pagination/examples/PaginationIndeterminate.tsx +++ b/packages/react-core/src/components/Pagination/examples/PaginationIndeterminate.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Pagination } from '@patternfly/react-core'; export const PaginationIndeterminate: React.FunctionComponent = () => { - const [page, setPage] = React.useState(1); - const [perPage, setPerPage] = React.useState(20); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(20); const onSetPage = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => { setPage(newPage); diff --git a/packages/react-core/src/components/Pagination/examples/PaginationInset.tsx b/packages/react-core/src/components/Pagination/examples/PaginationInset.tsx index 44bcc59ab76..e9f281b9c25 100644 --- a/packages/react-core/src/components/Pagination/examples/PaginationInset.tsx +++ b/packages/react-core/src/components/Pagination/examples/PaginationInset.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Pagination } from '@patternfly/react-core'; export const PaginationInset: React.FunctionComponent = () => { - const [page, setPage] = React.useState(1); - const [perPage, setPerPage] = React.useState(20); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(20); const onSetPage = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => { setPage(newPage); diff --git a/packages/react-core/src/components/Pagination/examples/PaginationNoItems.tsx b/packages/react-core/src/components/Pagination/examples/PaginationNoItems.tsx index f9d9a1b2ee2..9b1619c4cf2 100644 --- a/packages/react-core/src/components/Pagination/examples/PaginationNoItems.tsx +++ b/packages/react-core/src/components/Pagination/examples/PaginationNoItems.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Pagination } from '@patternfly/react-core'; export const PaginationNoItems: React.FunctionComponent = () => { - const [page, setPage] = React.useState(1); - const [perPage, setPerPage] = React.useState(20); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(20); const onSetPage = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => { setPage(newPage); diff --git a/packages/react-core/src/components/Pagination/examples/PaginationOffset.tsx b/packages/react-core/src/components/Pagination/examples/PaginationOffset.tsx index a22d8841312..fa2548a091e 100644 --- a/packages/react-core/src/components/Pagination/examples/PaginationOffset.tsx +++ b/packages/react-core/src/components/Pagination/examples/PaginationOffset.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Pagination } from '@patternfly/react-core'; export const PaginationOffset: React.FunctionComponent = () => { - const [offset, setOffset] = React.useState(7); - const [perPage, setPerPage] = React.useState(20); + const [offset, setOffset] = useState(7); + const [perPage, setPerPage] = useState(20); const onSetPage = ( _event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Pagination/examples/PaginationOnePage.tsx b/packages/react-core/src/components/Pagination/examples/PaginationOnePage.tsx index 7a3cefda36f..ce396b01ba4 100644 --- a/packages/react-core/src/components/Pagination/examples/PaginationOnePage.tsx +++ b/packages/react-core/src/components/Pagination/examples/PaginationOnePage.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Pagination } from '@patternfly/react-core'; export const PaginationOnePage: React.FunctionComponent = () => { - const [page, setPage] = React.useState(1); - const [perPage, setPerPage] = React.useState(20); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(20); const onSetPage = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => { setPage(newPage); diff --git a/packages/react-core/src/components/Pagination/examples/PaginationSticky.tsx b/packages/react-core/src/components/Pagination/examples/PaginationSticky.tsx index 6d31193a90c..f68868a9aae 100644 --- a/packages/react-core/src/components/Pagination/examples/PaginationSticky.tsx +++ b/packages/react-core/src/components/Pagination/examples/PaginationSticky.tsx @@ -1,10 +1,10 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Pagination, PaginationVariant, Gallery, GalleryItem, Card, CardBody } from '@patternfly/react-core'; export const PaginationSticky: React.FunctionComponent = () => { - const [page, setPage] = React.useState(1); - const [perPage, setPerPage] = React.useState(100); - const [isTopSticky, setIsTopSticky] = React.useState(true); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(100); + const [isTopSticky, setIsTopSticky] = useState(true); const itemCount = 523; const onToggleSticky = () => { diff --git a/packages/react-core/src/components/Pagination/examples/PaginationTop.tsx b/packages/react-core/src/components/Pagination/examples/PaginationTop.tsx index b03bc13fdb8..3bd8ccb4bec 100644 --- a/packages/react-core/src/components/Pagination/examples/PaginationTop.tsx +++ b/packages/react-core/src/components/Pagination/examples/PaginationTop.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Pagination } from '@patternfly/react-core'; export const PaginationTop: React.FunctionComponent = () => { - const [page, setPage] = React.useState(1); - const [perPage, setPerPage] = React.useState(20); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(20); const onSetPage = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => { setPage(newPage); diff --git a/packages/react-core/src/components/Popover/examples/Popover.md b/packages/react-core/src/components/Popover/examples/Popover.md index 0c5655987e8..2ccaa9d00ee 100644 --- a/packages/react-core/src/components/Popover/examples/Popover.md +++ b/packages/react-core/src/components/Popover/examples/Popover.md @@ -5,6 +5,7 @@ cssPrefix: pf-v6-c-popover propComponents: ['Popover'] --- +import { useRef, useState } from 'react'; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; diff --git a/packages/react-core/src/components/Popover/examples/PopoverAdvanced.tsx b/packages/react-core/src/components/Popover/examples/PopoverAdvanced.tsx index 5ebed4efc3a..9c856fce8c2 100644 --- a/packages/react-core/src/components/Popover/examples/PopoverAdvanced.tsx +++ b/packages/react-core/src/components/Popover/examples/PopoverAdvanced.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { Popover, PopoverPosition, Checkbox, Button } from '@patternfly/react-core'; export const PopoverAdvanced: React.FunctionComponent = () => { - const [position, setPosition] = React.useState(PopoverPosition.auto); - const [show, setShow] = React.useState(false); - const [keepInViewChecked, setKeepInViewChecked] = React.useState(true); + const [position, setPosition] = useState(PopoverPosition.auto); + const [show, setShow] = useState(false); + const [keepInViewChecked, setKeepInViewChecked] = useState(true); const handleKeepInViewChange = (checked: boolean) => { setKeepInViewChecked(checked); diff --git a/packages/react-core/src/components/Popover/examples/PopoverAlert.tsx b/packages/react-core/src/components/Popover/examples/PopoverAlert.tsx index de2bccb8ef3..bd1bdab2851 100644 --- a/packages/react-core/src/components/Popover/examples/PopoverAlert.tsx +++ b/packages/react-core/src/components/Popover/examples/PopoverAlert.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Popover, Button } from '@patternfly/react-core'; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; @@ -6,7 +7,7 @@ import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/excl import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon'; export const AlertPopover: React.FunctionComponent = () => { - const [alertSeverityVariant, setAlertSeverityVariant] = React.useState('default'); + const [alertSeverityVariant, setAlertSeverityVariant] = useState('default'); const alertIcons = { custom: , diff --git a/packages/react-core/src/components/Popover/examples/PopoverCloseControlled.tsx b/packages/react-core/src/components/Popover/examples/PopoverCloseControlled.tsx index 8ea7d0d0572..403bb3bee50 100644 --- a/packages/react-core/src/components/Popover/examples/PopoverCloseControlled.tsx +++ b/packages/react-core/src/components/Popover/examples/PopoverCloseControlled.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Popover, Button } from '@patternfly/react-core'; export const PopoverCloseControlled: React.FunctionComponent = () => { - const [isVisible, setIsVisible] = React.useState(false); + const [isVisible, setIsVisible] = useState(false); return (
diff --git a/packages/react-core/src/components/Popover/examples/PopoverReactRef.tsx b/packages/react-core/src/components/Popover/examples/PopoverReactRef.tsx index f800a87c968..923c355a8f6 100644 --- a/packages/react-core/src/components/Popover/examples/PopoverReactRef.tsx +++ b/packages/react-core/src/components/Popover/examples/PopoverReactRef.tsx @@ -1,7 +1,8 @@ +import { useRef } from 'react'; import { Popover } from '@patternfly/react-core'; export const PopoverReactRef: React.FunctionComponent = () => { - const popoverRef = React.useRef(null); + const popoverRef = useRef(null); return (
diff --git a/packages/react-core/src/components/Progress/examples/Progress.md b/packages/react-core/src/components/Progress/examples/Progress.md index 9289969c41b..6e4ddd905bb 100644 --- a/packages/react-core/src/components/Progress/examples/Progress.md +++ b/packages/react-core/src/components/Progress/examples/Progress.md @@ -5,6 +5,8 @@ cssPrefix: pf-v6-c-progress propComponents: ['Progress'] --- +import { useState } from 'react'; + ## Examples ### Basic ```ts file="./ProgressBasic.tsx" diff --git a/packages/react-core/src/components/Progress/examples/ProgressHelperText.tsx b/packages/react-core/src/components/Progress/examples/ProgressHelperText.tsx index 13c2255b8c6..98974b11d50 100644 --- a/packages/react-core/src/components/Progress/examples/ProgressHelperText.tsx +++ b/packages/react-core/src/components/Progress/examples/ProgressHelperText.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { Progress, ProgressProps, HelperText, HelperTextItem, Radio } from '@patternfly/react-core'; export const ProgressHelperText: React.FunctionComponent = () => { type ProgressVariant = ProgressProps['variant']; - const [selectedVariant, setSelectedVariant] = React.useState(undefined); + const [selectedVariant, setSelectedVariant] = useState(undefined); const progressVariants: ProgressVariant[] = [undefined, 'success', 'warning', 'danger']; diff --git a/packages/react-core/src/components/ProgressStepper/examples/ProgressStepper.md b/packages/react-core/src/components/ProgressStepper/examples/ProgressStepper.md index ac021e6ee42..7d5c3500fb0 100644 --- a/packages/react-core/src/components/ProgressStepper/examples/ProgressStepper.md +++ b/packages/react-core/src/components/ProgressStepper/examples/ProgressStepper.md @@ -5,7 +5,7 @@ cssPrefix: pf-v6-c-progress-stepper propComponents: ['ProgressStepper', 'ProgressStep'] --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import InProgressIcon from '@patternfly/react-icons/dist/esm/icons/in-progress-icon'; import PendingIcon from '@patternfly/react-icons/dist/esm/icons/pending-icon'; diff --git a/packages/react-core/src/components/ProgressStepper/examples/ProgressStepperBasicWithAlignment.tsx b/packages/react-core/src/components/ProgressStepper/examples/ProgressStepperBasicWithAlignment.tsx index bd1b04863a1..37ddee7736f 100644 --- a/packages/react-core/src/components/ProgressStepper/examples/ProgressStepperBasicWithAlignment.tsx +++ b/packages/react-core/src/components/ProgressStepper/examples/ProgressStepperBasicWithAlignment.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { ProgressStepper, ProgressStep, Checkbox } from '@patternfly/react-core'; export const ProgressStepperBasicWithAlignment: React.FunctionComponent = () => { - const [isVertical, setIsVertical] = React.useState(false); - const [isCenterAligned, setIsCenterAligned] = React.useState(false); + const [isVertical, setIsVertical] = useState(false); + const [isCenterAligned, setIsCenterAligned] = useState(false); return ( diff --git a/packages/react-core/src/components/ProgressStepper/examples/ProgressStepperCompact.tsx b/packages/react-core/src/components/ProgressStepper/examples/ProgressStepperCompact.tsx index 7f07918d82f..ce3c488f326 100644 --- a/packages/react-core/src/components/ProgressStepper/examples/ProgressStepperCompact.tsx +++ b/packages/react-core/src/components/ProgressStepper/examples/ProgressStepperCompact.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { ProgressStepper, ProgressStep, Checkbox } from '@patternfly/react-core'; export const ProgressStepperCompact: React.FunctionComponent = () => { - const [isVertical, setIsVertical] = React.useState(false); - const [isCenterAligned, setIsCenterAligned] = React.useState(false); + const [isVertical, setIsVertical] = useState(false); + const [isCenterAligned, setIsCenterAligned] = useState(false); return ( diff --git a/packages/react-core/src/components/Radio/examples/Radio.md b/packages/react-core/src/components/Radio/examples/Radio.md index 13e954222c8..89235b8cdcf 100644 --- a/packages/react-core/src/components/Radio/examples/Radio.md +++ b/packages/react-core/src/components/Radio/examples/Radio.md @@ -7,7 +7,7 @@ propComponents: ['Radio'] ouia: true --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; ## Examples diff --git a/packages/react-core/src/components/Radio/examples/RadioControlled.tsx b/packages/react-core/src/components/Radio/examples/RadioControlled.tsx index 12a66ad7739..75f2fd822c0 100644 --- a/packages/react-core/src/components/Radio/examples/RadioControlled.tsx +++ b/packages/react-core/src/components/Radio/examples/RadioControlled.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Radio } from '@patternfly/react-core'; export const RadioControlled: React.FunctionComponent = () => { - const [check1, setCheck1] = React.useState(false); + const [check1, setCheck1] = useState(false); const handleChange = () => { setCheck1(true); diff --git a/packages/react-core/src/components/SearchInput/examples/SearchInput.md b/packages/react-core/src/components/SearchInput/examples/SearchInput.md index 0fed2d947bb..0c855fde1f2 100644 --- a/packages/react-core/src/components/SearchInput/examples/SearchInput.md +++ b/packages/react-core/src/components/SearchInput/examples/SearchInput.md @@ -5,6 +5,7 @@ cssPrefix: 'pf-v6-c-search-input' propComponents: ['SearchInput', 'SearchInputSearchAttribute', 'SearchInputExpandable'] --- +import { useRef, useState } from 'react'; import { ExternalLinkSquareAltIcon } from '@patternfly/react-icons'; ## Examples diff --git a/packages/react-core/src/components/SearchInput/examples/SearchInputAdvanced.tsx b/packages/react-core/src/components/SearchInput/examples/SearchInputAdvanced.tsx index 1aa3fd6641d..194b4bc8f40 100644 --- a/packages/react-core/src/components/SearchInput/examples/SearchInputAdvanced.tsx +++ b/packages/react-core/src/components/SearchInput/examples/SearchInputAdvanced.tsx @@ -1,10 +1,11 @@ +import { useState } from 'react'; import { Button, Checkbox, FormGroup, SearchInput } from '@patternfly/react-core'; import ExternalLinkSquareAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-square-alt-icon'; export const SearchInputAdvanced: React.FunctionComponent = () => { - const [value, setValue] = React.useState('username:player firstname:john'); - const [useEqualsAsDelimiter, setUseEqualsAsDelimiter] = React.useState(false); - const [useCustomFooter, setUseCustomFooter] = React.useState(false); + const [value, setValue] = useState('username:player firstname:john'); + const [useEqualsAsDelimiter, setUseEqualsAsDelimiter] = useState(false); + const [useCustomFooter, setUseCustomFooter] = useState(false); const toggleDelimiter = (checked: boolean) => { setValue(value.replace(/:|=/g, checked ? '=' : ':')); diff --git a/packages/react-core/src/components/SearchInput/examples/SearchInputBasic.tsx b/packages/react-core/src/components/SearchInput/examples/SearchInputBasic.tsx index fff5d272e0b..acef1f03303 100644 --- a/packages/react-core/src/components/SearchInput/examples/SearchInputBasic.tsx +++ b/packages/react-core/src/components/SearchInput/examples/SearchInputBasic.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { SearchInput } from '@patternfly/react-core'; export const SearchInputBasic: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); + const [value, setValue] = useState(''); const onChange = (value: string) => { setValue(value); diff --git a/packages/react-core/src/components/SearchInput/examples/SearchInputFocusSearch.tsx b/packages/react-core/src/components/SearchInput/examples/SearchInputFocusSearch.tsx index 076eb4a067c..84b621b3e11 100644 --- a/packages/react-core/src/components/SearchInput/examples/SearchInputFocusSearch.tsx +++ b/packages/react-core/src/components/SearchInput/examples/SearchInputFocusSearch.tsx @@ -1,8 +1,9 @@ +import { useRef, useState } from 'react'; import { SearchInput, Button } from '@patternfly/react-core'; export const SearchInputFocusSearch: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); - const ref: React.MutableRefObject = React.useRef(null); + const [value, setValue] = useState(''); + const ref: React.MutableRefObject = useRef(null); return ( <> diff --git a/packages/react-core/src/components/SearchInput/examples/SearchInputWithExpandable.tsx b/packages/react-core/src/components/SearchInput/examples/SearchInputWithExpandable.tsx index cabb37f388f..315630d00a2 100644 --- a/packages/react-core/src/components/SearchInput/examples/SearchInputWithExpandable.tsx +++ b/packages/react-core/src/components/SearchInput/examples/SearchInputWithExpandable.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { SearchInput } from '@patternfly/react-core'; export const SearchInputWithExpandable: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); - const [isExpanded, setIsExpanded] = React.useState(false); + const [value, setValue] = useState(''); + const [isExpanded, setIsExpanded] = useState(false); const onChange = (value: string) => { setValue(value); diff --git a/packages/react-core/src/components/SearchInput/examples/SearchInputWithNavigableOptions.tsx b/packages/react-core/src/components/SearchInput/examples/SearchInputWithNavigableOptions.tsx index a8725e72cce..b768bca58ab 100644 --- a/packages/react-core/src/components/SearchInput/examples/SearchInputWithNavigableOptions.tsx +++ b/packages/react-core/src/components/SearchInput/examples/SearchInputWithNavigableOptions.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { SearchInput } from '@patternfly/react-core'; export const SearchInputWithNavigableOptions: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); - const [resultsCount, setResultsCount] = React.useState(0); - const [currentResult, setCurrentResult] = React.useState(1); + const [value, setValue] = useState(''); + const [resultsCount, setResultsCount] = useState(0); + const [currentResult, setCurrentResult] = useState(1); const onChange = (value: string) => { setValue(value); diff --git a/packages/react-core/src/components/SearchInput/examples/SearchInputWithResultCount.tsx b/packages/react-core/src/components/SearchInput/examples/SearchInputWithResultCount.tsx index 51e4c7f863b..5fe5f7a783e 100644 --- a/packages/react-core/src/components/SearchInput/examples/SearchInputWithResultCount.tsx +++ b/packages/react-core/src/components/SearchInput/examples/SearchInputWithResultCount.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { SearchInput } from '@patternfly/react-core'; export const SearchInputWithResultCount: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); - const [resultsCount, setResultsCount] = React.useState(0); + const [value, setValue] = useState(''); + const [resultsCount, setResultsCount] = useState(0); const onChange = (value: string) => { setValue(value); diff --git a/packages/react-core/src/components/SearchInput/examples/SearchInputWithSubmitButton.tsx b/packages/react-core/src/components/SearchInput/examples/SearchInputWithSubmitButton.tsx index 9f488b4a14e..9b9dd6bf011 100644 --- a/packages/react-core/src/components/SearchInput/examples/SearchInputWithSubmitButton.tsx +++ b/packages/react-core/src/components/SearchInput/examples/SearchInputWithSubmitButton.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { SearchInput } from '@patternfly/react-core'; export const SearchInputWithSubmitButton: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); + const [value, setValue] = useState(''); return ( { - const [isOpen, setIsOpen] = React.useState(false); - const [selected, setSelected] = React.useState('Select a value'); - const [isDisabled, setIsDisabled] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); + const [selected, setSelected] = useState('Select a value'); + const [isDisabled, setIsDisabled] = useState(false); const onToggleClick = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Select/examples/SelectCheckbox.tsx b/packages/react-core/src/components/Select/examples/SelectCheckbox.tsx index a3d3105caeb..2a1d582d83c 100644 --- a/packages/react-core/src/components/Select/examples/SelectCheckbox.tsx +++ b/packages/react-core/src/components/Select/examples/SelectCheckbox.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Select, SelectOption, SelectList, MenuToggle, MenuToggleElement, Badge } from '@patternfly/react-core'; export const SelectCheckbox: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [selectedItems, setSelectedItems] = React.useState([]); + const [isOpen, setIsOpen] = useState(false); + const [selectedItems, setSelectedItems] = useState([]); const onToggleClick = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Select/examples/SelectFooter.tsx b/packages/react-core/src/components/Select/examples/SelectFooter.tsx index d2333c630cb..fa61dfd213a 100644 --- a/packages/react-core/src/components/Select/examples/SelectFooter.tsx +++ b/packages/react-core/src/components/Select/examples/SelectFooter.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { MenuToggle, MenuFooter, Select, SelectList, SelectOption, Button } from '@patternfly/react-core'; export const SelectFooter: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [selected, setSelected] = React.useState('Select a value'); + const [isOpen, setIsOpen] = useState(false); + const [selected, setSelected] = useState('Select a value'); const onToggleClick = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Select/examples/SelectGrouped.tsx b/packages/react-core/src/components/Select/examples/SelectGrouped.tsx index 6108a41f266..4a592822d78 100644 --- a/packages/react-core/src/components/Select/examples/SelectGrouped.tsx +++ b/packages/react-core/src/components/Select/examples/SelectGrouped.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Select, SelectOption, @@ -9,8 +10,8 @@ import { } from '@patternfly/react-core'; export const SelectGrouped: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [selected, setSelected] = React.useState('Select a value'); + const [isOpen, setIsOpen] = useState(false); + const [selected, setSelected] = useState('Select a value'); const onToggleClick = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Select/examples/SelectMultiTypeahead.tsx b/packages/react-core/src/components/Select/examples/SelectMultiTypeahead.tsx index 640043aeb24..20095710a3d 100644 --- a/packages/react-core/src/components/Select/examples/SelectMultiTypeahead.tsx +++ b/packages/react-core/src/components/Select/examples/SelectMultiTypeahead.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef, useState } from 'react'; import { Select, SelectOption, @@ -24,17 +25,17 @@ const initialSelectOptions: SelectOptionProps[] = [ ]; export const SelectMultiTypeahead: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [inputValue, setInputValue] = React.useState(''); - const [selected, setSelected] = React.useState([]); - const [selectOptions, setSelectOptions] = React.useState(initialSelectOptions); - const [focusedItemIndex, setFocusedItemIndex] = React.useState(null); - const [activeItemId, setActiveItemId] = React.useState(null); - const textInputRef = React.useRef(undefined); + const [isOpen, setIsOpen] = useState(false); + const [inputValue, setInputValue] = useState(''); + const [selected, setSelected] = useState([]); + const [selectOptions, setSelectOptions] = useState(initialSelectOptions); + const [focusedItemIndex, setFocusedItemIndex] = useState(null); + const [activeItemId, setActiveItemId] = useState(null); + const textInputRef = useRef(undefined); const NO_RESULTS = 'no results'; - React.useEffect(() => { + useEffect(() => { let newSelectOptions: SelectOptionProps[] = initialSelectOptions; // Filter menu items based on the text input value when one exists diff --git a/packages/react-core/src/components/Select/examples/SelectMultiTypeaheadCheckbox.tsx b/packages/react-core/src/components/Select/examples/SelectMultiTypeaheadCheckbox.tsx index 5c55ab6eaa1..9241c38fa18 100644 --- a/packages/react-core/src/components/Select/examples/SelectMultiTypeaheadCheckbox.tsx +++ b/packages/react-core/src/components/Select/examples/SelectMultiTypeaheadCheckbox.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef, useState } from 'react'; import { Select, SelectOption, @@ -22,18 +23,18 @@ const initialSelectOptions: SelectOptionProps[] = [ ]; export const SelectMultiTypeaheadCheckbox: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [inputValue, setInputValue] = React.useState(''); - const [selected, setSelected] = React.useState([]); - const [selectOptions, setSelectOptions] = React.useState(initialSelectOptions); - const [focusedItemIndex, setFocusedItemIndex] = React.useState(null); - const [activeItemId, setActiveItemId] = React.useState(null); - const [placeholder, setPlaceholder] = React.useState('0 items selected'); - const textInputRef = React.useRef(undefined); + const [isOpen, setIsOpen] = useState(false); + const [inputValue, setInputValue] = useState(''); + const [selected, setSelected] = useState([]); + const [selectOptions, setSelectOptions] = useState(initialSelectOptions); + const [focusedItemIndex, setFocusedItemIndex] = useState(null); + const [activeItemId, setActiveItemId] = useState(null); + const [placeholder, setPlaceholder] = useState('0 items selected'); + const textInputRef = useRef(undefined); const NO_RESULTS = 'no results'; - React.useEffect(() => { + useEffect(() => { let newSelectOptions: SelectOptionProps[] = initialSelectOptions; // Filter menu items based on the text input value when one exists @@ -63,7 +64,7 @@ export const SelectMultiTypeaheadCheckbox: React.FunctionComponent = () => { setSelectOptions(newSelectOptions); }, [inputValue]); - React.useEffect(() => { + useEffect(() => { setPlaceholder(`${selected.length} item${selected.length !== 1 ? 's' : ''} selected`); }, [selected]); diff --git a/packages/react-core/src/components/Select/examples/SelectMultiTypeaheadCreatable.tsx b/packages/react-core/src/components/Select/examples/SelectMultiTypeaheadCreatable.tsx index 1b718d8c954..e7e2be5428c 100644 --- a/packages/react-core/src/components/Select/examples/SelectMultiTypeaheadCreatable.tsx +++ b/packages/react-core/src/components/Select/examples/SelectMultiTypeaheadCreatable.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef, useState } from 'react'; import { Select, SelectOption, @@ -24,18 +25,18 @@ let initialSelectOptions: SelectOptionProps[] = [ ]; export const SelectMultiTypeaheadCreatable: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [inputValue, setInputValue] = React.useState(''); - const [selected, setSelected] = React.useState([]); - const [selectOptions, setSelectOptions] = React.useState(initialSelectOptions); - const [focusedItemIndex, setFocusedItemIndex] = React.useState(null); - const [activeItemId, setActiveItemId] = React.useState(null); - const [onCreation, setOnCreation] = React.useState(false); // Boolean to refresh filter state after new option is created - const textInputRef = React.useRef(undefined); + const [isOpen, setIsOpen] = useState(false); + const [inputValue, setInputValue] = useState(''); + const [selected, setSelected] = useState([]); + const [selectOptions, setSelectOptions] = useState(initialSelectOptions); + const [focusedItemIndex, setFocusedItemIndex] = useState(null); + const [activeItemId, setActiveItemId] = useState(null); + const [onCreation, setOnCreation] = useState(false); // Boolean to refresh filter state after new option is created + const textInputRef = useRef(undefined); const CREATE_NEW = 'create'; - React.useEffect(() => { + useEffect(() => { let newSelectOptions: SelectOptionProps[] = initialSelectOptions; // Filter menu items based on the text input value when one exists diff --git a/packages/react-core/src/components/Select/examples/SelectOptionVariations.tsx b/packages/react-core/src/components/Select/examples/SelectOptionVariations.tsx index 6a4030af40f..94ee3cd4d7c 100644 --- a/packages/react-core/src/components/Select/examples/SelectOptionVariations.tsx +++ b/packages/react-core/src/components/Select/examples/SelectOptionVariations.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { Select, SelectOption, SelectList, MenuToggle, MenuToggleElement } from '@patternfly/react-core'; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; export const SelectOptionVariations: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [selected, setSelected] = React.useState('Select a value'); + const [isOpen, setIsOpen] = useState(false); + const [selected, setSelected] = useState('Select a value'); const onToggleClick = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Select/examples/SelectTypeahead.tsx b/packages/react-core/src/components/Select/examples/SelectTypeahead.tsx index b95a28c7984..b7a02d350ab 100644 --- a/packages/react-core/src/components/Select/examples/SelectTypeahead.tsx +++ b/packages/react-core/src/components/Select/examples/SelectTypeahead.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef, useState } from 'react'; import { Select, SelectOption, @@ -22,18 +23,18 @@ const initialSelectOptions: SelectOptionProps[] = [ ]; export const SelectTypeahead: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [selected, setSelected] = React.useState(''); - const [inputValue, setInputValue] = React.useState(''); - const [filterValue, setFilterValue] = React.useState(''); - const [selectOptions, setSelectOptions] = React.useState(initialSelectOptions); - const [focusedItemIndex, setFocusedItemIndex] = React.useState(null); - const [activeItemId, setActiveItemId] = React.useState(null); - const textInputRef = React.useRef(undefined); + const [isOpen, setIsOpen] = useState(false); + const [selected, setSelected] = useState(''); + const [inputValue, setInputValue] = useState(''); + const [filterValue, setFilterValue] = useState(''); + const [selectOptions, setSelectOptions] = useState(initialSelectOptions); + const [focusedItemIndex, setFocusedItemIndex] = useState(null); + const [activeItemId, setActiveItemId] = useState(null); + const textInputRef = useRef(undefined); const NO_RESULTS = 'no results'; - React.useEffect(() => { + useEffect(() => { let newSelectOptions: SelectOptionProps[] = initialSelectOptions; // Filter menu items based on the text input value when one exists diff --git a/packages/react-core/src/components/Select/examples/SelectTypeaheadCreatable.tsx b/packages/react-core/src/components/Select/examples/SelectTypeaheadCreatable.tsx index 47a79de6b6a..5d9ec246281 100644 --- a/packages/react-core/src/components/Select/examples/SelectTypeaheadCreatable.tsx +++ b/packages/react-core/src/components/Select/examples/SelectTypeaheadCreatable.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef, useState } from 'react'; import { Select, SelectOption, @@ -22,18 +23,18 @@ let initialSelectOptions: SelectOptionProps[] = [ ]; export const SelectTypeaheadCreatable: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [selected, setSelected] = React.useState(''); - const [inputValue, setInputValue] = React.useState(''); - const [filterValue, setFilterValue] = React.useState(''); - const [selectOptions, setSelectOptions] = React.useState(initialSelectOptions); - const [focusedItemIndex, setFocusedItemIndex] = React.useState(null); - const [activeItemId, setActiveItemId] = React.useState(null); - const textInputRef = React.useRef(undefined); + const [isOpen, setIsOpen] = useState(false); + const [selected, setSelected] = useState(''); + const [inputValue, setInputValue] = useState(''); + const [filterValue, setFilterValue] = useState(''); + const [selectOptions, setSelectOptions] = useState(initialSelectOptions); + const [focusedItemIndex, setFocusedItemIndex] = useState(null); + const [activeItemId, setActiveItemId] = useState(null); + const textInputRef = useRef(undefined); const CREATE_NEW = 'create'; - React.useEffect(() => { + useEffect(() => { let newSelectOptions: SelectOptionProps[] = initialSelectOptions; // Filter menu items based on the text input value when one exists diff --git a/packages/react-core/src/components/Select/examples/SelectValidated.tsx b/packages/react-core/src/components/Select/examples/SelectValidated.tsx index 055a4666b35..68dfa2db495 100644 --- a/packages/react-core/src/components/Select/examples/SelectValidated.tsx +++ b/packages/react-core/src/components/Select/examples/SelectValidated.tsx @@ -1,4 +1,4 @@ -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; import { Select, SelectOption, @@ -11,9 +11,9 @@ import { } from '@patternfly/react-core'; export const SelectValidated: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [selected, setSelected] = React.useState('Select a value'); - const [status, setStatus] = React.useState(); + const [isOpen, setIsOpen] = useState(false); + const [selected, setSelected] = useState('Select a value'); + const [status, setStatus] = useState(); const onToggleClick = () => { setIsOpen(!isOpen); diff --git a/packages/react-core/src/components/Select/examples/SelectViewMore.tsx b/packages/react-core/src/components/Select/examples/SelectViewMore.tsx index f1513b418c4..b72a241f3ac 100644 --- a/packages/react-core/src/components/Select/examples/SelectViewMore.tsx +++ b/packages/react-core/src/components/Select/examples/SelectViewMore.tsx @@ -1,12 +1,13 @@ +import { useEffect, useRef, useState } from 'react'; import { Select, SelectOption, SelectList, MenuToggle, Spinner } from '@patternfly/react-core'; export const SelectViewMore: React.FunctionComponent = () => { - const [isOpen, setIsOpen] = React.useState(false); - const [selected, setSelected] = React.useState('Select a value'); - const [activeItem, setActiveItem] = React.useState(0); - const [isLoading, setIsLoading] = React.useState(false); + const [isOpen, setIsOpen] = useState(false); + const [selected, setSelected] = useState('Select a value'); + const [activeItem, setActiveItem] = useState(0); + const [isLoading, setIsLoading] = useState(false); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [selectOptions, setSelectOptions] = React.useState([ + const [selectOptions, setSelectOptions] = useState([ Option 1 , @@ -38,13 +39,13 @@ export const SelectViewMore: React.FunctionComponent = () => { Final Option 10 ]); - const [numOptions, setNumOptions] = React.useState(3); - const [visibleOptions, setVisibleOptions] = React.useState(selectOptions.slice(0, numOptions)); - const activeItemRef = React.useRef(null); - const viewMoreRef = React.useRef(null); - const toggleRef = React.useRef(null); + const [numOptions, setNumOptions] = useState(3); + const [visibleOptions, setVisibleOptions] = useState(selectOptions.slice(0, numOptions)); + const activeItemRef = useRef(null); + const viewMoreRef = useRef(null); + const toggleRef = useRef(null); - React.useEffect(() => { + useEffect(() => { activeItemRef.current?.focus(); }, [visibleOptions]); diff --git a/packages/react-core/src/components/SimpleList/examples/SimpleList.md b/packages/react-core/src/components/SimpleList/examples/SimpleList.md index 34f04661ae0..bf7d3887cbd 100644 --- a/packages/react-core/src/components/SimpleList/examples/SimpleList.md +++ b/packages/react-core/src/components/SimpleList/examples/SimpleList.md @@ -4,6 +4,7 @@ section: components cssPrefix: pf-v6-c-simple-list propComponents: ['SimpleList', 'SimpleListGroup', 'SimpleListItem'] --- +import { useState } from 'react'; ## Examples diff --git a/packages/react-core/src/components/SimpleList/examples/SimpleListUncontrolled.tsx b/packages/react-core/src/components/SimpleList/examples/SimpleListUncontrolled.tsx index a80d99e21b7..2fc63143e10 100644 --- a/packages/react-core/src/components/SimpleList/examples/SimpleListUncontrolled.tsx +++ b/packages/react-core/src/components/SimpleList/examples/SimpleListUncontrolled.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { SimpleList, SimpleListItem, SimpleListItemProps } from '@patternfly/react-core'; export const SimpleListUncontrolled: React.FunctionComponent = () => { - const [activeItem, setActiveItem] = React.useState(0); + const [activeItem, setActiveItem] = useState(0); const onSelect = ( selectedItem: React.RefObject | React.RefObject, diff --git a/packages/react-core/src/components/Slider/examples/Slider.md b/packages/react-core/src/components/Slider/examples/Slider.md index ea765c9feeb..8c74eea7be0 100644 --- a/packages/react-core/src/components/Slider/examples/Slider.md +++ b/packages/react-core/src/components/Slider/examples/Slider.md @@ -5,6 +5,7 @@ cssPrefix: pf-v6-c-slider propComponents: ['Slider', 'SliderStepObject'] --- +import { useState } from 'react'; import { Slider, Button, Content, ContentVariants } from '@patternfly/react-core'; import MinusIcon from '@patternfly/react-icons/dist/esm/icons/minus-icon'; import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; diff --git a/packages/react-core/src/components/Slider/examples/SliderActions.tsx b/packages/react-core/src/components/Slider/examples/SliderActions.tsx index 6715965714e..1b4051008cb 100644 --- a/packages/react-core/src/components/Slider/examples/SliderActions.tsx +++ b/packages/react-core/src/components/Slider/examples/SliderActions.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Slider, SliderOnChangeEvent, Button, Content } from '@patternfly/react-core'; import MinusIcon from '@patternfly/react-icons/dist/esm/icons/minus-icon'; import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; @@ -5,10 +6,10 @@ import LockIcon from '@patternfly/react-icons/dist/esm/icons/lock-icon'; import LockOpenIcon from '@patternfly/react-icons/dist/esm/icons/lock-open-icon'; export const SliderActions: React.FunctionComponent = () => { - const [value1, setValue1] = React.useState(50); - const [value2, setValue2] = React.useState(50); - const [inputValue, setInputValue] = React.useState(50); - const [isDisabled, setIsDisabled] = React.useState(false); + const [value1, setValue1] = useState(50); + const [value2, setValue2] = useState(50); + const [inputValue, setInputValue] = useState(50); + const [isDisabled, setIsDisabled] = useState(false); const onChange1 = (_event: SliderOnChangeEvent, value: number) => { setValue1(Math.floor(Number(value))); diff --git a/packages/react-core/src/components/Slider/examples/SliderContinuous.tsx b/packages/react-core/src/components/Slider/examples/SliderContinuous.tsx index 1317bbc3078..a525498d215 100644 --- a/packages/react-core/src/components/Slider/examples/SliderContinuous.tsx +++ b/packages/react-core/src/components/Slider/examples/SliderContinuous.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { Checkbox, Slider, SliderOnChangeEvent, Content } from '@patternfly/react-core'; export const SliderContinuous: React.FunctionComponent = () => { - const [hasTooltipOverThumb, setHasTooltipOverThumb] = React.useState(false); - const [value, setValue] = React.useState(50); - const [valueCustom, setValueCustom] = React.useState(50); + const [hasTooltipOverThumb, setHasTooltipOverThumb] = useState(false); + const [value, setValue] = useState(50); + const [valueCustom, setValueCustom] = useState(50); return ( <> diff --git a/packages/react-core/src/components/Slider/examples/SliderDisabled.tsx b/packages/react-core/src/components/Slider/examples/SliderDisabled.tsx index 48eff696133..2c31cb223c7 100644 --- a/packages/react-core/src/components/Slider/examples/SliderDisabled.tsx +++ b/packages/react-core/src/components/Slider/examples/SliderDisabled.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Slider, SliderOnChangeEvent, Content } from '@patternfly/react-core'; export const SliderDisabled: React.FunctionComponent = () => { - const [value, setValue] = React.useState(50); + const [value, setValue] = useState(50); const steps = [ { value: 0, label: '0' }, { value: 12.5, label: '1', isLabelHidden: true }, diff --git a/packages/react-core/src/components/Slider/examples/SliderDiscrete.tsx b/packages/react-core/src/components/Slider/examples/SliderDiscrete.tsx index d779134561c..cfb9fb6cc3a 100644 --- a/packages/react-core/src/components/Slider/examples/SliderDiscrete.tsx +++ b/packages/react-core/src/components/Slider/examples/SliderDiscrete.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Slider, SliderOnChangeEvent, Content } from '@patternfly/react-core'; export const SliderDiscrete: React.FunctionComponent = () => { @@ -11,7 +12,7 @@ export const SliderDiscrete: React.FunctionComponent = () => { value7: 25 }; - const [numValue, setNumValue] = React.useState(initialValues); + const [numValue, setNumValue] = useState(initialValues); const handleChange = (value: number, name: string) => { setNumValue({ ...numValue, [name]: value }); diff --git a/packages/react-core/src/components/Slider/examples/SliderThumbValueInput.tsx b/packages/react-core/src/components/Slider/examples/SliderThumbValueInput.tsx index 5775c83c33d..6b9188c2390 100644 --- a/packages/react-core/src/components/Slider/examples/SliderThumbValueInput.tsx +++ b/packages/react-core/src/components/Slider/examples/SliderThumbValueInput.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Slider, SliderOnChangeEvent } from '@patternfly/react-core'; export const SliderThumbValueInput: React.FunctionComponent = () => { - const [value, setValue] = React.useState(50); - const [inputValue, setInputValue] = React.useState(50); + const [value, setValue] = useState(50); + const [inputValue, setInputValue] = useState(50); const onChange = ( _event: SliderOnChangeEvent, diff --git a/packages/react-core/src/components/Slider/examples/SliderValueInput.tsx b/packages/react-core/src/components/Slider/examples/SliderValueInput.tsx index e077ac192ae..21871042f8c 100644 --- a/packages/react-core/src/components/Slider/examples/SliderValueInput.tsx +++ b/packages/react-core/src/components/Slider/examples/SliderValueInput.tsx @@ -1,12 +1,13 @@ +import { useState } from 'react'; import { Slider, SliderOnChangeEvent } from '@patternfly/react-core'; export const SliderValueInput: React.FunctionComponent = () => { - const [valueDiscrete, setValueDiscrete] = React.useState(62.5); - const [inputValueDiscrete, setInputValueDiscrete] = React.useState(5); - const [valuePercent, setValuePercent] = React.useState(50); - const [inputValuePercent, setInputValuePercent] = React.useState(50); - const [valueContinuous, setValueContinuous] = React.useState(50); - const [inputValueContinuous, setInputValueContinuous] = React.useState(50); + const [valueDiscrete, setValueDiscrete] = useState(62.5); + const [inputValueDiscrete, setInputValueDiscrete] = useState(5); + const [valuePercent, setValuePercent] = useState(50); + const [inputValuePercent, setInputValuePercent] = useState(50); + const [valueContinuous, setValueContinuous] = useState(50); + const [inputValueContinuous, setInputValueContinuous] = useState(50); const stepsDiscrete = [ { value: 0, label: '0' }, diff --git a/packages/react-core/src/components/Switch/examples/Switch.md b/packages/react-core/src/components/Switch/examples/Switch.md index 25dcebb14f1..39023c97c6d 100644 --- a/packages/react-core/src/components/Switch/examples/Switch.md +++ b/packages/react-core/src/components/Switch/examples/Switch.md @@ -6,7 +6,7 @@ propComponents: ['Switch'] ouia: true --- -import { Fragment } from 'react'; +import { Fragment, useState } from 'react'; ## Examples diff --git a/packages/react-core/src/components/Switch/examples/SwitchBasic.tsx b/packages/react-core/src/components/Switch/examples/SwitchBasic.tsx index f37979411f1..4abd03c2a23 100644 --- a/packages/react-core/src/components/Switch/examples/SwitchBasic.tsx +++ b/packages/react-core/src/components/Switch/examples/SwitchBasic.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Switch } from '@patternfly/react-core'; export const SwitchBasic: React.FunctionComponent = () => { - const [isChecked, setIsChecked] = React.useState(true); + const [isChecked, setIsChecked] = useState(true); const handleChange = (_event: React.FormEvent, checked: boolean) => { setIsChecked(checked); diff --git a/packages/react-core/src/components/Switch/examples/SwitchCheckedWithLabel.tsx b/packages/react-core/src/components/Switch/examples/SwitchCheckedWithLabel.tsx index cb389e96d1c..351f2ec4935 100644 --- a/packages/react-core/src/components/Switch/examples/SwitchCheckedWithLabel.tsx +++ b/packages/react-core/src/components/Switch/examples/SwitchCheckedWithLabel.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Switch } from '@patternfly/react-core'; export const SwitchCheckedWithLabel: React.FunctionComponent = () => { - const [isChecked, setIsChecked] = React.useState(true); + const [isChecked, setIsChecked] = useState(true); const handleChange = (_event: React.FormEvent, checked: boolean) => { setIsChecked(checked); diff --git a/packages/react-core/src/components/Switch/examples/SwitchReversed.tsx b/packages/react-core/src/components/Switch/examples/SwitchReversed.tsx index de35db8e49a..b3882418504 100644 --- a/packages/react-core/src/components/Switch/examples/SwitchReversed.tsx +++ b/packages/react-core/src/components/Switch/examples/SwitchReversed.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Switch } from '@patternfly/react-core'; export const SwitchReversed: React.FunctionComponent = () => { - const [isChecked, setIsChecked] = React.useState(true); + const [isChecked, setIsChecked] = useState(true); const handleChange = (_event: React.FormEvent, checked: boolean) => { setIsChecked(checked); diff --git a/packages/react-core/src/components/Switch/examples/SwitchWithoutLabel.tsx b/packages/react-core/src/components/Switch/examples/SwitchWithoutLabel.tsx index eb6268517de..fbe701642c1 100644 --- a/packages/react-core/src/components/Switch/examples/SwitchWithoutLabel.tsx +++ b/packages/react-core/src/components/Switch/examples/SwitchWithoutLabel.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Switch } from '@patternfly/react-core'; export const SwitchWithoutLabel: React.FunctionComponent = () => { - const [isChecked, setIsChecked] = React.useState(true); + const [isChecked, setIsChecked] = useState(true); const handleChange = (_event: React.FormEvent, checked: boolean) => { setIsChecked(checked); diff --git a/packages/react-core/src/components/Tabs/examples/Tabs.md b/packages/react-core/src/components/Tabs/examples/Tabs.md index 0bbf5ada5e7..6df1476058a 100644 --- a/packages/react-core/src/components/Tabs/examples/Tabs.md +++ b/packages/react-core/src/components/Tabs/examples/Tabs.md @@ -6,7 +6,7 @@ propComponents: ['Tabs', 'Tab', 'TabContent', 'TabContentBody', 'TabTitleText', ouia: true --- -import { Fragment } from 'react'; +import { createRef, Fragment, useEffect, useRef, useState } from 'react'; import UsersIcon from '@patternfly/react-icons/dist/esm/icons/users-icon'; import BoxIcon from '@patternfly/react-icons/dist/esm/icons/box-icon'; import DatabaseIcon from '@patternfly/react-icons/dist/esm/icons/database-icon'; diff --git a/packages/react-core/src/components/Tabs/examples/TabsBoxSecondary.tsx b/packages/react-core/src/components/Tabs/examples/TabsBoxSecondary.tsx index 9a943477d58..b6ef371a1f4 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsBoxSecondary.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsBoxSecondary.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText, Checkbox, Tooltip } from '@patternfly/react-core'; export const TabsBoxSecondary: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isTabsBoxSecondary, setIsTabsBoxSecondary] = React.useState(true); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isTabsBoxSecondary, setIsTabsBoxSecondary] = useState(true); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsChildrenMounting.tsx b/packages/react-core/src/components/Tabs/examples/TabsChildrenMounting.tsx index a05eca357d5..8a8dd9b13ce 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsChildrenMounting.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsChildrenMounting.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText } from '@patternfly/react-core'; export const TabsChildrenMounting: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); + const [activeTabKey, setActiveTabKey] = useState(0); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsContentWithBodyPadding.tsx b/packages/react-core/src/components/Tabs/examples/TabsContentWithBodyPadding.tsx index 9849d03daec..da1de049bb8 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsContentWithBodyPadding.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsContentWithBodyPadding.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { createRef, Fragment, useState } from 'react'; import { Tabs, Tab, TabTitleText, TabContent, TabContentBody } from '@patternfly/react-core'; export const TabContentWithBodyPadding: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); + const [activeTabKey, setActiveTabKey] = useState(0); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, @@ -11,9 +11,9 @@ export const TabContentWithBodyPadding: React.FunctionComponent = () => { setActiveTabKey(tabIndex); }; - const contentRef1 = React.createRef(); - const contentRef2 = React.createRef(); - const contentRef3 = React.createRef(); + const contentRef1 = createRef(); + const contentRef2 = createRef(); + const contentRef3 = createRef(); return ( diff --git a/packages/react-core/src/components/Tabs/examples/TabsDefault.tsx b/packages/react-core/src/components/Tabs/examples/TabsDefault.tsx index 505e3769dae..24024377fd8 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsDefault.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsDefault.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText, Checkbox, Tooltip } from '@patternfly/react-core'; export const TabsDefault: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isBox, setIsBox] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isBox, setIsBox] = useState(false); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsDefaultOverflow.tsx b/packages/react-core/src/components/Tabs/examples/TabsDefaultOverflow.tsx index 56b3dbd6bcc..b5bc9103866 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsDefaultOverflow.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsDefaultOverflow.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core'; export const TabsDefaultOverflow: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isBox, setIsBox] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isBox, setIsBox] = useState(false); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsDynamic.tsx b/packages/react-core/src/components/Tabs/examples/TabsDynamic.tsx index a62520f12ad..f966a5550dc 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsDynamic.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsDynamic.tsx @@ -1,11 +1,12 @@ +import { useEffect, useRef, useState } from 'react'; import { Tabs, Tab, TabTitleText } from '@patternfly/react-core'; export const TabsDynamic: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [tabs, setTabs] = React.useState(['Terminal 1', 'Terminal 2', 'Terminal 3']); - const [newTabNumber, setNewTabNumber] = React.useState(4); - const tabComponentRef = React.useRef(undefined); - const firstMount = React.useRef(true); + const [activeTabKey, setActiveTabKey] = useState(0); + const [tabs, setTabs] = useState(['Terminal 1', 'Terminal 2', 'Terminal 3']); + const [newTabNumber, setNewTabNumber] = useState(4); + const tabComponentRef = useRef(undefined); + const firstMount = useRef(true); const onClose = (event: any, tabIndex: string | number) => { const tabIndexNum = tabIndex as number; @@ -27,7 +28,7 @@ export const TabsDynamic: React.FunctionComponent = () => { setNewTabNumber(newTabNumber + 1); }; - React.useEffect(() => { + useEffect(() => { if (firstMount.current) { firstMount.current = false; return; diff --git a/packages/react-core/src/components/Tabs/examples/TabsFilled.tsx b/packages/react-core/src/components/Tabs/examples/TabsFilled.tsx index 9838505c8f6..17326fac2e2 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsFilled.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsFilled.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core'; export const TabsFilled: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isBox, setIsBox] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isBox, setIsBox] = useState(false); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsFilledWithIcons.tsx b/packages/react-core/src/components/Tabs/examples/TabsFilledWithIcons.tsx index 8c2edb68832..06aee39f478 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsFilledWithIcons.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsFilledWithIcons.tsx @@ -1,11 +1,12 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText, TabTitleIcon, Checkbox } from '@patternfly/react-core'; import UsersIcon from '@patternfly/react-icons/dist/esm/icons/users-icon'; import BoxIcon from '@patternfly/react-icons/dist/esm/icons/box-icon'; import DatabaseIcon from '@patternfly/react-icons/dist/esm/icons/database-icon'; export const TabsFilledWithIcons: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isBox, setIsBox] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isBox, setIsBox] = useState(false); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsHelp.tsx b/packages/react-core/src/components/Tabs/examples/TabsHelp.tsx index d6ee39810d3..1fc646e62ae 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsHelp.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsHelp.tsx @@ -1,8 +1,9 @@ +import { createRef, useState } from 'react'; import { Tabs, Tab, TabTitleText, TabAction, Popover } from '@patternfly/react-core'; import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon'; export const TabsHelp: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); + const [activeTabKey, setActiveTabKey] = useState(0); const tabs = ['Users', 'Containers', 'Database', 'Disabled', 'ARIA disabled', 'Help disabled']; @@ -27,7 +28,7 @@ export const TabsHelp: React.FunctionComponent = () => { role="region" > {tabs.map((tab, index) => { - const ref = React.createRef(); + const ref = createRef(); return ( { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [tabs, setTabs] = React.useState(['Terminal 1', 'Terminal 2', 'Terminal 3']); - const tabComponentRef = React.useRef(undefined); - const firstMount = React.useRef(true); + const [activeTabKey, setActiveTabKey] = useState(0); + const [tabs, setTabs] = useState(['Terminal 1', 'Terminal 2', 'Terminal 3']); + const tabComponentRef = useRef(undefined); + const firstMount = useRef(true); const onClose = (event: any, tabIndex: string | number) => { const tabIndexNum = tabIndex as number; @@ -35,7 +36,7 @@ export const TabsHelpAndClose: React.FunctionComponent = () => { /> ); - React.useEffect(() => { + useEffect(() => { if (firstMount.current) { firstMount.current = false; return; @@ -54,7 +55,7 @@ export const TabsHelpAndClose: React.FunctionComponent = () => { ref={tabComponentRef} > {tabs.map((tab, index) => { - const ref = React.createRef(); + const ref = createRef(); return ( { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [showTabCount, setShowTabCount] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [showTabCount, setShowTabCount] = useState(false); const handleTabClick = (_event: any, tabIndex: string | number) => { setActiveTabKey(tabIndex); diff --git a/packages/react-core/src/components/Tabs/examples/TabsIconAndText.tsx b/packages/react-core/src/components/Tabs/examples/TabsIconAndText.tsx index a2d26e0a842..cd2a75932ed 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsIconAndText.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsIconAndText.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText, TabTitleIcon } from '@patternfly/react-core'; import UsersIcon from '@patternfly/react-icons/dist/esm/icons/users-icon'; import BoxIcon from '@patternfly/react-icons/dist/esm/icons/box-icon'; @@ -7,7 +8,7 @@ import LaptopIcon from '@patternfly/react-icons/dist/esm/icons/laptop-icon'; import ProjectDiagramIcon from '@patternfly/react-icons/dist/esm/icons/project-diagram-icon'; export const TabsIconAndText: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); + const [activeTabKey, setActiveTabKey] = useState(0); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsInset.tsx b/packages/react-core/src/components/Tabs/examples/TabsInset.tsx index e2846ede5ca..c78257c6842 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsInset.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsInset.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core'; export const TabsInset: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isBox, setIsBox] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isBox, setIsBox] = useState(false); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsNav.tsx b/packages/react-core/src/components/Tabs/examples/TabsNav.tsx index 7edf0f76105..906e5034fea 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsNav.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsNav.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Tabs, Tab, TabsComponent, TabTitleText } from '@patternfly/react-core'; export const TabsNav: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); + const [activeTabKey, setActiveTabKey] = useState(0); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsNavSubtab.tsx b/packages/react-core/src/components/Tabs/examples/TabsNavSubtab.tsx index 3023b900a13..4b1223df012 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsNavSubtab.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsNavSubtab.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Tabs, Tab, TabsComponent, TabTitleText } from '@patternfly/react-core'; export const TabsNavSubtab: React.FunctionComponent = () => { - const [activeTabKey1, setActiveTabKey1] = React.useState(0); - const [activeTabKey2, setActiveTabKey2] = React.useState(0); + const [activeTabKey1, setActiveTabKey1] = useState(0); + const [activeTabKey2, setActiveTabKey2] = useState(0); // Toggle currently active primary tab const handleTabClickFirst = ( diff --git a/packages/react-core/src/components/Tabs/examples/TabsPageInsets.tsx b/packages/react-core/src/components/Tabs/examples/TabsPageInsets.tsx index 22b151bdac6..c100d7ac54f 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsPageInsets.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsPageInsets.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core'; export const TabsPageInsets: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isBox, setIsBox] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isBox, setIsBox] = useState(false); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsSeparateContent.tsx b/packages/react-core/src/components/Tabs/examples/TabsSeparateContent.tsx index fa8e6008f00..09cc0a9cd1a 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsSeparateContent.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsSeparateContent.tsx @@ -1,8 +1,8 @@ -import { Fragment } from 'react'; +import { createRef, Fragment, useState } from 'react'; import { Tabs, Tab, TabTitleText, TabContent } from '@patternfly/react-core'; export const TabsSeparateContent: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); + const [activeTabKey, setActiveTabKey] = useState(0); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, @@ -11,9 +11,9 @@ export const TabsSeparateContent: React.FunctionComponent = () => { setActiveTabKey(tabIndex); }; - const contentRef1 = React.createRef(); - const contentRef2 = React.createRef(); - const contentRef3 = React.createRef(); + const contentRef1 = createRef(); + const contentRef2 = createRef(); + const contentRef3 = createRef(); return ( diff --git a/packages/react-core/src/components/Tabs/examples/TabsSubtabs.tsx b/packages/react-core/src/components/Tabs/examples/TabsSubtabs.tsx index 855dfdafb0c..0c0428d62e2 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsSubtabs.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsSubtabs.tsx @@ -1,9 +1,10 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core'; export const TabsSubtabs: React.FunctionComponent = () => { - const [activeTabKey1, setActiveTabKey1] = React.useState(0); - const [activeTabKey2, setActiveTabKey2] = React.useState(0); - const [isBox, setIsBox] = React.useState(false); + const [activeTabKey1, setActiveTabKey1] = useState(0); + const [activeTabKey2, setActiveTabKey2] = useState(0); + const [isBox, setIsBox] = useState(false); // Toggle currently active primary tab const handleTabClickFirst = ( diff --git a/packages/react-core/src/components/Tabs/examples/TabsToggledSeparateContent.tsx b/packages/react-core/src/components/Tabs/examples/TabsToggledSeparateContent.tsx index 6e6486ee628..c8a6d648f68 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsToggledSeparateContent.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsToggledSeparateContent.tsx @@ -1,9 +1,9 @@ -import { Fragment } from 'react'; +import { createRef, Fragment, useState } from 'react'; import { Tabs, Tab, TabContent, Button, Divider } from '@patternfly/react-core'; export const TabsToggledSeparateContent: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isTab2Hidden, setIsTab2Hidden] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isTab2Hidden, setIsTab2Hidden] = useState(false); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, @@ -12,9 +12,9 @@ export const TabsToggledSeparateContent: React.FunctionComponent = () => { setActiveTabKey(tabIndex); }; - const contentRef1 = React.createRef(); - const contentRef2 = React.createRef(); - const contentRef3 = React.createRef(); + const contentRef1 = createRef(); + const contentRef2 = createRef(); + const contentRef3 = createRef(); return ( diff --git a/packages/react-core/src/components/Tabs/examples/TabsTooltipReactRef.tsx b/packages/react-core/src/components/Tabs/examples/TabsTooltipReactRef.tsx index 1e047acb78f..7091a1bbe4c 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsTooltipReactRef.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsTooltipReactRef.tsx @@ -1,8 +1,9 @@ +import { createRef, useState } from 'react'; import { Tabs, Tab, TabTitleText, Checkbox, Tooltip } from '@patternfly/react-core'; export const TabsTooltipReactRef: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isBox, setIsBox] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isBox, setIsBox] = useState(false); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, @@ -15,7 +16,7 @@ export const TabsTooltipReactRef: React.FunctionComponent = () => { setIsBox(checked); }; - const tooltipRef = React.createRef(); + const tooltipRef = createRef(); return (
diff --git a/packages/react-core/src/components/Tabs/examples/TabsUnmountingInvisibleChildren.tsx b/packages/react-core/src/components/Tabs/examples/TabsUnmountingInvisibleChildren.tsx index 1e6f44d209a..d8922894782 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsUnmountingInvisibleChildren.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsUnmountingInvisibleChildren.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText } from '@patternfly/react-core'; export const TabsUnmountingInvisibleChildren: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); + const [activeTabKey, setActiveTabKey] = useState(0); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsVertical.tsx b/packages/react-core/src/components/Tabs/examples/TabsVertical.tsx index d1206b0d99f..c0feb9d0b73 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsVertical.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsVertical.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText, Checkbox, Tooltip } from '@patternfly/react-core'; export const TabsVertical: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isBox, setIsBox] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isBox, setIsBox] = useState(false); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsVerticalExpandable.tsx b/packages/react-core/src/components/Tabs/examples/TabsVerticalExpandable.tsx index a49845199e7..ff4b5bbb545 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsVerticalExpandable.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsVerticalExpandable.tsx @@ -1,8 +1,9 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText } from '@patternfly/react-core'; export const TabsVerticalExpandable: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); - const [isExpanded, setIsExpanded] = React.useState(false); + const [activeTabKey, setActiveTabKey] = useState(0); + const [isExpanded, setIsExpanded] = useState(false); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/Tabs/examples/TabsVerticalExpandableUncontrolled.tsx b/packages/react-core/src/components/Tabs/examples/TabsVerticalExpandableUncontrolled.tsx index 3671988e8b3..6b658bc3abd 100644 --- a/packages/react-core/src/components/Tabs/examples/TabsVerticalExpandableUncontrolled.tsx +++ b/packages/react-core/src/components/Tabs/examples/TabsVerticalExpandableUncontrolled.tsx @@ -1,6 +1,7 @@ +import { useState } from 'react'; import { Tabs, Tab, TabTitleText } from '@patternfly/react-core'; export const TabsVerticalExpandableUncontrolled: React.FunctionComponent = () => { - const [activeTabKey, setActiveTabKey] = React.useState(0); + const [activeTabKey, setActiveTabKey] = useState(0); // Toggle currently active tab const handleTabClick = ( event: React.MouseEvent | React.KeyboardEvent | MouseEvent, diff --git a/packages/react-core/src/components/TextArea/examples/TextArea.md b/packages/react-core/src/components/TextArea/examples/TextArea.md index 9136eb2dff1..a3dd633aa64 100644 --- a/packages/react-core/src/components/TextArea/examples/TextArea.md +++ b/packages/react-core/src/components/TextArea/examples/TextArea.md @@ -6,7 +6,7 @@ cssPrefix: pf-v6-c-form-control propComponents: ['TextArea'] --- -import { Fragment } from 'react'; +import { Fragment, useRef, useState } from 'react'; ## Examples diff --git a/packages/react-core/src/components/TextArea/examples/TextAreaAutoResizing.tsx b/packages/react-core/src/components/TextArea/examples/TextAreaAutoResizing.tsx index 819d5b80a51..4fe55f21820 100644 --- a/packages/react-core/src/components/TextArea/examples/TextAreaAutoResizing.tsx +++ b/packages/react-core/src/components/TextArea/examples/TextAreaAutoResizing.tsx @@ -1,7 +1,8 @@ +import { useState } from 'react'; import { TextArea } from '@patternfly/react-core'; export const TextAreaAutoResizing: React.FunctionComponent = () => { - const [value, setValue] = React.useState(''); + const [value, setValue] = useState(''); return (