Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"presets": [
["@babel/preset-env", { "modules": false } ],
["@babel/preset-react", { "useSpread": true } ],
["@babel/preset-react", { "useSpread": true, "runtime": "automatic" } ],
"@babel/preset-typescript"
],
"env": {
"test": {
"presets": [
["@babel/preset-env", {}],
["@babel/preset-react", { "useSpread": true } ],
["@babel/preset-react", { "useSpread": true, "runtime": "automatic" } ],
"@babel/preset-typescript"
]
}
Expand Down
1 change: 0 additions & 1 deletion src/Spinner/Spinner.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Spinner from '.';
Expand Down
9 changes: 5 additions & 4 deletions src/Spinner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import React from 'react';
import type { ReactNode, ForwardedRef } from 'react';
import { forwardRef } from 'react';
import classNames from 'classnames';
import BaseSpinner, { type SpinnerProps as BaseSpinnerProps } from 'react-bootstrap/Spinner';

interface SpinnerProps extends BaseSpinnerProps {
/** Optionally specify additional CSS classes to give this spinner's `<div>`. */
className?: string;
/** Specifies the screen reader content for a11y. */
screenReaderText?: React.ReactNode;
screenReaderText?: ReactNode;
}

/** A spinning animation that indicates loading. */
const Spinner = React.forwardRef(({
const Spinner = forwardRef(({
className,
screenReaderText,
...attrs
}: SpinnerProps, ref: React.ForwardedRef<HTMLDivElement>) => {
}: SpinnerProps, ref: ForwardedRef<HTMLDivElement>) => {
const spinnerProps = {
...attrs,
className: classNames('pgn__spinner', className),
Expand Down
1 change: 0 additions & 1 deletion src/Stack/Stack.test.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import renderer from 'react-test-renderer';

Expand Down
1 change: 1 addition & 0 deletions src/Stack/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// React import needed to support build-docs, if removed the build-docs will break
import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
Expand Down
1 change: 0 additions & 1 deletion src/StatefulButton/StatefulButtontest.test.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import renderer from 'react-test-renderer';

import StatefulButton from './index';
Expand Down
1 change: 1 addition & 0 deletions src/StatefulButton/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// React import needed to support build-docs, if removed the build-docs will break
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
Expand Down
1 change: 0 additions & 1 deletion src/Stepper/Stepper.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import PropTypes from 'prop-types';
import StepperStep from './StepperStep';
import StepperHeader from './StepperHeader';
Expand Down
4 changes: 2 additions & 2 deletions src/Stepper/StepperActionRow.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from 'react';
import { createElement, useContext } from 'react';
import PropTypes from 'prop-types';
import { StepperContext } from './StepperContext';
import ActionRow from '../ActionRow';
Expand All @@ -16,7 +16,7 @@ function StepperActionRow({
return null;
}

return React.createElement(as, props, children);
return createElement(as, props, children);
}

StepperActionRow.propTypes = {
Expand Down
6 changes: 3 additions & 3 deletions src/Stepper/StepperContext.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, {
useCallback, useEffect, useReducer, useState,
import {
createContext, useCallback, useEffect, useReducer, useState,
} from 'react';
import PropTypes from 'prop-types';

export const StepperContext = React.createContext({
export const StepperContext = createContext({
activeKey: '',
});

Expand Down
32 changes: 17 additions & 15 deletions src/Stepper/StepperHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from 'react';
import { Fragment, useContext } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import StepperHeaderStep from './StepperHeaderStep';
Expand All @@ -12,20 +12,22 @@ function StepListSeparator() {

function StepList({ steps, activeKey }) {
return (
<ul className="pgn__stepper-header-step-list">
{steps.map(({ label, ...stepProps }, index) => (
<React.Fragment key={stepProps.eventKey}>
{index !== 0 && <StepListSeparator />}
<StepperHeaderStep
{...stepProps}
index={index}
isActive={activeKey === stepProps.eventKey}
>
{label}
</StepperHeaderStep>
</React.Fragment>
))}
</ul>
(
<ul className="pgn__stepper-header-step-list">
{steps.map(({ label, ...stepProps }, index) => (
<Fragment key={stepProps.eventKey}>
{index !== 0 && <StepListSeparator />}
<StepperHeaderStep
{...stepProps}
index={index}
isActive={activeKey === stepProps.eventKey}
>
{label}
</StepperHeaderStep>
</Fragment>
))}
</ul>
)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Stepper/StepperHeaderStep.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from 'react';
import { useContext } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

Expand Down
2 changes: 1 addition & 1 deletion src/Stepper/StepperStep.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useEffect } from 'react';
import { useContext, useEffect } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { StepperContext } from './StepperContext';
Expand Down
1 change: 0 additions & 1 deletion src/Stepper/tests/Stepper.test.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

Expand Down
1 change: 0 additions & 1 deletion src/Sticky/Sticky.test.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import renderer from 'react-test-renderer';

Expand Down
9 changes: 6 additions & 3 deletions src/Sticky/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React, { useLayoutEffect, useState } from 'react';
// React import needed to support build-docs, if removed the build-docs will break
import React, {
forwardRef, useRef, useLayoutEffect, useState,
} from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

Expand All @@ -7,15 +10,15 @@ const POSITION_VARIANTS = [
'bottom',
];

const Sticky = React.forwardRef(({
const Sticky = forwardRef(({
position,
children,
offset,
className,
...rest
}, ref) => {
const [isSticky, setIsSticky] = useState(false);
const defaultRef = React.useRef();
const defaultRef = useRef();
const resolvedRef = ref || defaultRef;

// eslint-disable-next-line consistent-return
Expand Down
1 change: 0 additions & 1 deletion src/Tabs/Tab.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import PropTypes from 'prop-types';
import BaseTab from 'react-bootstrap/Tab';

Expand Down
1 change: 0 additions & 1 deletion src/Tabs/Tabs.test.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { render, waitFor, act } from '@testing-library/react';
import renderer from 'react-test-renderer';
import userEvent from '@testing-library/user-event';
Expand Down
10 changes: 7 additions & 3 deletions src/Tabs/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// React import needed to support build-docs, if removed the build-docs will break
import React, {
Children,
isValidElement,
cloneElement,
useEffect,
useMemo,
useRef,
Expand Down Expand Up @@ -81,14 +85,14 @@ function Tabs({
handleDropdownTabClick(eventKey);
}
};
const childrenList = React.Children.map(children, (child, index) => {
const childrenList = Children.map(children, (child, index) => {
if (child?.type?.name !== 'Tab' && process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.error(
`Tabs children can only be of type Tab. ${children[index]} was passed instead.`,
);
}
if (!React.isValidElement(child)) {
if (!isValidElement(child)) {
return child;
}
const {
Expand All @@ -114,7 +118,7 @@ function Tabs({
newTitle = title;
}
const tabClass = index > indexOfLastVisibleChild ? 'pgn__tab_invisible' : '';
const modifiedTab = React.cloneElement(child, {
const modifiedTab = cloneElement(child, {
...rest,
title: newTitle,
tabClassName: classNames(tabClass, tabClassName),
Expand Down
4 changes: 3 additions & 1 deletion src/Toast/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { MouseEvent } from 'react';
// React import needed to support build-docs, if removed the build-docs will break
import React, { useState } from 'react';
import classNames from 'classnames';
import BaseToast from 'react-bootstrap/Toast';
Expand All @@ -15,7 +17,7 @@ export const TOAST_DELAY = 5000;
interface ToastAction {
label: string;
href?: string;
onClick?: (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
onClick?: (event: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
}

interface ToastProps {
Expand Down