@openedx/paragon 23.3.0 → 23.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/bin/paragon-scripts.js +1 -1
  2. package/dist/DataTable/TablePagination.js +4 -0
  3. package/dist/DataTable/TablePagination.js.map +1 -1
  4. package/dist/DataTable/TablePaginationMinimal.js +4 -1
  5. package/dist/DataTable/TablePaginationMinimal.js.map +1 -1
  6. package/dist/DataTable/messages.js +11 -0
  7. package/dist/Hyperlink/index.d.ts +10 -5
  8. package/dist/Hyperlink/index.js +56 -25
  9. package/dist/Hyperlink/index.js.map +1 -1
  10. package/dist/core.css +657 -657
  11. package/dist/core.css.map +1 -1
  12. package/dist/core.min.css +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/light.css +2051 -2051
  16. package/dist/light.css.map +1 -1
  17. package/dist/light.min.css +1 -1
  18. package/package.json +2 -2
  19. package/src/Button/Button.test.tsx +6 -1
  20. package/src/DataTable/TablePagination.jsx +5 -0
  21. package/src/DataTable/TablePaginationMinimal.jsx +5 -1
  22. package/src/DataTable/messages.js +11 -0
  23. package/src/DataTable/tests/TableFooter.test.jsx +5 -1
  24. package/src/DataTable/tests/TablePagination.test.jsx +6 -3
  25. package/src/Hyperlink/Hyperlink.test.tsx +50 -20
  26. package/src/Hyperlink/README.md +14 -1
  27. package/src/Hyperlink/index.tsx +70 -30
  28. package/src/MailtoLink/MailtoLink.test.jsx +12 -3
  29. package/src/Menu/Menu.test.jsx +12 -9
  30. package/src/Menu/SelectMenu.test.jsx +35 -16
  31. package/src/Menu/__snapshots__/Menu.test.jsx.snap +0 -1
  32. package/src/index.d.ts +1 -1
  33. package/src/index.js +1 -1
  34. package/styles/css/core/variables.css +656 -656
  35. package/styles/css/themes/light/variables.css +2051 -2051
  36. package/styles/scss/core/_variables.scss +1 -1
  37. package/tokens/src/core/global/other.json +5 -0
  38. package/tokens/src/core/global/typography.json +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openedx/paragon",
3
- "version": "23.3.0",
3
+ "version": "23.4.0",
4
4
  "description": "Accessible, responsive UI component library based on Bootstrap.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -96,7 +96,7 @@
96
96
  "react-table": "^7.7.0",
97
97
  "react-transition-group": "^4.4.2",
98
98
  "sass": "^1.58.3",
99
- "style-dictionary": "^4.0.1",
99
+ "style-dictionary": "^4.3.2",
100
100
  "tabbable": "^5.3.3",
101
101
  "uncontrollable": "^7.2.1",
102
102
  "uuid": "^9.0.0"
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { IntlProvider } from 'react-intl';
2
3
  import { render, screen } from '@testing-library/react';
3
4
  import userEvent from '@testing-library/user-event';
4
5
  import renderer from 'react-test-renderer';
@@ -96,7 +97,11 @@ describe('<Button />', () => {
96
97
  test('test button as hyperlink', () => {
97
98
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
98
99
  const ref = (_current: HTMLAnchorElement) => {}; // Check typing of a ref - should not show type errors.
99
- render(<Button as={Hyperlink} ref={ref} destination="https://www.poop.com/💩">Button</Button>);
100
+ render(
101
+ <IntlProvider locale="en">
102
+ <Button as={Hyperlink} ref={ref} destination="https://www.poop.com/💩">Button</Button>
103
+ </IntlProvider>,
104
+ );
100
105
  expect(screen.getByRole('link').getAttribute('href')).toEqual('https://www.poop.com/💩');
101
106
  });
102
107
  });
@@ -1,8 +1,12 @@
1
1
  import React, { useContext } from 'react';
2
+ import { useIntl } from 'react-intl';
2
3
  import DataTableContext from './DataTableContext';
3
4
  import Pagination from '../Pagination';
5
+ import messages from './messages';
4
6
 
5
7
  function TablePagination() {
8
+ const intl = useIntl();
9
+
6
10
  const {
7
11
  pageCount, state, gotoPage,
8
12
  } = useContext(DataTableContext);
@@ -19,6 +23,7 @@ function TablePagination() {
19
23
  currentPage={pageIndex + 1}
20
24
  onPageSelect={(pageNum) => gotoPage(pageNum - 1)}
21
25
  pageCount={pageCount}
26
+ paginationLabel={intl.formatMessage(messages.paginationLabel)}
22
27
  icons={{
23
28
  leftIcon: null,
24
29
  rightIcon: null,
@@ -1,9 +1,13 @@
1
1
  import React, { useContext } from 'react';
2
+ import { useIntl } from 'react-intl';
2
3
  import DataTableContext from './DataTableContext';
3
4
  import Pagination from '../Pagination';
4
5
  import { ArrowBackIos, ArrowForwardIos } from '../../icons';
6
+ import messages from './messages';
5
7
 
6
8
  function TablePaginationMinimal() {
9
+ const intl = useIntl();
10
+
7
11
  const {
8
12
  nextPage, pageCount, gotoPage, state,
9
13
  } = useContext(DataTableContext);
@@ -20,7 +24,7 @@ function TablePaginationMinimal() {
20
24
  variant="minimal"
21
25
  currentPage={pageIndex + 1}
22
26
  pageCount={pageCount}
23
- paginationLabel="table pagination"
27
+ paginationLabel={intl.formatMessage(messages.paginationLabel)}
24
28
  onPageSelect={(pageNum) => gotoPage(pageNum - 1)}
25
29
  icons={{
26
30
  leftIcon: ArrowBackIos,
@@ -0,0 +1,11 @@
1
+ import { defineMessages } from 'react-intl';
2
+
3
+ const messages = defineMessages({
4
+ paginationLabel: {
5
+ id: 'pgn.DataTable.paginationLabel',
6
+ defaultMessage: 'table pagination',
7
+ description: 'Accessibile name for the navigation element of a pagination component',
8
+ },
9
+ });
10
+
11
+ export default messages;
@@ -32,7 +32,11 @@ describe('<TableFooter />', () => {
32
32
  it('Renders the default footer', () => {
33
33
  render(<TableFooterWrapper />);
34
34
  expect(screen.getByTestId('row-status')).toBeInTheDocument();
35
- expect(screen.getByLabelText('table pagination')).toBeInTheDocument();
35
+
36
+ // The TableFooter contains two components that have the aria-label
37
+ // "table pagination" - DataTable and DataTableMinimal.
38
+ const tables = screen.getAllByLabelText('table pagination');
39
+ tables.forEach(table => expect(table).toBeInTheDocument());
36
40
  });
37
41
 
38
42
  it('accepts a class name', () => {
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { render, act, screen } from '@testing-library/react';
3
+ import { IntlProvider } from 'react-intl';
3
4
  import userEvent from '@testing-library/user-event';
4
5
 
5
6
  import TablePagination from '../TablePagination';
@@ -14,9 +15,11 @@ const instance = {
14
15
  // eslint-disable-next-line react/prop-types
15
16
  function PaginationWrapper({ value }) {
16
17
  return (
17
- <DataTableContext.Provider value={value}>
18
- <TablePagination />
19
- </DataTableContext.Provider>
18
+ <IntlProvider>
19
+ <DataTableContext.Provider value={value}>
20
+ <TablePagination />
21
+ </DataTableContext.Provider>
22
+ </IntlProvider>
20
23
  );
21
24
  }
22
25
 
@@ -1,12 +1,12 @@
1
- import React from 'react';
1
+ import { IntlProvider } from 'react-intl';
2
2
  import { render } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
4
 
5
- import Hyperlink from '.';
5
+ import Hyperlink, { HyperlinkProps } from '.';
6
6
 
7
- const destination = 'destination';
7
+ const destination = 'http://destination.example';
8
8
  const content = 'content';
9
- const onClick = jest.fn();
9
+ const onClick = jest.fn().mockImplementation((e) => e.preventDefault());
10
10
  const props = {
11
11
  destination,
12
12
  onClick,
@@ -20,13 +20,37 @@ const externalLinkProps = {
20
20
  ...props,
21
21
  };
22
22
 
23
+ interface LinkProps extends HyperlinkProps {
24
+ to: string;
25
+ }
26
+
27
+ function Link({ to, children, ...rest }: LinkProps) {
28
+ return (
29
+ <a
30
+ data-testid="custom-hyperlink-element"
31
+ href={to}
32
+ {...rest}
33
+ >
34
+ {children}
35
+ </a>
36
+ );
37
+ }
38
+
39
+ function HyperlinkWrapper({ children, ...rest }: HyperlinkProps) {
40
+ return (
41
+ <IntlProvider locale="en">
42
+ <Hyperlink {...rest}>{children}</Hyperlink>
43
+ </IntlProvider>
44
+ );
45
+ }
46
+
23
47
  describe('correct rendering', () => {
24
48
  beforeEach(() => {
25
- onClick.mockClear();
49
+ jest.clearAllMocks();
26
50
  });
27
51
 
28
52
  it('renders Hyperlink', async () => {
29
- const { getByRole } = render(<Hyperlink {...props}>{content}</Hyperlink>);
53
+ const { getByRole } = render(<HyperlinkWrapper {...props}>{content}</HyperlinkWrapper>);
30
54
  const wrapper = getByRole('link');
31
55
  expect(wrapper).toBeInTheDocument();
32
56
 
@@ -36,12 +60,29 @@ describe('correct rendering', () => {
36
60
  expect(wrapper).toHaveAttribute('href', destination);
37
61
  expect(wrapper).toHaveAttribute('target', '_self');
38
62
 
63
+ // Clicking on the link should call the onClick handler
39
64
  await userEvent.click(wrapper);
40
65
  expect(onClick).toHaveBeenCalledTimes(1);
41
66
  });
42
67
 
68
+ it('renders with custom element type via "as" prop', () => {
69
+ const propsWithoutDestination = {
70
+ to: destination, // `to` simulates common `Link` components' prop
71
+ };
72
+ const { getByRole } = render(<HyperlinkWrapper as={Link} {...propsWithoutDestination}>{content}</HyperlinkWrapper>);
73
+ const wrapper = getByRole('link');
74
+ expect(wrapper).toBeInTheDocument();
75
+
76
+ expect(wrapper).toHaveClass('pgn__hyperlink');
77
+ expect(wrapper).toHaveClass('standalone-link');
78
+ expect(wrapper).toHaveTextContent(content);
79
+ expect(wrapper).toHaveAttribute('href', destination);
80
+ expect(wrapper).toHaveAttribute('target', '_self');
81
+ expect(wrapper).toHaveAttribute('data-testid', 'custom-hyperlink-element');
82
+ });
83
+
43
84
  it('renders an underlined Hyperlink', async () => {
44
- const { getByRole } = render(<Hyperlink isInline {...props}>{content}</Hyperlink>);
85
+ const { getByRole } = render(<HyperlinkWrapper isInline {...props}>{content}</HyperlinkWrapper>);
45
86
  const wrapper = getByRole('link');
46
87
  expect(wrapper).toBeInTheDocument();
47
88
  expect(wrapper).toHaveClass('pgn__hyperlink');
@@ -50,7 +91,7 @@ describe('correct rendering', () => {
50
91
  });
51
92
 
52
93
  it('renders external Hyperlink', () => {
53
- const { getByRole, getByTestId } = render(<Hyperlink {...externalLinkProps}>{content}</Hyperlink>);
94
+ const { getByRole, getByTestId } = render(<HyperlinkWrapper {...externalLinkProps}>{content}</HyperlinkWrapper>);
54
95
  const wrapper = getByRole('link');
55
96
  const icon = getByTestId('hyperlink-icon');
56
97
  const iconSvg = icon.querySelector('svg');
@@ -66,19 +107,8 @@ describe('correct rendering', () => {
66
107
 
67
108
  describe('security', () => {
68
109
  it('prevents reverse tabnabbing for links with target="_blank"', () => {
69
- const { getByRole } = render(<Hyperlink {...externalLinkProps}>{content}</Hyperlink>);
110
+ const { getByRole } = render(<HyperlinkWrapper {...externalLinkProps}>{content}</HyperlinkWrapper>);
70
111
  const wrapper = getByRole('link');
71
112
  expect(wrapper).toHaveAttribute('rel', 'noopener noreferrer');
72
113
  });
73
114
  });
74
-
75
- describe('event handlers are triggered correctly', () => {
76
- it('should fire onClick', async () => {
77
- const spy = jest.fn();
78
- const { getByRole } = render(<Hyperlink {...props} onClick={spy}>{content}</Hyperlink>);
79
- const wrapper = getByRole('link');
80
- expect(spy).toHaveBeenCalledTimes(0);
81
- await userEvent.click(wrapper);
82
- expect(spy).toHaveBeenCalledTimes(1);
83
- });
84
- });
@@ -7,7 +7,7 @@ categories:
7
7
  - Buttonlike
8
8
  status: 'Needs Work'
9
9
  designStatus: 'Done'
10
- devStatus: 'To Do'
10
+ devStatus: 'Done'
11
11
  notes: |
12
12
  Improve prop naming. Deprecate content prop.
13
13
  Use React.forwardRef for ref forwarding.
@@ -100,3 +100,16 @@ notes: |
100
100
  </div>
101
101
  </div>
102
102
  ```
103
+
104
+ ## with custom link element (e.g., using a router)
105
+
106
+ ``Hyperlink`` typically relies on the standard HTML anchor tag (i.e., ``a``); however, this behavior may be overriden when the destination link is to an internal route where it should be using routing instead (e.g., ``Link`` from React Router).
107
+
108
+ ```jsx live
109
+ <Hyperlink
110
+ as={GatsbyLink}
111
+ to="/components/button"
112
+ >
113
+ Button
114
+ </Hyperlink>
115
+ ```
@@ -1,15 +1,19 @@
1
- import React from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
+ import {
5
+ type BsPrefixRefForwardingComponent as ComponentWithAsProp,
6
+ type BsPrefixProps,
7
+ } from 'react-bootstrap/esm/helpers';
8
+ import { defineMessages, useIntl } from 'react-intl';
4
9
  import { Launch } from '../../icons';
5
10
  import Icon from '../Icon';
11
+ // @ts-ignore
12
+ import { customPropTypeRequirement } from '../utils/propTypes/utils';
6
13
 
7
- export const HYPER_LINK_EXTERNAL_LINK_ALT_TEXT = 'in a new tab';
8
- export const HYPER_LINK_EXTERNAL_LINK_TITLE = 'Opens in a new tab';
9
-
10
- interface Props extends Omit<React.ComponentPropsWithRef<'a'>, 'href' | 'target'> {
14
+ export interface HyperlinkProps extends BsPrefixProps, Omit<React.ComponentPropsWithRef<'a'>, 'href' | 'target'> {
11
15
  /** specifies the URL */
12
- destination: string;
16
+ destination?: string;
13
17
  /** Content of the hyperlink */
14
18
  children: React.ReactNode;
15
19
  /** Custom class names for the hyperlink */
@@ -24,22 +28,42 @@ interface Props extends Omit<React.ComponentPropsWithRef<'a'>, 'href' | 'target'
24
28
  isInline?: boolean;
25
29
  /** specify if we need to show launch Icon. By default, it will be visible. */
26
30
  showLaunchIcon?: boolean;
31
+ /** specifies where the link should open. The default behavior is `_self`, which means that the URL will be
32
+ * loaded into the same browsing context as the current one.
33
+ * If the target is `_blank` (opening a new window) `rel='noopener'` will be added to the anchor tag to prevent
34
+ * any potential [reverse tabnabbing attack](https://www.owasp.org/index.php/Reverse_Tabnabbing).
35
+ */
27
36
  target?: '_blank' | '_self';
28
37
  }
29
38
 
30
- const Hyperlink = React.forwardRef<HTMLAnchorElement, Props>(({
39
+ export type HyperlinkType = ComponentWithAsProp<'a', HyperlinkProps>;
40
+
41
+ const messages = defineMessages({
42
+ externalLinkAltText: {
43
+ id: 'Hyperlink.externalLinkAltText',
44
+ defaultMessage: 'in a new tab',
45
+ },
46
+ externalLinkTitle: {
47
+ id: 'Hyperlink.externalLinkTitle',
48
+ defaultMessage: 'Opens in a new tab',
49
+ },
50
+ });
51
+
52
+ const Hyperlink = forwardRef<HTMLAnchorElement, HyperlinkProps>(({
53
+ as: Component = 'a',
31
54
  className,
32
55
  destination,
33
56
  children,
34
- target,
57
+ target = '_self',
35
58
  onClick,
36
59
  externalLinkAlternativeText,
37
60
  externalLinkTitle,
38
- variant,
39
- isInline,
40
- showLaunchIcon,
61
+ variant = 'default',
62
+ isInline = false,
63
+ showLaunchIcon = true,
41
64
  ...attrs
42
65
  }, ref) => {
66
+ const intl = useIntl();
43
67
  let externalLinkIcon;
44
68
 
45
69
  if (target === '_blank') {
@@ -63,11 +87,11 @@ const Hyperlink = React.forwardRef<HTMLAnchorElement, Props>(({
63
87
  externalLinkIcon = (
64
88
  <span
65
89
  className="pgn__hyperlink__external-icon"
66
- title={externalLinkTitle}
90
+ title={externalLinkTitle || intl.formatMessage(messages.externalLinkTitle)}
67
91
  >
68
92
  <Icon
69
93
  src={Launch}
70
- screenReaderText={externalLinkAlternativeText}
94
+ screenReaderText={externalLinkAlternativeText || intl.formatMessage(messages.externalLinkAltText)}
71
95
  style={{ height: '1em', width: '1em' }}
72
96
  data-testid="hyperlink-icon"
73
97
  />
@@ -76,8 +100,13 @@ const Hyperlink = React.forwardRef<HTMLAnchorElement, Props>(({
76
100
  }
77
101
  }
78
102
 
103
+ const additionalProps: Record<string, any> = { ...attrs };
104
+ if (destination) {
105
+ additionalProps.href = destination;
106
+ }
107
+
79
108
  return (
80
- <a
109
+ <Component
81
110
  ref={ref}
82
111
  className={classNames(
83
112
  'pgn__hyperlink',
@@ -88,31 +117,27 @@ const Hyperlink = React.forwardRef<HTMLAnchorElement, Props>(({
88
117
  },
89
118
  className,
90
119
  )}
91
- href={destination}
92
120
  target={target}
93
121
  onClick={onClick}
94
- {...attrs}
122
+ {...additionalProps}
95
123
  >
96
124
  {children}
97
125
  {externalLinkIcon}
98
- </a>
126
+ </Component>
99
127
  );
100
128
  });
101
129
 
102
- Hyperlink.defaultProps = {
103
- className: undefined,
104
- target: '_self',
105
- onClick: () => {},
106
- externalLinkAlternativeText: HYPER_LINK_EXTERNAL_LINK_ALT_TEXT,
107
- externalLinkTitle: HYPER_LINK_EXTERNAL_LINK_TITLE,
108
- variant: 'default',
109
- isInline: false,
110
- showLaunchIcon: true,
111
- };
112
-
113
130
  Hyperlink.propTypes = {
114
- /** specifies the URL */
115
- destination: PropTypes.string.isRequired,
131
+ /** specifies the component element type to render for the hyperlink */
132
+ // @ts-ignore
133
+ as: PropTypes.elementType,
134
+ /** specifies the URL; required iff `as` prop is a standard anchor tag */
135
+ destination: customPropTypeRequirement(
136
+ PropTypes.string,
137
+ ({ as }: { as: React.ElementType }) => as && as === 'a',
138
+ // "[`destination` is required when]..."
139
+ 'the `as` prop is a standard anchor element (i.e., "a")',
140
+ ),
116
141
  /** Content of the hyperlink */
117
142
  // @ts-ignore
118
143
  children: PropTypes.node.isRequired,
@@ -138,4 +163,19 @@ Hyperlink.propTypes = {
138
163
  showLaunchIcon: PropTypes.bool,
139
164
  };
140
165
 
166
+ Hyperlink.defaultProps = {
167
+ as: 'a',
168
+ className: undefined,
169
+ destination: undefined,
170
+ externalLinkAlternativeText: undefined,
171
+ externalLinkTitle: undefined,
172
+ isInline: false,
173
+ onClick: undefined,
174
+ showLaunchIcon: true,
175
+ target: '_self',
176
+ variant: 'default',
177
+ };
178
+
179
+ Hyperlink.displayName = 'Hyperlink';
180
+
141
181
  export default Hyperlink;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { render } from '@testing-library/react';
3
+ import { IntlProvider } from 'react-intl';
3
4
 
4
5
  import MailtoLink from '.';
5
6
 
@@ -11,10 +12,18 @@ const content = 'content';
11
12
 
12
13
  const baseProps = { subject, body, content };
13
14
 
15
+ function MailtoLinkWrapper(props) {
16
+ return (
17
+ <IntlProvider locale="en">
18
+ <MailtoLink {...props} />
19
+ </IntlProvider>
20
+ );
21
+ }
22
+
14
23
  describe('correct rendering', () => {
15
24
  it('renders MailtoLink with single to, cc, and bcc recipient', () => {
16
25
  const singleRecipientLink = (
17
- <MailtoLink
26
+ <MailtoLinkWrapper
18
27
  {...baseProps}
19
28
  to={emailAddress}
20
29
  cc={emailAddress}
@@ -31,7 +40,7 @@ describe('correct rendering', () => {
31
40
 
32
41
  it('renders mailtoLink with many to, cc, and bcc recipients', () => {
33
42
  const multiRecipientLink = (
34
- <MailtoLink
43
+ <MailtoLinkWrapper
35
44
  {...baseProps}
36
45
  to={emailAddresses}
37
46
  cc={emailAddresses}
@@ -46,7 +55,7 @@ describe('correct rendering', () => {
46
55
  });
47
56
 
48
57
  it('renders empty mailtoLink', () => {
49
- const { getByText } = render(<MailtoLink content={content} />);
58
+ const { getByText } = render(<MailtoLinkWrapper content={content} />);
50
59
  const linkElement = getByText('content');
51
60
  expect(linkElement.getAttribute('href')).toEqual('mailto:');
52
61
  });
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { IntlProvider } from 'react-intl';
2
3
  import { render, screen } from '@testing-library/react';
3
4
  import renderer from 'react-test-renderer';
4
5
  import userEvent from '@testing-library/user-event';
@@ -20,15 +21,17 @@ describe('Menu Item renders correctly', () => {
20
21
 
21
22
  it('renders as expected with menu items', () => {
22
23
  const tree = renderer.create((
23
- <Menu>
24
- <MenuItem> A Menu Item</MenuItem>
25
- <MenuItem iconBefore={Add} stoven>A Menu Item With an Icon Before</MenuItem>
26
- <MenuItem iconAfter={Check}>A Menu Item With an Icon After </MenuItem>
27
- <MenuItem disabled>A Disabled Menu Item</MenuItem>
28
- <MenuItem as={Hyperlink} destination="https://en.wikipedia.org/wiki/Hyperlink">A Link Menu Item</MenuItem>
29
- <MenuItem as={Button} variant="primary" size="inline">A Button Menu Item</MenuItem>
30
- <MenuItem as={Form.Checkbox}>A Checkbox Menu Item</MenuItem>
31
- </Menu>
24
+ <IntlProvider locale="en">
25
+ <Menu>
26
+ <MenuItem> A Menu Item</MenuItem>
27
+ <MenuItem iconBefore={Add} stoven>A Menu Item With an Icon Before</MenuItem>
28
+ <MenuItem iconAfter={Check}>A Menu Item With an Icon After </MenuItem>
29
+ <MenuItem disabled>A Disabled Menu Item</MenuItem>
30
+ <MenuItem as={Hyperlink} destination="https://en.wikipedia.org/wiki/Hyperlink">A Link Menu Item</MenuItem>
31
+ <MenuItem as={Button} variant="primary" size="inline">A Button Menu Item</MenuItem>
32
+ <MenuItem as={Form.Checkbox}>A Checkbox Menu Item</MenuItem>
33
+ </Menu>
34
+ </IntlProvider>
32
35
  )).toJSON();
33
36
  expect(tree).toMatchSnapshot();
34
37
  });
@@ -1,4 +1,6 @@
1
1
  import React from 'react';
2
+ import { IntlProvider } from 'react-intl';
3
+ import PropTypes from 'prop-types';
2
4
  import { render, screen } from '@testing-library/react';
3
5
  import renderer from 'react-test-renderer';
4
6
  import userEvent from '@testing-library/user-event';
@@ -10,27 +12,44 @@ import Hyperlink from '../Hyperlink';
10
12
  const app = document.createElement('div');
11
13
  document.body.appendChild(app);
12
14
 
15
+ function SelectMenuWrapper({ children }) {
16
+ return (
17
+ <IntlProvider locale="en">
18
+ {children}
19
+ </IntlProvider>
20
+ );
21
+ }
22
+ SelectMenuWrapper.propTypes = {
23
+ children: PropTypes.node.isRequired,
24
+ };
25
+
13
26
  function DefaultSelectMenu(props) {
14
- return <SelectMenu {...props}><MenuItem>A Menu Item</MenuItem></SelectMenu>;
27
+ return (
28
+ <SelectMenuWrapper>
29
+ <SelectMenu {...props}><MenuItem>A Menu Item</MenuItem></SelectMenu>
30
+ </SelectMenuWrapper>
31
+ );
15
32
  }
16
33
 
17
34
  function defaultSelectMenu() {
18
35
  return (
19
- <SelectMenu>
20
- <MenuItem>A Menu Item</MenuItem>
21
- <MenuItem iconBefore={Add}>A Menu Item With an Icon Before</MenuItem>
22
- <MenuItem iconAfter={Check}>A Menu Item With an Icon After </MenuItem>
23
- <MenuItem disabled>A Disabled Menu Item</MenuItem>
24
- <MenuItem as={Hyperlink} destination="https://en.wikipedia.org/wiki/Hyperlink">A Link Menu Item</MenuItem>
25
- <MenuItem>Falstaff</MenuItem>
26
- <MenuItem>Scipio</MenuItem>
27
- <MenuItem>Faustus</MenuItem>
28
- <MenuItem>Cordelia</MenuItem>
29
- <MenuItem>Renfrancine</MenuItem>
30
- <MenuItem>Stovern</MenuItem>
31
- <MenuItem>Kainian</MenuItem>
32
- <MenuItem>M. Hortens</MenuItem>
33
- </SelectMenu>
36
+ <SelectMenuWrapper>
37
+ <SelectMenu>
38
+ <MenuItem>A Menu Item</MenuItem>
39
+ <MenuItem iconBefore={Add}>A Menu Item With an Icon Before</MenuItem>
40
+ <MenuItem iconAfter={Check}>A Menu Item With an Icon After </MenuItem>
41
+ <MenuItem disabled>A Disabled Menu Item</MenuItem>
42
+ <MenuItem as={Hyperlink} destination="https://en.wikipedia.org/wiki/Hyperlink">A Link Menu Item</MenuItem>
43
+ <MenuItem>Falstaff</MenuItem>
44
+ <MenuItem>Scipio</MenuItem>
45
+ <MenuItem>Faustus</MenuItem>
46
+ <MenuItem>Cordelia</MenuItem>
47
+ <MenuItem>Renfrancine</MenuItem>
48
+ <MenuItem>Stovern</MenuItem>
49
+ <MenuItem>Kainian</MenuItem>
50
+ <MenuItem>M. Hortens</MenuItem>
51
+ </SelectMenu>
52
+ </SelectMenuWrapper>
34
53
  );
35
54
  }
36
55
 
@@ -95,7 +95,6 @@ exports[`Menu Item renders correctly renders as expected with menu items 1`] = `
95
95
  <a
96
96
  className="pgn__hyperlink default-link standalone-link pgn__menu-item"
97
97
  href="https://en.wikipedia.org/wiki/Hyperlink"
98
- onClick={[Function]}
99
98
  target="_self"
100
99
  >
101
100
  <span
package/src/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export { default as Button, ButtonGroup, ButtonToolbar } from './Button';
9
9
  export { default as Chip, CHIP_PGN_CLASS } from './Chip';
10
10
  export { default as ChipCarousel } from './ChipCarousel';
11
11
  export { default as Container, ContainerSize } from './Container';
12
- export { default as Hyperlink, HYPER_LINK_EXTERNAL_LINK_ALT_TEXT, HYPER_LINK_EXTERNAL_LINK_TITLE } from './Hyperlink';
12
+ export { default as Hyperlink } from './Hyperlink';
13
13
  export { default as Icon } from './Icon';
14
14
  export { default as IconButton, IconButtonWithTooltip } from './IconButton';
15
15
  export { default as ModalContext } from './Modal/ModalContext';
package/src/index.js CHANGED
@@ -9,7 +9,7 @@ export { default as Button, ButtonGroup, ButtonToolbar } from './Button';
9
9
  export { default as Chip, CHIP_PGN_CLASS } from './Chip';
10
10
  export { default as ChipCarousel } from './ChipCarousel';
11
11
  export { default as Container } from './Container';
12
- export { default as Hyperlink, HYPER_LINK_EXTERNAL_LINK_ALT_TEXT, HYPER_LINK_EXTERNAL_LINK_TITLE } from './Hyperlink';
12
+ export { default as Hyperlink } from './Hyperlink';
13
13
  export { default as Icon } from './Icon';
14
14
  export { default as IconButton, IconButtonWithTooltip } from './IconButton';
15
15
  export { default as ModalContext } from './Modal/ModalContext';