diff --git a/examples/bpk-component-accordion/examples.js b/examples/bpk-component-accordion/examples.tsx similarity index 98% rename from examples/bpk-component-accordion/examples.js rename to examples/bpk-component-accordion/examples.tsx index 8ec6b2aad3..f7f787a1ae 100644 --- a/examples/bpk-component-accordion/examples.js +++ b/examples/bpk-component-accordion/examples.tsx @@ -16,8 +16,6 @@ * limitations under the License. */ -/* @flow strict */ - import { colorMonteverde, colorPanjin, @@ -32,6 +30,7 @@ import { BpkAccordionItem, withAccordionItemState, } from '../../packages/bpk-component-accordion'; +// @ts-expect-error Untyped import - see `decisions/imports-ts-suppressions.md`. import BpkCheckbox from '../../packages/bpk-component-checkbox'; import { withAlignment } from '../../packages/bpk-component-icon'; import StopsIcon from '../../packages/bpk-component-icon/sm/stops'; @@ -44,7 +43,7 @@ const StatefulAccordionItem = withAccordionItemState(BpkAccordionItem); const AlignedStopsIcon = withAlignment(StopsIcon, lineHeightBase, iconSizeSm); const AlignedTimeIcon = withAlignment(TimeIcon, lineHeightBase, iconSizeSm); -const CheckboxWrapper = (props) => ( +const CheckboxWrapper = (props: any) => (
); diff --git a/examples/bpk-component-accordion/stories-utils.js b/examples/bpk-component-accordion/stories-utils.tsx similarity index 100% rename from examples/bpk-component-accordion/stories-utils.js rename to examples/bpk-component-accordion/stories-utils.tsx diff --git a/examples/bpk-component-accordion/stories.js b/examples/bpk-component-accordion/stories.tsx similarity index 96% rename from examples/bpk-component-accordion/stories.js rename to examples/bpk-component-accordion/stories.tsx index 2b000faea4..52f8193039 100644 --- a/examples/bpk-component-accordion/stories.js +++ b/examples/bpk-component-accordion/stories.tsx @@ -77,7 +77,9 @@ export const WithoutDividerOnDark = SingleItemExampleWithoutDividerOnDark; export const VisualTest = SingleItemExample; export const VisualTestOnDark = WithDarkBackgroundExample; -export const VisualTestWithZoom = VisualTest.bind({}); -VisualTestWithZoom.args = { - zoomEnabled: true, +export const VisualTestWithZoom = { + render: VisualTest, + args: { + zoomEnabled: true, + } }; diff --git a/packages/bpk-component-accordion/index.js b/packages/bpk-component-accordion/index.ts similarity index 98% rename from packages/bpk-component-accordion/index.js rename to packages/bpk-component-accordion/index.ts index 0be49bf9c7..908560a875 100644 --- a/packages/bpk-component-accordion/index.js +++ b/packages/bpk-component-accordion/index.ts @@ -16,8 +16,6 @@ * limitations under the License. */ -/* @flow strict */ - import BpkAccordion from './src/BpkAccordion'; import BpkAccordionItem from './src/BpkAccordionItem'; import withAccordionItemState from './src/withAccordionItemState'; diff --git a/packages/bpk-component-accordion/src/BpkAccordion-test.js b/packages/bpk-component-accordion/src/BpkAccordion-test.tsx similarity index 98% rename from packages/bpk-component-accordion/src/BpkAccordion-test.js rename to packages/bpk-component-accordion/src/BpkAccordion-test.tsx index a807babb8f..b857dd40ef 100644 --- a/packages/bpk-component-accordion/src/BpkAccordion-test.js +++ b/packages/bpk-component-accordion/src/BpkAccordion-test.tsx @@ -16,8 +16,6 @@ * limitations under the License. */ -/* @flow strict */ - import { render } from '@testing-library/react'; import BpkAccordion from './BpkAccordion'; diff --git a/packages/bpk-component-accordion/src/BpkAccordion.js b/packages/bpk-component-accordion/src/BpkAccordion.tsx similarity index 67% rename from packages/bpk-component-accordion/src/BpkAccordion.js rename to packages/bpk-component-accordion/src/BpkAccordion.tsx index 6d1881a04f..2c613bca47 100644 --- a/packages/bpk-component-accordion/src/BpkAccordion.js +++ b/packages/bpk-component-accordion/src/BpkAccordion.tsx @@ -16,10 +16,8 @@ * limitations under the License. */ -/* @flow strict */ - -import PropTypes from 'prop-types'; -import { createContext, Node } from 'react'; +import { createContext } from 'react'; +import type { ReactNode } from 'react'; import { cssModules } from '../../bpk-react-utils'; @@ -27,15 +25,26 @@ import STYLES from './BpkAccordion.module.scss'; const getClassName = cssModules(STYLES); -type Props = { children: Node, className: ?string }; +export type BpkAccordionProps = { + children: ReactNode; + className?: string; + divider?: boolean; + onDark?: boolean; +}; export const BpkAccordionContext = createContext({ onDark: false, divider: true, }); -const BpkAccordion = (props: Props) => { - const { children, className, divider, onDark, ...rest } = props; +const BpkAccordion = (props: BpkAccordionProps) => { + const { + children, + className, + divider = true, + onDark = false, + ...rest + } = props; const classNames = getClassName( 'bpk-accordion', @@ -45,7 +54,6 @@ const BpkAccordion = (props: Props) => { return (( + ComposedComponent: ComponentType
, +) => { + class WithAccordionItemState extends Component
{
+ static displayName = wrapDisplayName(
+ ComposedComponent,
+ 'withAccordionItemState',
+ );
static defaultProps = {
initiallyExpanded: false,
@@ -48,7 +48,7 @@ const withAccordionItemState = (ComposedComponent: ComponentType (
+ ComposedComponent: ComponentType ,
) => {
- class WithSingleItemAccordionState extends Component {
+ static displayName = wrapDisplayName(
+ ComposedComponent,
+ 'withSingleItemAccordionState',
+ );
+
+ constructor(props: P & Props) {
super(props);
this.state = {
@@ -53,13 +57,13 @@ const withSingleItemAccordionState = (
};
}
- openAccordionItem = (key: ?string | ?number) => {
+ openAccordionItem = (key?: string | number | null) => {
this.setState({ expanded: key });
};
- renderAccordionItem = (accordionItem: Element