From 8540614b7e99ffa97affab628ed4e50a800b5a67 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 17 Oct 2023 16:30:20 -0500 Subject: [PATCH 1/4] feat(react): remove PropTypes from all react components --- .../src/components/Accordion/Accordion.tsx | 18 --------- .../react/src/components/Address/index.tsx | 15 ------- .../components/Breadcrumb/BreadcrumbItem.tsx | 4 -- packages/react/src/components/Card/Card.tsx | 5 --- .../react/src/components/Card/CardContent.tsx | 4 -- .../react/src/components/Card/CardFooter.tsx | 4 -- .../react/src/components/Card/CardHeader.tsx | 4 -- .../components/ClickOutsideListener/index.tsx | 13 +----- packages/react/src/components/Code/index.tsx | 9 ----- .../src/components/DescriptionList/index.tsx | 10 ----- .../react/src/components/Dialog/index.tsx | 25 ------------ .../ExpandCollapsePanel.tsx | 23 ++++------- .../ExpandCollapsePanel/PanelTrigger.tsx | 11 ----- .../react/src/components/FieldWrap/index.tsx | 6 --- packages/react/src/components/Icon/index.tsx | 10 +---- .../react/src/components/IconButton/index.tsx | 16 -------- .../react/src/components/IssuePanel/index.tsx | 7 +--- .../react/src/components/Layout/index.tsx | 9 ----- packages/react/src/components/Line/index.tsx | 5 --- packages/react/src/components/Link/index.tsx | 12 ------ .../react/src/components/Loader/index.tsx | 5 --- .../src/components/LoaderOverlay/index.tsx | 9 ----- packages/react/src/components/Main/index.tsx | 9 ----- .../react/src/components/MenuBar/index.tsx | 12 ++---- .../react/src/components/MenuItem/index.tsx | 14 +------ .../react/src/components/NavBar/NavBar.tsx | 8 ---- .../react/src/components/NavBar/NavItem.tsx | 4 -- .../react/src/components/Notice/index.tsx | 13 ------ .../components/OptionsMenu/OptionsMenu.tsx | 17 +------- .../OptionsMenu/OptionsMenuItem.tsx | 7 ---- .../OptionsMenu/OptionsMenuList.tsx | 16 +------- .../OptionsMenu/OptionsMenuTrigger.tsx | 10 ----- .../OptionsMenu/OptionsMenuWrapper.tsx | 7 ---- .../src/components/Pagination/Pagination.tsx | 20 ---------- packages/react/src/components/Panel/Panel.tsx | 9 ----- .../src/components/Panel/PanelContent.tsx | 7 ---- .../src/components/Panel/PanelHeader.tsx | 6 --- .../react/src/components/Pointout/index.tsx | 40 +++---------------- .../src/components/ProgressBar/index.tsx | 1 - .../src/components/RadioCardGroup/index.tsx | 30 +------------- .../react/src/components/RadioGroup/index.tsx | 30 +------------- packages/react/src/components/Scrim/index.tsx | 7 +--- .../react/src/components/SideBar/SideBar.tsx | 18 +-------- .../src/components/SideBar/SideBarItem.tsx | 5 --- .../react/src/components/SkipLink/index.tsx | 19 --------- .../react/src/components/Stepper/index.tsx | 13 ------ packages/react/src/components/Table/Table.tsx | 6 --- .../react/src/components/Table/TableBody.tsx | 5 --- .../react/src/components/Table/TableCell.tsx | 5 --- .../src/components/Table/TableFooter.tsx | 5 --- .../react/src/components/Table/TableHead.tsx | 5 --- .../src/components/Table/TableHeader.tsx | 9 ----- .../react/src/components/Table/TableRow.tsx | 5 --- packages/react/src/components/Tabs/Tab.tsx | 6 --- .../react/src/components/Tabs/TabPanel.tsx | 6 --- packages/react/src/components/Tabs/Tabs.tsx | 20 +++------- packages/react/src/components/Tag/index.tsx | 9 ----- .../react/src/components/TextField/index.tsx | 18 --------- packages/react/src/components/Toast/index.tsx | 25 +----------- .../react/src/components/Tooltip/index.tsx | 17 -------- .../src/components/TopBar/TopBarMenu.tsx | 12 ++---- .../src/components/TopBar/TopBarTrigger.tsx | 5 --- .../TwoColumnPanel/ColumnGroupHeader.tsx | 4 -- .../TwoColumnPanel/ColumnHeader.tsx | 4 -- .../components/TwoColumnPanel/ColumnList.tsx | 4 -- .../react/src/components/Workspace/index.tsx | 18 --------- packages/react/src/contexts/theme.tsx | 6 --- packages/react/src/propTypes.ts | 11 ----- 68 files changed, 37 insertions(+), 714 deletions(-) delete mode 100644 packages/react/src/propTypes.ts diff --git a/packages/react/src/components/Accordion/Accordion.tsx b/packages/react/src/components/Accordion/Accordion.tsx index 4c445ae31..86baa5158 100644 --- a/packages/react/src/components/Accordion/Accordion.tsx +++ b/packages/react/src/components/Accordion/Accordion.tsx @@ -5,7 +5,6 @@ import ExpandCollapsePanel, { PanelTrigger } from '../ExpandCollapsePanel'; import { useId } from 'react-id-generator'; -import PropTypes from 'prop-types'; export interface AccordionTriggerProps extends React.HTMLAttributes { @@ -116,22 +115,5 @@ Accordion.displayName = 'Accordion'; AccordionContent.displayName = 'AccordionContent'; AccordionTrigger.displayName = 'AccordionTrigger'; -Accordion.propTypes = { - children: PropTypes.node, - className: PropTypes.string -}; - -AccordionTrigger.propTypes = { - children: PropTypes.node, - heading: PropTypes.shape({ - level: PropTypes.number - }) -}; - -AccordionContent.propTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string -}; - export default Accordion; export { Accordion, AccordionTrigger, AccordionContent }; diff --git a/packages/react/src/components/Address/index.tsx b/packages/react/src/components/Address/index.tsx index a1bedf7d1..905e409b4 100644 --- a/packages/react/src/components/Address/index.tsx +++ b/packages/react/src/components/Address/index.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; interface AddressProps extends React.HTMLAttributes { @@ -13,10 +12,6 @@ export const Address = ({ children, className, ...other }: AddressProps) => ( ); Address.displayName = 'Address'; -Address.propTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string -}; type AddressLineProps = React.HTMLAttributes; @@ -32,10 +27,6 @@ export const AddressLine = ({ ) : null; AddressLine.displayName = 'AddressLine'; -AddressLine.propTypes = { - children: PropTypes.node, - className: PropTypes.string -}; interface AddressCityStateZipProps extends React.HTMLAttributes { city: React.ReactNode; @@ -62,9 +53,3 @@ export const AddressCityStateZip = ({ ) : null; AddressCityStateZip.displayName = 'AddressCityStateZip'; -AddressCityStateZip.propTypes = { - city: PropTypes.node, - state: PropTypes.node, - zip: PropTypes.node, - className: PropTypes.string -}; diff --git a/packages/react/src/components/Breadcrumb/BreadcrumbItem.tsx b/packages/react/src/components/Breadcrumb/BreadcrumbItem.tsx index a72943560..74ad1da64 100644 --- a/packages/react/src/components/Breadcrumb/BreadcrumbItem.tsx +++ b/packages/react/src/components/Breadcrumb/BreadcrumbItem.tsx @@ -1,6 +1,5 @@ import React, { forwardRef } from 'react'; import classnames from 'classnames'; -import PropTypes from 'prop-types'; type BreadcrumbItemProps = React.HTMLAttributes; @@ -16,7 +15,4 @@ const BreadcrumbItem = forwardRef( // eslint-d ) ); -BreadcrumbItem.propTypes = { - className: PropTypes.string -}; export default BreadcrumbItem; diff --git a/packages/react/src/components/Card/Card.tsx b/packages/react/src/components/Card/Card.tsx index 214e15dd6..f9763660e 100644 --- a/packages/react/src/components/Card/Card.tsx +++ b/packages/react/src/components/Card/Card.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; export interface CardProps extends React.HTMLAttributes { @@ -17,9 +16,5 @@ const Card = ({ className, variant, ...other }: CardProps) => ( ); Card.displayName = 'Card'; -Card.propTypes = { - className: PropTypes.string, - variant: PropTypes.string -}; export default Card; diff --git a/packages/react/src/components/Card/CardContent.tsx b/packages/react/src/components/Card/CardContent.tsx index bc760c3e1..9b54bda02 100644 --- a/packages/react/src/components/Card/CardContent.tsx +++ b/packages/react/src/components/Card/CardContent.tsx @@ -1,6 +1,5 @@ import React from 'react'; import classNames from 'classnames'; -import PropTypes from 'prop-types'; export type CardContentProps = React.HTMLAttributes; @@ -9,8 +8,5 @@ const CardContent = ({ className, ...other }: CardContentProps) => ( ); CardContent.displayName = 'CardContent'; -CardContent.propTypes = { - className: PropTypes.string -}; export default CardContent; diff --git a/packages/react/src/components/Card/CardFooter.tsx b/packages/react/src/components/Card/CardFooter.tsx index cdc2971c4..56dfa4b9e 100644 --- a/packages/react/src/components/Card/CardFooter.tsx +++ b/packages/react/src/components/Card/CardFooter.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; export type CardFooterProps = React.HTMLAttributes; @@ -9,8 +8,5 @@ const CardFooter = ({ className, ...other }: CardFooterProps) => ( ); CardFooter.displayName = 'CardFooter'; -CardFooter.propTypes = { - className: PropTypes.string -}; export default CardFooter; diff --git a/packages/react/src/components/Card/CardHeader.tsx b/packages/react/src/components/Card/CardHeader.tsx index fe771c32c..d18361635 100644 --- a/packages/react/src/components/Card/CardHeader.tsx +++ b/packages/react/src/components/Card/CardHeader.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; export type CardHeaderProps = React.HTMLAttributes; @@ -9,8 +8,5 @@ const CardHeader = ({ className, ...other }: CardHeaderProps) => ( ); CardHeader.displayName = 'CardHeader'; -CardHeader.propTypes = { - className: PropTypes.string -}; export default CardHeader; diff --git a/packages/react/src/components/ClickOutsideListener/index.tsx b/packages/react/src/components/ClickOutsideListener/index.tsx index b5355e5ed..8bddc5281 100644 --- a/packages/react/src/components/ClickOutsideListener/index.tsx +++ b/packages/react/src/components/ClickOutsideListener/index.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import setRef from '../../utils/setRef'; export interface ClickOutsideListenerProps< @@ -12,9 +11,7 @@ export interface ClickOutsideListenerProps< target?: T; } -export default class ClickOutsideListener extends React.Component< - ClickOutsideListenerProps -> { +export default class ClickOutsideListener extends React.Component { static displayName = 'ClickOutsideListener'; static defaultProps = { @@ -22,14 +19,6 @@ export default class ClickOutsideListener extends React.Component< touchEvent: 'touchend' }; - static propTypes = { - children: PropTypes.node, - target: PropTypes.any, - onClickOutside: PropTypes.func.isRequired, - mouseEvent: PropTypes.oneOf(['mousedown', 'click', 'mouseup', false]), - touchEvent: PropTypes.oneOf(['touchstart', 'touchend', false]) - }; - private nodeRef: HTMLElement | null; handleEvent = (event: MouseEvent | TouchEvent) => { diff --git a/packages/react/src/components/Code/index.tsx b/packages/react/src/components/Code/index.tsx index b9501dfc0..b5974a33b 100644 --- a/packages/react/src/components/Code/index.tsx +++ b/packages/react/src/components/Code/index.tsx @@ -1,5 +1,4 @@ import React, { useRef, useState, useEffect } from 'react'; -import PropTypes from 'prop-types'; import { SyntaxHighlighterProps } from 'react-syntax-highlighter'; import SyntaxHighlighter from 'react-syntax-highlighter/dist/cjs/light'; import classNames from 'classnames'; @@ -81,12 +80,4 @@ const Code: React.ComponentType> = ({ Code.displayName = 'Code'; -Code.propTypes = { - children: PropTypes.string.isRequired, - language: PropTypes.oneOf(['javascript', 'css', 'html', 'yaml']), - className: PropTypes.string, - tabIndex: PropTypes.number, - scrollable: PropTypes.bool -}; - export default Code; diff --git a/packages/react/src/components/DescriptionList/index.tsx b/packages/react/src/components/DescriptionList/index.tsx index 803e477ae..d68d73d54 100644 --- a/packages/react/src/components/DescriptionList/index.tsx +++ b/packages/react/src/components/DescriptionList/index.tsx @@ -1,12 +1,6 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; -const commonPropTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string -}; - interface DescriptionProps { children: React.ReactNode; className?: string; @@ -33,7 +27,6 @@ export const DescriptionList = ({ ); DescriptionList.displayName = 'DescriptionList'; -DescriptionList.propTypes = commonPropTypes; export const DescriptionListItem = ({ children, @@ -46,7 +39,6 @@ export const DescriptionListItem = ({ ); DescriptionListItem.displayName = 'DescriptionListItem'; -DescriptionListItem.propTypes = commonPropTypes; export const DescriptionTerm = ({ children, @@ -59,7 +51,6 @@ export const DescriptionTerm = ({ ); DescriptionTerm.displayName = 'DescriptionTerm'; -DescriptionTerm.propTypes = commonPropTypes; export const DescriptionDetails = ({ children, @@ -72,4 +63,3 @@ export const DescriptionDetails = ({ ); DescriptionDetails.displayName = 'DescriptionDetails'; -DescriptionDetails.propTypes = commonPropTypes; diff --git a/packages/react/src/components/Dialog/index.tsx b/packages/react/src/components/Dialog/index.tsx index 92124e703..47a62efab 100644 --- a/packages/react/src/components/Dialog/index.tsx +++ b/packages/react/src/components/Dialog/index.tsx @@ -1,6 +1,5 @@ import React from 'react'; import { createPortal } from 'react-dom'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; import FocusTrap from 'focus-trap-react'; import Offscreen from '../Offscreen'; @@ -42,20 +41,6 @@ export default class Dialog extends React.Component { closeButtonText: 'Close' }; - static propTypes = { - className: PropTypes.string, - show: PropTypes.bool, - dialogRef: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.any }) - ]), - onClose: PropTypes.func, - forceAction: PropTypes.bool, - heading: PropTypes.oneOfType([PropTypes.object, PropTypes.node]).isRequired, - closeButtonText: PropTypes.string, - portal: PropTypes.any - }; - private element: HTMLDivElement | null; private heading: HTMLHeadingElement | null; @@ -223,11 +208,6 @@ const DialogContent = ({ ); DialogContent.displayName = 'DialogContent'; -DialogContent.propTypes = { - className: PropTypes.string, - children: PropTypes.node, - align: PropTypes.string -}; export type DialogFooterProps = React.HTMLAttributes & DialogAlignmentProps; @@ -250,9 +230,4 @@ const DialogFooter = ({ ); DialogFooter.displayName = 'DialogFooter'; -DialogFooter.propTypes = { - className: PropTypes.string, - children: PropTypes.node, - align: PropTypes.string -}; export { Dialog, DialogContent, DialogFooter }; diff --git a/packages/react/src/components/ExpandCollapsePanel/ExpandCollapsePanel.tsx b/packages/react/src/components/ExpandCollapsePanel/ExpandCollapsePanel.tsx index 5de705a36..242fd4d4f 100644 --- a/packages/react/src/components/ExpandCollapsePanel/ExpandCollapsePanel.tsx +++ b/packages/react/src/components/ExpandCollapsePanel/ExpandCollapsePanel.tsx @@ -1,5 +1,4 @@ import React, { ReactElement } from 'react'; -import PropTypes from 'prop-types'; import classnames from 'classnames'; import PanelTrigger from './PanelTrigger'; import { @@ -33,14 +32,6 @@ export default class ExpandCollapsePanel extends React.Component< onToggle: () => {} }; - static propTypes = { - open: PropTypes.bool, - children: PropTypes.node.isRequired, - className: PropTypes.string, - animationTiming: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]), - onToggle: PropTypes.func - }; - readonly state: ExpandCollapsePanelState = { controlled: typeof this.props.open !== 'undefined', isOpen: typeof this.props.open !== 'undefined' ? this.props.open : false @@ -63,8 +54,9 @@ export default class ExpandCollapsePanel extends React.Component< animateOpen = () => { const { current: panel } = this.panel; const { animationTiming } = this.props; - const prefersReducedMotion = matchMedia('(prefers-reduced-motion: reduce)') - .matches; + const prefersReducedMotion = matchMedia( + '(prefers-reduced-motion: reduce)' + ).matches; if (!animationTiming || prefersReducedMotion) { this.setState({ isAnimating: false }); @@ -107,8 +99,9 @@ export default class ExpandCollapsePanel extends React.Component< animateClose = () => { const { current: panel } = this.panel; const { animationTiming } = this.props; - const prefersReducedMotion = matchMedia('(prefers-reduced-motion: reduce)') - .matches; + const prefersReducedMotion = matchMedia( + '(prefers-reduced-motion: reduce)' + ).matches; if (!animationTiming || prefersReducedMotion) { this.setState({ isAnimating: false }); @@ -186,10 +179,10 @@ export default class ExpandCollapsePanel extends React.Component< } = this.props; const { isOpen, isAnimating, animationClass } = this.state; const trigger = React.Children.toArray(children).find( - child => (child as ReactElement).type === PanelTrigger + (child) => (child as ReactElement).type === PanelTrigger ); const panelElements = React.Children.toArray(children).filter( - child => + (child) => typeof child === 'string' || (child as ReactElement).type !== PanelTrigger ); diff --git a/packages/react/src/components/ExpandCollapsePanel/PanelTrigger.tsx b/packages/react/src/components/ExpandCollapsePanel/PanelTrigger.tsx index 60fce8024..a73305b74 100644 --- a/packages/react/src/components/ExpandCollapsePanel/PanelTrigger.tsx +++ b/packages/react/src/components/ExpandCollapsePanel/PanelTrigger.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classnames from 'classnames'; import Icon, { IconType } from '../Icon'; @@ -56,16 +55,6 @@ const PanelTrigger = ({ ); }; -PanelTrigger.propTypes = { - children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]), - open: PropTypes.bool, - iconExpanded: PropTypes.string, - iconCollapsed: PropTypes.string, - heading: PropTypes.shape({ - level: PropTypes.number - }) -}; - PanelTrigger.displayName = 'PanelTrigger'; export default React.memo(PanelTrigger); diff --git a/packages/react/src/components/FieldWrap/index.tsx b/packages/react/src/components/FieldWrap/index.tsx index 436a78f6f..583413671 100644 --- a/packages/react/src/components/FieldWrap/index.tsx +++ b/packages/react/src/components/FieldWrap/index.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; interface Props extends React.HTMLAttributes { @@ -16,10 +15,5 @@ const FieldWrap = React.forwardRef( ); FieldWrap.displayName = 'FieldWrap'; -FieldWrap.propTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string, - as: PropTypes.string -}; export default FieldWrap; diff --git a/packages/react/src/components/Icon/index.tsx b/packages/react/src/components/Icon/index.tsx index 07b14d710..4c06c4ff9 100644 --- a/packages/react/src/components/Icon/index.tsx +++ b/packages/react/src/components/Icon/index.tsx @@ -1,6 +1,5 @@ import React, { useState, useEffect, useRef, forwardRef } from 'react'; import Offscreen from '../Offscreen'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; import { IconType, iconTypes } from './types'; @@ -29,7 +28,7 @@ const Icon = forwardRef( } import(`./icons/${name}.svg`) - .then(icon => { + .then((icon) => { isMounted.current && setIcon(() => icon.default); }) .catch(() => { @@ -59,13 +58,6 @@ const Icon = forwardRef( } ); -Icon.propTypes = { - label: PropTypes.string, - className: PropTypes.string, - // @ts-expect-error - type: PropTypes.string.isRequired -}; - Icon.displayName = 'Icon'; export default Icon; diff --git a/packages/react/src/components/IconButton/index.tsx b/packages/react/src/components/IconButton/index.tsx index a7d1ae31d..e0d92b8c2 100644 --- a/packages/react/src/components/IconButton/index.tsx +++ b/packages/react/src/components/IconButton/index.tsx @@ -12,7 +12,6 @@ import React, { MutableRefObject, HTMLProps } from 'react'; -import PropTypes from 'prop-types'; import classnames from 'classnames'; import * as Polymorphic from '../../utils/polymorphic-type'; import Icon, { IconType } from '../Icon'; @@ -110,21 +109,6 @@ const IconButton = forwardRef( } ) as PolymorphicIconButton; -IconButton.propTypes = { - // @ts-expect-error - as: PropTypes.elementType, - // @ts-expect-error - icon: PropTypes.string.isRequired, - label: PropTypes.node.isRequired, - // @ts-expect-error - tooltipPlacement: PropTypes.string, - // @ts-expect-error - tooltipVariant: PropTypes.string, - tooltipPortal: PropTypes.any, - // @ts-expect-error - variant: PropTypes.string -}; - IconButton.displayName = 'IconButton'; export default IconButton; diff --git a/packages/react/src/components/IssuePanel/index.tsx b/packages/react/src/components/IssuePanel/index.tsx index e1f971978..4ba4cf142 100644 --- a/packages/react/src/components/IssuePanel/index.tsx +++ b/packages/react/src/components/IssuePanel/index.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; import IconButton from '../IconButton'; @@ -11,7 +10,7 @@ const IssuePanel = ({ }: { className?: string; title?: string; - actions?: typeof IconButton[]; + actions?: (typeof IconButton)[]; children: React.ReactNode; }) => { return ( @@ -30,9 +29,5 @@ const IssuePanel = ({ }; IssuePanel.displayName = 'IssuePanel'; -IssuePanel.propTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string -}; export default IssuePanel; diff --git a/packages/react/src/components/Layout/index.tsx b/packages/react/src/components/Layout/index.tsx index 2d66d5a27..6b304e467 100644 --- a/packages/react/src/components/Layout/index.tsx +++ b/packages/react/src/components/Layout/index.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; export interface LayoutProps extends React.HTMLAttributes { layoutRef?: React.Ref; @@ -11,14 +10,6 @@ export default class Layout extends React.Component { layoutRef: () => {} }; - static propTypes = { - children: PropTypes.node.isRequired, - layoutRef: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.any }) - ]) - }; - render() { const { layoutRef, children, ...other } = this.props; return ( diff --git a/packages/react/src/components/Line/index.tsx b/packages/react/src/components/Line/index.tsx index 2c37e9f4a..38c5890fe 100644 --- a/packages/react/src/components/Line/index.tsx +++ b/packages/react/src/components/Line/index.tsx @@ -1,15 +1,10 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; const Line = ({ className, ...other }: React.HTMLAttributes) => (
); -Line.propTypes = { - className: PropTypes.string -}; - Line.displayName = 'Line'; export default Line; diff --git a/packages/react/src/components/Link/index.tsx b/packages/react/src/components/Link/index.tsx index 8616949ac..139ce14c3 100644 --- a/packages/react/src/components/Link/index.tsx +++ b/packages/react/src/components/Link/index.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; export interface LinkProps @@ -31,17 +30,6 @@ const Link = ({ ); -Link.propTypes = { - children: PropTypes.node, - className: PropTypes.string, - variant: PropTypes.string, - thin: PropTypes.bool, - linkRef: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.any }) - ]) -}; - Link.displayName = 'Link'; export default Link; diff --git a/packages/react/src/components/Loader/index.tsx b/packages/react/src/components/Loader/index.tsx index 6d8bd4da9..aae9bd472 100644 --- a/packages/react/src/components/Loader/index.tsx +++ b/packages/react/src/components/Loader/index.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Offscreen from '../Offscreen'; import classNames from 'classnames'; @@ -32,10 +31,6 @@ const Loader = React.forwardRef( } ); -Loader.propTypes = { - className: PropTypes.string -}; - Loader.displayName = 'Loader'; export default Loader; diff --git a/packages/react/src/components/LoaderOverlay/index.tsx b/packages/react/src/components/LoaderOverlay/index.tsx index 6f80570fb..a7a047232 100644 --- a/packages/react/src/components/LoaderOverlay/index.tsx +++ b/packages/react/src/components/LoaderOverlay/index.tsx @@ -1,6 +1,5 @@ import React, { forwardRef, useEffect } from 'react'; import FocusTrap from 'focus-trap-react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; import Loader from '../Loader'; import AxeLoader from './axe-loader'; @@ -93,14 +92,6 @@ const LoaderOverlay = forwardRef( } ); -LoaderOverlay.propTypes = { - className: PropTypes.string, - variant: PropTypes.oneOf(['large', 'small']), - label: PropTypes.string, - focusOnInitialRender: PropTypes.bool, - children: PropTypes.node -}; - LoaderOverlay.displayName = 'LoaderOverlay'; export default LoaderOverlay; diff --git a/packages/react/src/components/Main/index.tsx b/packages/react/src/components/Main/index.tsx index cf09d1ffe..02bbddda6 100644 --- a/packages/react/src/components/Main/index.tsx +++ b/packages/react/src/components/Main/index.tsx @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; export interface MainProps extends React.HTMLAttributes { mainRef?: React.Ref; @@ -11,14 +10,6 @@ export default class Main extends Component { mainRef: () => {} }; - static propTypes = { - children: PropTypes.node.isRequired, - mainRef: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.any }) - ]) - }; - render() { const { mainRef, children, ...other } = this.props; return ( diff --git a/packages/react/src/components/MenuBar/index.tsx b/packages/react/src/components/MenuBar/index.tsx index daad361f9..ee3eee7a0 100644 --- a/packages/react/src/components/MenuBar/index.tsx +++ b/packages/react/src/components/MenuBar/index.tsx @@ -1,5 +1,4 @@ import React, { Children, cloneElement } from 'react'; -import PropTypes from 'prop-types'; import keyname from 'keyname'; import { isWide } from '../../utils/viewport'; @@ -17,13 +16,6 @@ export default class TopBar extends React.Component< MenuBarProps, MenuBarState > { - static propTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string, - thin: PropTypes.bool, - hasTrigger: PropTypes.bool - }; - static defaultProps = { thin: false, hasTrigger: false @@ -117,7 +109,9 @@ export default class TopBar extends React.Component< menuItems.shift(); } - const currentIndex = menuItems.findIndex(menuitem => menuitem === e.target); + const currentIndex = menuItems.findIndex( + (menuitem) => menuitem === e.target + ); if (currentIndex === -1 || (key !== 'left' && key !== 'right')) { return; } diff --git a/packages/react/src/components/MenuItem/index.tsx b/packages/react/src/components/MenuItem/index.tsx index eb02df592..d6c8e458c 100644 --- a/packages/react/src/components/MenuItem/index.tsx +++ b/packages/react/src/components/MenuItem/index.tsx @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; import keyname from 'keyname'; import clickLink from './click-link'; import setRef from '../../utils/setRef'; @@ -23,17 +22,6 @@ export default class MenuItem extends Component { autoClickLink: true }; - static propTypes = { - children: PropTypes.node.isRequired, - menuItemRef: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.any }) - ]), - onClick: PropTypes.func, - onKeyDown: PropTypes.func, - autoClickLink: PropTypes.bool - }; - private item: HTMLLIElement | null; constructor(props: MenuItemProps) { @@ -68,7 +56,7 @@ export default class MenuItem extends Component {
  • { + ref={(item) => { this.item = item; setRef(menuItemRef, item); }} diff --git a/packages/react/src/components/NavBar/NavBar.tsx b/packages/react/src/components/NavBar/NavBar.tsx index 64118132d..26dd6fa84 100644 --- a/packages/react/src/components/NavBar/NavBar.tsx +++ b/packages/react/src/components/NavBar/NavBar.tsx @@ -5,7 +5,6 @@ import React, { KeyboardEventHandler } from 'react'; import classNames from 'classnames'; -import PropTypes from 'prop-types'; import Icon from '../Icon'; import { useId } from 'react-id-generator'; @@ -97,12 +96,5 @@ const NavBar = ({ }; NavBar.displayName = 'NavBar'; -NavBar.propTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string, - collapsed: PropTypes.bool, - navTriggerLabel: PropTypes.string, - propId: PropTypes.string -}; export default NavBar; diff --git a/packages/react/src/components/NavBar/NavItem.tsx b/packages/react/src/components/NavBar/NavItem.tsx index 4af138f6f..1b0efaf20 100644 --- a/packages/react/src/components/NavBar/NavItem.tsx +++ b/packages/react/src/components/NavBar/NavItem.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; interface NavItemProps extends React.HTMLAttributes { @@ -34,8 +33,5 @@ const NavItem = ({ }; NavItem.displayName = 'NavItem'; -NavItem.propTypes = { - children: PropTypes.node.isRequired -}; export default NavItem; diff --git a/packages/react/src/components/Notice/index.tsx b/packages/react/src/components/Notice/index.tsx index 082cc94f8..cbd4cd735 100644 --- a/packages/react/src/components/Notice/index.tsx +++ b/packages/react/src/components/Notice/index.tsx @@ -1,5 +1,4 @@ import React, { forwardRef, ReactNode } from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; import Icon, { IconType } from '../Icon'; import { ContentNode } from '../../types'; @@ -42,17 +41,5 @@ const Notice = forwardRef( ); Notice.displayName = 'Notice'; -Notice.propTypes = { - children: PropTypes.node, - type: PropTypes.oneOf(['caution', 'info', 'danger']), - // @ts-expect-error - title: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - PropTypes.element - ]), - // @ts-expect-error - icon: PropTypes.string -}; export default Notice; diff --git a/packages/react/src/components/OptionsMenu/OptionsMenu.tsx b/packages/react/src/components/OptionsMenu/OptionsMenu.tsx index abd3c9d38..948cbc895 100644 --- a/packages/react/src/components/OptionsMenu/OptionsMenu.tsx +++ b/packages/react/src/components/OptionsMenu/OptionsMenu.tsx @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; import OptionsMenuWrapper from './OptionsMenuWrapper'; import OptionsMenuList from './OptionsMenuList'; import setRef from '../../utils/setRef'; @@ -47,20 +46,6 @@ export default class OptionsMenu extends Component< align: 'right' }; - static propTypes = { - trigger: PropTypes.func, - children: PropTypes.node.isRequired, - onClose: PropTypes.func, - className: PropTypes.string, - onSelect: PropTypes.func, - closeOnSelect: PropTypes.bool, - menuRef: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.any }) - ]), - align: PropTypes.oneOf(['left', 'right']) - }; - private triggerRef: React.RefObject; constructor(props: AllOptionsMenuProps) { @@ -116,7 +101,7 @@ export default class OptionsMenu extends Component< })} { + menuRef={(el) => { if (menuRef) { setRef(menuRef, el); } diff --git a/packages/react/src/components/OptionsMenu/OptionsMenuItem.tsx b/packages/react/src/components/OptionsMenu/OptionsMenuItem.tsx index 04d99f8dd..52205d1e3 100644 --- a/packages/react/src/components/OptionsMenu/OptionsMenuItem.tsx +++ b/packages/react/src/components/OptionsMenu/OptionsMenuItem.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; export interface OptionsMenuItemProps extends Pick< @@ -18,12 +17,6 @@ class OptionsMenuItemComponent extends React.Component { onSelect: () => {} }; - static propTypes = { - disabled: PropTypes.bool, - className: PropTypes.string, - onSelect: PropTypes.func - }; - handleClick = (event: React.MouseEvent) => { const { disabled, onSelect } = this.props; if (!disabled) { diff --git a/packages/react/src/components/OptionsMenu/OptionsMenuList.tsx b/packages/react/src/components/OptionsMenu/OptionsMenuList.tsx index 2c5e849b9..4b8088a28 100644 --- a/packages/react/src/components/OptionsMenu/OptionsMenuList.tsx +++ b/packages/react/src/components/OptionsMenu/OptionsMenuList.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import { OptionsMenuProps } from './OptionsMenu'; import ClickOutsideListener from '../ClickOutsideListener'; import classnames from 'classnames'; @@ -28,19 +27,6 @@ export default class OptionsMenuList extends React.Component< onClose: () => {} }; - static propTypes = { - show: PropTypes.bool, - children: PropTypes.node.isRequired, - onClose: PropTypes.func, - className: PropTypes.string, - onSelect: PropTypes.func, - closeOnSelect: PropTypes.bool, - menuRef: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.any }) - ]) - }; - private itemRefs: Array; private menuRef: HTMLUListElement | null; @@ -189,7 +175,7 @@ export default class OptionsMenuList extends React.Component< aria-expanded={show} role="menu" onClick={handleClick} - ref={el => { + ref={(el) => { this.menuRef = el; if (menuRef) { setRef(menuRef, el); diff --git a/packages/react/src/components/OptionsMenu/OptionsMenuTrigger.tsx b/packages/react/src/components/OptionsMenu/OptionsMenuTrigger.tsx index 43fb2ac2c..7dac74304 100644 --- a/packages/react/src/components/OptionsMenu/OptionsMenuTrigger.tsx +++ b/packages/react/src/components/OptionsMenu/OptionsMenuTrigger.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; export interface OptionsMenuTriggerProps @@ -27,15 +26,6 @@ function OptionsMenuTriggerComponent({ ); } -OptionsMenuTriggerComponent.propTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string, - triggerRef: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.any }) - ]) -}; - export default React.forwardRef(function OptionsMenuTrigger( props: OptionsMenuTriggerProps, ref: React.Ref diff --git a/packages/react/src/components/OptionsMenu/OptionsMenuWrapper.tsx b/packages/react/src/components/OptionsMenu/OptionsMenuWrapper.tsx index 56b853fdd..ffcc70a63 100644 --- a/packages/react/src/components/OptionsMenu/OptionsMenuWrapper.tsx +++ b/packages/react/src/components/OptionsMenu/OptionsMenuWrapper.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; import { OptionsMenuAlignmentProps } from './OptionsMenu'; @@ -30,10 +29,4 @@ const OptionsMenuWrapper = ({ /> ); -OptionsMenuWrapper.propTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string, - align: PropTypes.oneOf(['left', 'right']) -}; - export default OptionsMenuWrapper; diff --git a/packages/react/src/components/Pagination/Pagination.tsx b/packages/react/src/components/Pagination/Pagination.tsx index 5f39afefc..ffae298d9 100644 --- a/packages/react/src/components/Pagination/Pagination.tsx +++ b/packages/react/src/components/Pagination/Pagination.tsx @@ -1,10 +1,8 @@ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; import { Placement } from '@popperjs/core'; import IconButton from '../IconButton'; import { ContentNode } from '../../types'; -import * as CustomPropTypes from '../../propTypes'; interface Props extends React.HTMLAttributes { totalItems: number; @@ -117,23 +115,5 @@ const Pagination = React.forwardRef( ); Pagination.displayName = 'Pagination'; -Pagination.propTypes = { - totalItems: PropTypes.number.isRequired, - itemsPerPage: PropTypes.number, - currentPage: PropTypes.number, - statusLabel: PropTypes.element, - firstPageLabel: CustomPropTypes.contentNode, - previousPageLabel: CustomPropTypes.contentNode, - nextPageLabel: CustomPropTypes.contentNode, - lastPageLabel: CustomPropTypes.contentNode, - onNextPageClick: PropTypes.func, - onPreviousPageClick: PropTypes.func, - onFirstPageClick: PropTypes.func, - onLastPageClick: PropTypes.func, - // @ts-expect-error - tooltipPlacement: PropTypes.string, - className: PropTypes.string, - thin: PropTypes.bool -}; export default Pagination; diff --git a/packages/react/src/components/Panel/Panel.tsx b/packages/react/src/components/Panel/Panel.tsx index dd9e72053..04e5c62e6 100644 --- a/packages/react/src/components/Panel/Panel.tsx +++ b/packages/react/src/components/Panel/Panel.tsx @@ -1,5 +1,4 @@ import React, { HTMLAttributes, ReactNode, forwardRef } from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; import rndid from '../../utils/rndid'; @@ -76,13 +75,5 @@ const Panel = forwardRef( ); Panel.displayName = 'Panel'; -Panel.propTypes = { - children: PropTypes.node.isRequired, - // @ts-expect-error - heading: PropTypes.oneOfType([PropTypes.object, PropTypes.node]), - className: PropTypes.string, - padding: PropTypes.bool, - collapsed: PropTypes.bool -}; export default Panel; diff --git a/packages/react/src/components/Panel/PanelContent.tsx b/packages/react/src/components/Panel/PanelContent.tsx index d75e0e353..55bc084dd 100644 --- a/packages/react/src/components/Panel/PanelContent.tsx +++ b/packages/react/src/components/Panel/PanelContent.tsx @@ -1,6 +1,5 @@ import React, { ReactNode, forwardRef } from 'react'; import classNames from 'classnames'; -import PropTypes from 'prop-types'; export interface PanelContentProps extends React.HTMLAttributes { @@ -30,10 +29,4 @@ const PanelContent = forwardRef( PanelContent.displayName = 'PanelContent'; -PanelContent.propTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string, - padding: PropTypes.bool -}; - export default PanelContent; diff --git a/packages/react/src/components/Panel/PanelHeader.tsx b/packages/react/src/components/Panel/PanelHeader.tsx index eb409e3d9..f89eb441c 100644 --- a/packages/react/src/components/Panel/PanelHeader.tsx +++ b/packages/react/src/components/Panel/PanelHeader.tsx @@ -1,6 +1,5 @@ import React, { ReactNode, forwardRef } from 'react'; import classNames from 'classnames'; -import PropTypes from 'prop-types'; export interface PanelHeaderProps extends React.HTMLAttributes { children: ReactNode; @@ -23,9 +22,4 @@ const PanelHeader = forwardRef( PanelHeader.displayName = 'PanelHeader'; -PanelHeader.propTypes = { - children: PropTypes.node.isRequired, - className: PropTypes.string -}; - export default PanelHeader; diff --git a/packages/react/src/components/Pointout/index.tsx b/packages/react/src/components/Pointout/index.tsx index 7165ee3c2..370e9c5cf 100644 --- a/packages/react/src/components/Pointout/index.tsx +++ b/packages/react/src/components/Pointout/index.tsx @@ -1,5 +1,4 @@ import React, { ButtonHTMLAttributes } from 'react'; -import PropTypes from 'prop-types'; import { createPortal } from 'react-dom'; import classNames from 'classnames'; import focusable from 'focusable'; @@ -63,35 +62,6 @@ export default class Pointout extends React.Component< position: 'center' }; - static propTypes = { - heading: PropTypes.node, - children: PropTypes.node.isRequired, - ftpRef: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.any }) - ]), - noArrow: function(props: PointoutProps, propName: keyof PointoutProps) { - if (props[propName] === true && typeof props['target'] !== 'undefined') { - return new Error( - 'A "target" prop with "noArrow=true" is not currently supported.' - ); - } - }, - arrowPosition: PropTypes.string, - onClose: PropTypes.func, - dismissText: PropTypes.string, - className: PropTypes.string, - target: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.any }) - ]), - disableOffscreenPointout: PropTypes.bool, - portal: PropTypes.any, - previousButtonProps: PropTypes.any, - nextButtonProps: PropTypes.any, - closeButtonProps: PropTypes.any - }; - private resizeDebounceId: number; private resizeDebounce: () => void; private offscreenRef: HTMLElement | null; @@ -231,7 +201,7 @@ export default class Pointout extends React.Component< const offscreenFocusable = getFocusableElements(offscreenRef); const visibleFocusable = getFocusableElements(visibleRef); const elementIndex = offscreenFocusable.findIndex( - element => element === target + (element) => element === target ); if (elementIndex === -1 || !visibleFocusable[elementIndex]) { @@ -252,7 +222,7 @@ export default class Pointout extends React.Component< const offscreenFocusable = getFocusableElements(offscreenRef); const visibleFocusable = getFocusableElements(visibleRef); const elementIndex = offscreenFocusable.findIndex( - element => element === target + (element) => element === target ); if (elementIndex === -1 || !visibleFocusable[elementIndex]) { @@ -396,7 +366,7 @@ export default class Pointout extends React.Component< role={target ? undefined : 'region'} aria-labelledby={heading ? headingId : undefined} aria-hidden={!!target && !disableOffscreenPointout} - ref={el => (this.visibleRef = el)} + ref={(el) => (this.visibleRef = el)} > {noArrow ? null : (
    (this.offscreenRef = el)} + ref={(el) => (this.offscreenRef = el)} >