Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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} ],
"@babel/preset-typescript"
],
"env": {
"test": {
"presets": [
["@babel/preset-env", {}],
["@babel/preset-react", { "useSpread": true } ],
["@babel/preset-react", { "useSpread": true, "runtime": "automatic" } ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can keep same babel configs for test and build, so it can represent a non-breaking change.

@jacobo-dominguez-wgu if we’ve decided that the @babel/preset-react configuration should be used across all environments, and we’ve already added it to the presets on line 4 of this file, do we still need to duplicate @babel/preset-react under the test environment?

Since the presets section on line 4 defines the base configuration - for example, @babel/preset-env is defined there and then overridden with {} (CommonJS) for the test environment - it seems we can safely remove @babel/preset-react from env.test.presets and keep it only in the global configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I removed it from the test env config. The tests remain working.

"@babel/preset-typescript"
]
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@
"uuid": "^9.0.0"
},
"peerDependencies": {
"react": "^16.8.6 || ^17 || ^18",
"react-dom": "^16.8.6 || ^17 || ^18",
"react": "^16.14 || ^17 || ^18",
"react-dom": "^16.14 || ^17 || ^18",
"react-intl": "^5.25.1 || ^6.4.0"
},
"devDependencies": {
Expand Down
11 changes: 6 additions & 5 deletions src/ActionRow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
import { createElement } from 'react';
import classNames from 'classnames';

interface ActionRowProps extends React.HTMLAttributes<HTMLElement> {
interface ActionRowProps extends HTMLAttributes<HTMLElement> {
/** Specifies the base element */
as?: React.ElementType;
as?: ElementType;
/** Specifies the contents of the row */
children: React.ReactNode;
children: ReactNode;
/** Specifies class name to append to the base element */
className?: string;
/** Specifies whether row should be displayed horizontally */
Expand All @@ -18,7 +19,7 @@ function ActionRow({
children,
...props
}: ActionRowProps) {
return React.createElement(
return createElement(
as,
{
...props,
Expand Down
6 changes: 3 additions & 3 deletions src/Alert/Alert.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type { ReactNode } from 'react';
import { IntlProvider } from 'react-intl';
import renderer, { act } from 'react-test-renderer';
import { render, screen, within } from '@testing-library/react';
Expand All @@ -11,9 +11,9 @@ import Alert, { AlertProps } from '.';

/** A compile time check. Whatever React elements this wraps won't run at runtime. */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function CompileCheck(_props: { children: React.ReactNode }) { return null; }
function CompileCheck(_props: { children: ReactNode }) { return null; }

function AlertWrapper({ children, ...props }: AlertProps & { children: React.ReactNode }) {
function AlertWrapper({ children, ...props }: AlertProps & { children: ReactNode }) {
return (
<IntlProvider locale="en" messages={{}}>
<Alert {...props}>
Expand Down
11 changes: 7 additions & 4 deletions src/Alert/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable react/require-default-props */
import type { ComponentType, ReactElement, ForwardedRef } from 'react';
// react import needed to support JSX outside functions
import React, {
useCallback,
useEffect,
Expand All @@ -11,6 +13,7 @@ import React, {
RefAttributes,
cloneElement,
} from 'react';

import classNames from 'classnames';
import {
Alert as BaseAlert,
Expand Down Expand Up @@ -46,15 +49,15 @@ export interface AlertProps extends BaseProps {
transition?: boolean | TransitionComponent;
children?: ReactNode;
/** Icon that will be shown in the alert */
icon?: React.ComponentType<IconProps>;
icon?: ComponentType<IconProps>;
/** Whether the alert is shown. */
show?: boolean;
/** Whether the alert is dismissible. Defaults to false. */
dismissible?: boolean;
/** Optional callback function for when the alert it dismissed. */
onClose?: () => void;
/** Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true. */
actions?: React.ReactElement[];
actions?: ReactElement[];
/** Position of the dismiss and call-to-action buttons. Defaults to `false`. */
stacked?: boolean;
/** Sets the text for alert close button, defaults to 'Dismiss'. */
Expand Down Expand Up @@ -96,7 +99,7 @@ const Alert = forwardRef(({
stacked = false,
show = true,
...props
}: AlertProps, ref: React.ForwardedRef<HTMLDivElement>) => {
}: AlertProps, ref: ForwardedRef<HTMLDivElement>) => {
const [isStacked, setIsStacked] = useState(stacked);
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });
const actionButtonSize = 'sm';
Expand All @@ -110,7 +113,7 @@ const Alert = forwardRef(({
}, [isExtraSmall, stacked]);

const cloneActionElement = useCallback(
(Action: React.ReactElement) => {
(Action: ReactElement) => {
const addtlActionProps = { size: actionButtonSize, key: Action.props.children };
return cloneElement(Action, addtlActionProps);
},
Expand Down
1 change: 0 additions & 1 deletion src/Annotation/Annotation.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 { render, screen } from '@testing-library/react';
import Annotation from '.';
Expand Down
9 changes: 5 additions & 4 deletions src/Annotation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, { ForwardedRef } from 'react';
import type { HTMLAttributes, ReactNode } from 'react';
import { forwardRef, ForwardedRef } from 'react';
import classNames from 'classnames';

interface AnnotationProps extends React.HTMLAttributes<HTMLSpanElement> {
interface AnnotationProps extends HTMLAttributes<HTMLSpanElement> {
/** Specifies contents of the component. */
children: React.ReactNode;
children: ReactNode;
/** Specifies class name to append to the base element. */
className?: string;
/** Specifies variant to use. */
Expand All @@ -12,7 +13,7 @@ interface AnnotationProps extends React.HTMLAttributes<HTMLSpanElement> {
arrowPlacement?: 'top' | 'right' | 'bottom' | 'left';
}

const Annotation = React.forwardRef(({
const Annotation = forwardRef(({
className,
variant = 'success',
children,
Expand Down
1 change: 0 additions & 1 deletion src/Avatar/Avatar.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 Avatar from './index';

Expand Down
4 changes: 2 additions & 2 deletions src/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import type { ImgHTMLAttributes } from 'react';
import classNames from 'classnames';
// @ts-ignore
import defaultAvatar from './default-avatar.svg';

export interface AvatarProps extends React.ImgHTMLAttributes<HTMLImageElement> {
export interface AvatarProps extends ImgHTMLAttributes<HTMLImageElement> {
/** Alt text. Usually the user's name */
alt?: string;
/** Size of the avatar */
Expand Down
5 changes: 3 additions & 2 deletions src/Badge/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
// React import needed to support JSX outside functions, if removed build-docs fails
import React, { forwardRef } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does removing React not work here? If it doesn't then could you add a comment explaining what happens if you try removing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added

import PropTypes from 'prop-types';
import BaseBadge from 'react-bootstrap/Badge';

const Badge = React.forwardRef((props, ref) => <BaseBadge {...props} ref={ref} />);
const Badge = forwardRef((props, ref) => <BaseBadge {...props} ref={ref} />);

const STYLE_VARIANTS = [
'primary',
Expand Down
1 change: 0 additions & 1 deletion src/Breadcrumb/Breadcrumb.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
4 changes: 2 additions & 2 deletions src/Breadcrumb/BreadcrumbLink.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import { createElement } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

Expand All @@ -24,7 +24,7 @@ export default function BreadcrumbLink({ as, clickHandler, linkProps }) {
addtlProps.onClick = clickHandler;
}

return React.createElement(
return createElement(
as,
{
...props,
Expand Down
38 changes: 20 additions & 18 deletions src/Breadcrumb/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import { Fragment } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

Expand All @@ -14,28 +14,30 @@ function Breadcrumb({
const displayLinks = isMobile ? [links[linkCount - 1]] : links;

return (
<nav
aria-label={ariaLabel}
className={classNames('pgn__breadcrumb', `pgn__breadcrumb-${variant}`)}
{...props}
>
<ol className={classNames('list-inline', { 'is-mobile': isMobile })}>
{displayLinks.map((link, i) => (
<React.Fragment key={link.label}>
<li className={classNames('list-inline-item')}>
<BreadcrumbLink as={linkAs} clickHandler={clickHandler} linkProps={link} />
</li>
{(activeLabel || ((i + 1) < linkCount))
(
<nav
aria-label={ariaLabel}
className={classNames('pgn__breadcrumb', `pgn__breadcrumb-${variant}`)}
{...props}
>
<ol className={classNames('list-inline', { 'is-mobile': isMobile })}>
{displayLinks.map((link, i) => (
<Fragment key={link.label}>
<li className={classNames('list-inline-item')}>
<BreadcrumbLink as={linkAs} clickHandler={clickHandler} linkProps={link} />
</li>
{(activeLabel || ((i + 1) < linkCount))
&& (
<li className="list-inline-item" role="presentation">
{spacer || <Icon src={ChevronRight} id={`spacer-${i}`} />}
</li>
)}
</React.Fragment>
))}
{!isMobile && activeLabel && <li className="list-inline-item active" key="active" aria-current="page">{activeLabel}</li>}
</ol>
</nav>
</Fragment>
))}
{!isMobile && activeLabel && <li className="list-inline-item active" key="active" aria-current="page">{activeLabel}</li>}
</ol>
</nav>
)
);
}

Expand Down
1 change: 0 additions & 1 deletion src/Bubble/Bubble.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 { render, screen } from '@testing-library/react';
import Bubble from '.';
Expand Down
9 changes: 5 additions & 4 deletions src/Bubble/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import type { ReactNode, ForwardedRef } from 'react';
import { forwardRef } from 'react';
import classNames from 'classnames';

export type BubbleVariant = 'primary' | 'success' | 'error' | 'warning';

export interface BubbleProps {
/** Specifies contents of the component. */
children: React.ReactNode;
children: ReactNode;
/** The `Bubble` style variant to use. */
variant?: BubbleVariant;
/** Activates disabled variant. */
Expand All @@ -16,14 +17,14 @@ export interface BubbleProps {
expandable?: boolean;
}

const Bubble = React.forwardRef(({
const Bubble = forwardRef(({
variant = 'primary',
className,
children = null,
disabled = false,
expandable = false,
...props
}: BubbleProps, ref: React.ForwardedRef<HTMLDivElement>) => (
}: BubbleProps, ref: ForwardedRef<HTMLDivElement>) => (
<div
ref={ref}
className={classNames(
Expand Down
1 change: 0 additions & 1 deletion src/Button/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { IntlProvider } from 'react-intl';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
Expand Down
1 change: 0 additions & 1 deletion src/Button/ButtonGroup.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 Button, { ButtonGroup } from './index';
Expand Down
1 change: 0 additions & 1 deletion src/Button/ButtonToolbar.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 { ButtonToolbar } from './index';
Expand Down
Loading