@jpmorganchase/mosaic-components 0.1.0-beta.71 → 0.1.0-beta.73

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 (192) hide show
  1. package/package.json +8 -5
  2. package/.turbo/turbo-build.log +0 -4
  3. package/CHANGELOG.md +0 -686
  4. package/src/Accordion/__tests__/index.test.tsx +0 -82
  5. package/src/Accordion/index.tsx +0 -88
  6. package/src/Accordion/styles.css.ts +0 -16
  7. package/src/AudioPlayer/__tests__/index.test.tsx +0 -19
  8. package/src/AudioPlayer/index.tsx +0 -163
  9. package/src/AudioPlayer/styles.css.ts +0 -65
  10. package/src/BrowserOnly.tsx +0 -17
  11. package/src/Button.tsx +0 -25
  12. package/src/Callout/__tests__/index.test.tsx +0 -102
  13. package/src/Callout/index.tsx +0 -62
  14. package/src/Callout/styles.css.ts +0 -77
  15. package/src/Card/index.tsx +0 -35
  16. package/src/Card/styles.css.ts +0 -23
  17. package/src/Cards.tsx +0 -25
  18. package/src/ComponentExample/index.tsx +0 -23
  19. package/src/ComponentExample/styles.css.ts +0 -25
  20. package/src/DataTable.tsx +0 -114
  21. package/src/EditionFilterView/__tests__/index.test.tsx +0 -49
  22. package/src/EditionFilterView/index.tsx +0 -108
  23. package/src/EditionFilterView/styles.css.ts +0 -8
  24. package/src/EditionTileLink/index.tsx +0 -90
  25. package/src/EditionTileLink/styles.css.ts +0 -95
  26. package/src/Feature/Feature.tsx +0 -92
  27. package/src/Feature/FeatureActions/index.tsx +0 -34
  28. package/src/Feature/FeatureActions/styles.css.ts +0 -15
  29. package/src/Feature/FeatureContent/index.tsx +0 -30
  30. package/src/Feature/FeatureContent/styles.css.ts +0 -13
  31. package/src/Feature/FeatureEyebrow/index.tsx +0 -19
  32. package/src/Feature/FeatureEyebrow/styles.css.ts +0 -11
  33. package/src/Feature/FeatureTitle/index.tsx +0 -18
  34. package/src/Feature/FeatureTitle/styles.css.ts +0 -9
  35. package/src/Feature/index.tsx +0 -10
  36. package/src/Feature/styles.css.ts +0 -58
  37. package/src/Features/index.tsx +0 -33
  38. package/src/Features/styles.css.ts +0 -10
  39. package/src/FilterToolbar/ContentArea/index.tsx +0 -12
  40. package/src/FilterToolbar/ContentArea/styles.css.ts +0 -16
  41. package/src/FilterToolbar/FilterDropdown/__tests__/index.test.tsx +0 -22
  42. package/src/FilterToolbar/FilterDropdown/index.tsx +0 -62
  43. package/src/FilterToolbar/FilterDropdown/styles.css.ts +0 -16
  44. package/src/FilterToolbar/PillGroup/__tests__/index.test.tsx +0 -26
  45. package/src/FilterToolbar/PillGroup/index.tsx +0 -36
  46. package/src/FilterToolbar/PillGroup/styles.css.ts +0 -17
  47. package/src/FilterToolbar/Search/__tests__/index.test.tsx +0 -34
  48. package/src/FilterToolbar/Search/index.tsx +0 -33
  49. package/src/FilterToolbar/Search/styles.css.ts +0 -9
  50. package/src/FilterToolbar/SortDropdown/__tests__/index.test.tsx +0 -22
  51. package/src/FilterToolbar/SortDropdown/defaultSort.js +0 -8
  52. package/src/FilterToolbar/SortDropdown/index.tsx +0 -53
  53. package/src/FilterToolbar/SortDropdown/styles.css.ts +0 -15
  54. package/src/FilterToolbar/Toolbar.tsx +0 -38
  55. package/src/FilterToolbar/ToolbarProvider.tsx +0 -94
  56. package/src/FilterToolbar/__tests__/Toolbar.test.tsx +0 -127
  57. package/src/FilterToolbar/__tests__/ToolbarProvider.test.tsx +0 -85
  58. package/src/FilterToolbar/index.tsx +0 -9
  59. package/src/FilterToolbar/styles.css.ts +0 -19
  60. package/src/FilterView/ContentArea/index.tsx +0 -24
  61. package/src/FilterView/ContentArea/styles.css.ts +0 -16
  62. package/src/FilterView/FilterView.tsx +0 -205
  63. package/src/FilterView/FilterViewProvider.tsx +0 -23
  64. package/src/FilterView/NoResults/index.tsx +0 -19
  65. package/src/FilterView/NoResults/styles.css.ts +0 -13
  66. package/src/FilterView/Pagination/index.tsx +0 -40
  67. package/src/FilterView/Pagination/styles.css.ts +0 -40
  68. package/src/FilterView/Pagination/usePagination.ts +0 -31
  69. package/src/FilterView/ResultCount/index.tsx +0 -23
  70. package/src/FilterView/ResultCount/styles.css.ts +0 -11
  71. package/src/FilterView/__tests__/index.test.tsx +0 -109
  72. package/src/FilterView/index.tsx +0 -5
  73. package/src/FilterView/useResultCount.tsx +0 -8
  74. package/src/FormattedContent.tsx +0 -75
  75. package/src/Grid/index.tsx +0 -29
  76. package/src/Grid/styles.css.ts +0 -13
  77. package/src/GridBase/index.tsx +0 -60
  78. package/src/GridBase/styles.css.ts +0 -19
  79. package/src/HelpLinks/index.tsx +0 -80
  80. package/src/HelpLinks/styles.css.ts +0 -32
  81. package/src/Hero/__tests__/index.test.tsx +0 -19
  82. package/src/Hero/index.tsx +0 -172
  83. package/src/Hero/styles.css.ts +0 -111
  84. package/src/Icon/index.tsx +0 -50
  85. package/src/ImageProvider.ts +0 -9
  86. package/src/Impact/index.tsx +0 -36
  87. package/src/Impact/styles.css.ts +0 -72
  88. package/src/Impacts.tsx +0 -25
  89. package/src/IsomorphicSuspense.tsx +0 -9
  90. package/src/Label/__tests__/index.test.tsx +0 -27
  91. package/src/Label/index.tsx +0 -42
  92. package/src/Label/styles.css.ts +0 -14
  93. package/src/Link/index.tsx +0 -83
  94. package/src/Link/styles.css.ts +0 -15
  95. package/src/LinkBase/index.tsx +0 -32
  96. package/src/LinkButton.css.ts +0 -19
  97. package/src/LinkButton.tsx +0 -22
  98. package/src/LinkProvider.ts +0 -9
  99. package/src/LinkText/index.tsx +0 -121
  100. package/src/LinkText/styles.css.ts +0 -30
  101. package/src/Links/index.tsx +0 -18
  102. package/src/Links/styles.css.ts +0 -13
  103. package/src/List/ListItem.tsx +0 -31
  104. package/src/List/OrderedList.tsx +0 -22
  105. package/src/List/UnorderedList.tsx +0 -35
  106. package/src/List/index.tsx +0 -3
  107. package/src/Markdown/AnchorHeading/__tests__/index.test.tsx +0 -56
  108. package/src/Markdown/AnchorHeading/index.css.ts +0 -64
  109. package/src/Markdown/AnchorHeading/index.tsx +0 -97
  110. package/src/Markdown/BlockQuote/index.css.ts +0 -6
  111. package/src/Markdown/BlockQuote/index.tsx +0 -21
  112. package/src/Markdown/Heading.tsx +0 -39
  113. package/src/Markdown/InlineCode.tsx +0 -10
  114. package/src/Markdown/Link.tsx +0 -11
  115. package/src/Markdown/Pre/index.css.ts +0 -35
  116. package/src/Markdown/Pre/index.tsx +0 -155
  117. package/src/Markdown/Table.tsx +0 -11
  118. package/src/Markdown/Tbody.tsx +0 -9
  119. package/src/Markdown/Td.tsx +0 -9
  120. package/src/Markdown/Th.tsx +0 -9
  121. package/src/Markdown/Thead.tsx +0 -9
  122. package/src/Markdown/ThematicBreak/index.css.ts +0 -5
  123. package/src/Markdown/ThematicBreak/index.tsx +0 -10
  124. package/src/Markdown/Tr.tsx +0 -9
  125. package/src/Markdown/__tests__/Heading.test.tsx +0 -56
  126. package/src/Markdown/index.tsx +0 -210
  127. package/src/Markdown/markdownElements.tsx +0 -52
  128. package/src/Markdown/withMarkdownSpacing/index.tsx +0 -33
  129. package/src/Markdown/withMarkdownSpacing/styles.css.ts +0 -7
  130. package/src/PageFilterView/index.tsx +0 -86
  131. package/src/PageFilterView/styles.css.ts +0 -8
  132. package/src/ReactLive/index.tsx +0 -71
  133. package/src/ReactLive/styles.css.ts +0 -28
  134. package/src/SecondaryNavbar/index.tsx +0 -55
  135. package/src/SecondaryNavbar/styles.css.ts +0 -27
  136. package/src/SectionHeading/__tests__/index.test.tsx +0 -20
  137. package/src/SectionHeading/index.tsx +0 -33
  138. package/src/SectionHeading/styles.css.ts +0 -15
  139. package/src/StickyHeader/index.tsx +0 -52
  140. package/src/StickyHeader/styles.css.ts +0 -17
  141. package/src/Story/index.tsx +0 -70
  142. package/src/Story/styles.css.ts +0 -37
  143. package/src/Tabs/index.tsx +0 -65
  144. package/src/Tabs/styles.css.ts +0 -7
  145. package/src/TabsBase/TabsBase.tsx +0 -89
  146. package/src/TabsBase/TabsButton.tsx +0 -30
  147. package/src/TabsBase/TabsLink.tsx +0 -30
  148. package/src/TabsBase/TabsMenuButton.tsx +0 -41
  149. package/src/TabsBase/index.ts +0 -4
  150. package/src/TabsBase/styles.css.ts +0 -64
  151. package/src/TabsBase/tabsMenuButton.css.ts +0 -25
  152. package/src/Tag/__tests__/index.test.tsx +0 -58
  153. package/src/Tag/index.tsx +0 -62
  154. package/src/Tag/styles.css.ts +0 -48
  155. package/src/ThemeProvider.tsx +0 -37
  156. package/src/TileBase/TileBase.tsx +0 -159
  157. package/src/TileBase/TileStateProvider.tsx +0 -52
  158. package/src/TileBase/index.ts +0 -2
  159. package/src/TileBase/styles.css.ts +0 -15
  160. package/src/TileButton/index.tsx +0 -68
  161. package/src/TileContent/index.tsx +0 -155
  162. package/src/TileContent/styles.css.ts +0 -229
  163. package/src/TileContentLabel/index.tsx +0 -74
  164. package/src/TileContentLabel/styles.css.ts +0 -22
  165. package/src/TileLink/index.tsx +0 -83
  166. package/src/TileLink/styles.css.ts +0 -9
  167. package/src/Tiles.tsx +0 -17
  168. package/src/Typography/Typography.tsx +0 -22
  169. package/src/Typography/index.tsx +0 -54
  170. package/src/Typography/withStyledTypography.tsx +0 -25
  171. package/src/VideoPlayer/__tests__/index.test.tsx +0 -13
  172. package/src/VideoPlayer/index.tsx +0 -179
  173. package/src/VideoPlayer/styles.css.ts +0 -87
  174. package/src/ViewStack/View.tsx +0 -19
  175. package/src/ViewStack/ViewStack.tsx +0 -50
  176. package/src/ViewStack/__tests__/index.test.tsx +0 -86
  177. package/src/ViewStack/index.tsx +0 -2
  178. package/src/__tests__/Button.test.tsx +0 -13
  179. package/src/__tests__/LinkButton.test.tsx +0 -16
  180. package/src/__tests__/ReactLive.test.tsx +0 -21
  181. package/src/canUseDOM.ts +0 -5
  182. package/src/common/types/index.ts +0 -52
  183. package/src/index.tsx +0 -59
  184. package/src/styles.ts +0 -45
  185. package/src/useBreakpoint.ts +0 -28
  186. package/src/useLockBodyScroll.ts +0 -16
  187. package/src/useOutsideClick.ts +0 -25
  188. package/src/useSize.ts +0 -32
  189. package/src/useSpacing.ts +0 -17
  190. package/src/utils/hasProtocol.ts +0 -1
  191. package/src/utils/index.ts +0 -1
  192. package/tsconfig.json +0 -8
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
-
3
- export function IsomorphicSuspense({ children, fallback }) {
4
- if (typeof window === 'undefined') {
5
- return fallback;
6
- }
7
-
8
- return <React.Suspense fallback={fallback}>{children}</React.Suspense>;
9
- }
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
- import { fireEvent, render, screen } from '@testing-library/react';
3
- import { Label } from '../index';
4
-
5
- describe('GIVEN a Label with no tooltip', () =>
6
- it('THEN it should render as a label', () => {
7
- // arrange
8
- render(<Label>My Label</Label>);
9
-
10
- // assert
11
- expect(screen.getByText('My Label')).toBeInTheDocument();
12
- }));
13
-
14
- describe('GIVEN a Label with a tooltip', () =>
15
- it('THEN it should render as a label with a tooltip', () => {
16
- // arrange
17
- render(
18
- <Label aria-label="My Tooltip Label" tooltip="My Tooltip" TooltipProps={{ open: true }}>
19
- My Label
20
- </Label>
21
- );
22
-
23
- // assert
24
- expect(screen.getByText('My Label')).toBeInTheDocument();
25
- const label = screen.getByLabelText('My Tooltip Label');
26
- expect(screen.getByText('My Tooltip')).toBeInTheDocument();
27
- }));
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
- import { Tooltip, TooltipProps as SaltTooltipProps } from '@salt-ds/core';
3
-
4
- import styles from './styles.css';
5
-
6
- export interface LabelProps {
7
- /** The children components of the Tile component */
8
- children?: React.ReactNode;
9
- /** Additional class name for root class override */
10
- className?: string;
11
- /* Tooltip */
12
- tooltip?: React.ReactNode;
13
- /* Tooltip ClassName */
14
- tooltipClass?: string;
15
- /* Additional Tooltip Props */
16
- TooltipProps?: SaltTooltipProps | { title?: string };
17
- }
18
-
19
- export const Label: React.FC<LabelProps> = ({
20
- children,
21
- className,
22
- tooltip,
23
- tooltipClass,
24
- TooltipProps = {},
25
- ...rest
26
- }) => (
27
- <Tooltip
28
- disabled={!tooltip}
29
- {...TooltipProps}
30
- content={
31
- <div className={styles.tooltip}>
32
- {TooltipProps.title && <span className={styles.tooltipTitle}>{TooltipProps.title}</span>}
33
- <span className={styles.tooltipContent}>{tooltip}</span>
34
- </div>
35
- }
36
- status="info"
37
- >
38
- <span className={className} {...rest}>
39
- {children}
40
- </span>
41
- </Tooltip>
42
- );
@@ -1,14 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { paragraph } from '@jpmorganchase/mosaic-theme';
3
- import { backgroundColor } from '@jpmorganchase/mosaic-theme';
4
-
5
- export default {
6
- tooltip: style([
7
- {
8
- display: 'block'
9
- },
10
- backgroundColor({ variant: 'regular' })
11
- ]),
12
- tooltipTitle: style([paragraph({ variant: 'paragraph5' }), { display: 'block' }]),
13
- tooltipContent: style([paragraph({ variant: 'paragraph6' }), { display: 'block' }])
14
- };
@@ -1,83 +0,0 @@
1
- import React, { forwardRef, Ref } from 'react';
2
- import classnames from 'clsx';
3
-
4
- import { LinkBase, LinkBaseProps } from '../LinkBase';
5
- import { LinkText, LinkTextProps } from '../LinkText';
6
- import styles from './styles.css';
7
-
8
- export interface LinkProps extends LinkBaseProps, Omit<LinkTextProps, 'variant'> {
9
- LinkBaseProps?: LinkBaseProps;
10
- LinkTextProps?: LinkTextProps;
11
- /* Variant
12
- - `component` is a custom solution where you provide your own component that is wrapped by the link
13
- - `document` is a simple inline link text used by document content
14
- - `heading` is a simple inline link text used by document headings
15
- - `regular` is designed for link text for general use anywhere
16
- - `selectable` is designed for use in tabs and vertical navigation
17
- */
18
- variant?: 'component' | 'document' | 'heading' | 'regular' | 'selectable';
19
- }
20
-
21
- export const Link = forwardRef<HTMLLinkElement, LinkProps>((props, ref: Ref<HTMLLinkElement>) => {
22
- const {
23
- children,
24
- className,
25
- disabled,
26
- endIcon,
27
- hovered,
28
- link,
29
- href = link,
30
- LinkBaseProps: LinkBasePropsProp,
31
- LinkTextProps: LinkTextPropsProp,
32
- onClick,
33
- rel,
34
- startIcon,
35
- target,
36
- title,
37
- variant = 'regular',
38
- ...rest
39
- } = props;
40
-
41
- const linkTextProps = {
42
- children,
43
- disabled,
44
- endIcon,
45
- link,
46
- hovered,
47
- startIcon,
48
- ...LinkTextPropsProp
49
- };
50
- return (
51
- <LinkBase
52
- disabled={disabled}
53
- href={href}
54
- onClick={onClick}
55
- {...LinkBasePropsProp}
56
- className={classnames(
57
- styles.link,
58
- {
59
- [styles.inline]: variant === 'document',
60
- [styles.document]: variant === 'document',
61
- [styles.heading]: variant === 'heading',
62
- [styles.regular]: variant === 'regular',
63
- [styles.selectable]: variant === 'selectable'
64
- },
65
- LinkBasePropsProp?.className,
66
- className
67
- )}
68
- ref={ref}
69
- rel={rel}
70
- target={target}
71
- title={title}
72
- {...rest}
73
- >
74
- {variant === 'regular' || variant === 'document' ? (
75
- <LinkText variant={variant} {...linkTextProps}>
76
- {children}
77
- </LinkText>
78
- ) : (
79
- children
80
- )}
81
- </LinkBase>
82
- );
83
- });
@@ -1,15 +0,0 @@
1
- import { link } from '@jpmorganchase/mosaic-theme';
2
- import { style } from '@vanilla-extract/css';
3
-
4
- export default {
5
- link: style({
6
- display: 'block'
7
- }),
8
- inline: style({
9
- display: 'inline-block'
10
- }),
11
- document: link({ variant: 'document' }),
12
- heading: link({ variant: 'heading' }),
13
- regular: link({ variant: 'regular' }),
14
- selectable: link({ variant: 'selectable' })
15
- };
@@ -1,32 +0,0 @@
1
- import React, { forwardRef, Ref } from 'react';
2
-
3
- import { useLinkComponent } from '../LinkProvider';
4
- import { hasProtocol } from '../utils/hasProtocol';
5
-
6
- export interface LinkBaseProps extends Omit<React.HTMLProps<HTMLLinkElement>, 'ref'> {
7
- /** Children */
8
- children?: React.ReactNode;
9
- /** Additional class name for root class override */
10
- className?: string;
11
- }
12
-
13
- export const LinkBase = forwardRef<HTMLLinkElement, LinkBaseProps>(
14
- (props, ref: Ref<HTMLLinkElement>) => {
15
- const { children, href, ...rest } = props;
16
- const LinkComponent = useLinkComponent();
17
- const isInternal = !hasProtocol(href);
18
-
19
- return (
20
- <LinkComponent
21
- href={href}
22
- ref={ref}
23
- role="link"
24
- {...rest}
25
- target={!rest.target && !isInternal ? '_blank' : rest.target}
26
- rel={!rest.rel && !isInternal ? 'noopener noreferrer' : rest.rel}
27
- >
28
- {children}
29
- </LinkComponent>
30
- );
31
- }
32
- );
@@ -1,19 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { vars } from '@jpmorganchase/mosaic-theme';
3
-
4
- export default {
5
- root: style([
6
- {
7
- display: 'inline-flex',
8
- alignItems: 'center',
9
- justifyContent: 'center',
10
- letterSpacing: '0.6px',
11
- fontWeight: vars.fontWeight.bold,
12
- fontSize: vars.fontSize.s50,
13
- lineHeight: '1.5em',
14
- paddingLeft: vars.space.horizontal.x2,
15
- paddingRight: vars.space.horizontal.x2,
16
- height: vars.component.button.web.height
17
- }
18
- ])
19
- };
@@ -1,22 +0,0 @@
1
- import React, { FC } from 'react';
2
- import classnames from 'clsx';
3
- import { button as buttonStyles } from '@jpmorganchase/mosaic-theme';
4
-
5
- import styles from './LinkButton.css';
6
-
7
- export interface LinkButtonProps {
8
- href?: string /** href when component is a link */;
9
- className?: string;
10
- variant?: 'regular' | 'cta';
11
- }
12
-
13
- export const LinkButton: FC<React.PropsWithChildren<LinkButtonProps>> = ({
14
- className,
15
- children,
16
- variant = 'regular',
17
- ...rest
18
- }) => (
19
- <a className={classnames(buttonStyles({ variant }), styles.root, className)} {...rest}>
20
- {children}
21
- </a>
22
- );
@@ -1,9 +0,0 @@
1
- import { createContext, Context, ElementType, useContext } from 'react';
2
-
3
- export type LinkProviderValue = ElementType;
4
-
5
- const LinkContext: Context<LinkProviderValue> = createContext<LinkProviderValue>('a');
6
-
7
- export const useLinkComponent = (): ElementType => useContext(LinkContext);
8
-
9
- export const LinkProvider = LinkContext.Provider;
@@ -1,121 +0,0 @@
1
- import React, { forwardRef, isValidElement, ReactNode, Ref } from 'react';
2
- import classnames from 'clsx';
3
- import { Icon, IconProps } from '../Icon';
4
-
5
- import styles from './styles.css';
6
- import { hasProtocol } from '../utils/hasProtocol';
7
-
8
- type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
9
- export type LinkIconProps = PartialBy<IconProps, 'name'>;
10
-
11
- export interface LinkTextProps {
12
- /** Children */
13
- children?: React.ReactNode;
14
- /** Additional class name for root class override */
15
- className?: string;
16
- /** Disabled */
17
- disabled?: boolean;
18
- /* End Icon name */
19
- endIcon?: string;
20
- /* Additional End Icon Props */
21
- EndIconProps?: IconProps;
22
- /** hovered, used when the link's UI is controlled by another component's state */
23
- hovered?: boolean;
24
- /* Link URL */
25
- link?: string;
26
- /* Start Icon name */
27
- startIcon?: string;
28
- /* Additional Start Icon Props */
29
- StartIconProps?: IconProps;
30
- /* Variant
31
- - `regular` is designed for link text for use anywhere
32
- - `document` is a simpler link text used by documents
33
- */
34
- variant?: 'document' | 'regular';
35
- }
36
-
37
- function IconAdornment({ additionalProps, className, disabled, name = 'none' }) {
38
- if (name === 'none') {
39
- return null;
40
- }
41
- return (
42
- <Icon
43
- className={classnames(className, styles.icon, {
44
- [styles.disabled]: disabled
45
- })}
46
- name={name}
47
- {...additionalProps}
48
- />
49
- );
50
- }
51
-
52
- export const LinkText = forwardRef<HTMLSpanElement, LinkTextProps>(
53
- (props, ref: Ref<HTMLSpanElement>) => {
54
- const {
55
- children,
56
- className,
57
- disabled,
58
- endIcon,
59
- EndIconProps,
60
- hovered,
61
- link,
62
- startIcon = 'none',
63
- StartIconProps,
64
- variant = 'regular',
65
- ...rest
66
- } = props;
67
- const isInternal = !hasProtocol(link);
68
-
69
- // eslint-disable-next-line new-cap
70
- const startIconAdornment = IconAdornment({
71
- additionalProps: StartIconProps,
72
- disabled,
73
- name: startIcon,
74
- className: styles.icon
75
- });
76
-
77
- let defaultEndIconName;
78
- if (!isInternal) {
79
- defaultEndIconName = 'tearOut';
80
- } else {
81
- defaultEndIconName = variant === 'regular' ? 'chevronRight' : 'none';
82
- }
83
-
84
- const endIconName = endIcon || defaultEndIconName;
85
- // eslint-disable-next-line new-cap
86
- const endIconAdornment = IconAdornment({
87
- additionalProps: EndIconProps,
88
- disabled,
89
- name: endIconName,
90
- className: styles.icon
91
- });
92
-
93
- let enhancedChildren: ReactNode = null;
94
- const childrenClassName = classnames(className, styles.root, {
95
- [styles.document]: variant === 'document',
96
- [styles.regular]: variant === 'regular',
97
- [styles.disabled]: disabled
98
- });
99
- if (typeof children === 'string') {
100
- enhancedChildren = children;
101
- } else if (isValidElement(children)) {
102
- const child = React.Children.only(children) as React.ReactElement<{
103
- className: string;
104
- ref: Ref<HTMLSpanElement>;
105
- }>;
106
- enhancedChildren = React.cloneElement(child, {
107
- className: classnames(child.props.className, childrenClassName),
108
- ref
109
- });
110
- }
111
- return (
112
- <span className={classnames(className)} ref={ref} {...rest}>
113
- {startIconAdornment}
114
- <span className={childrenClassName} data-dp-hover={!disabled && hovered}>
115
- {enhancedChildren}
116
- </span>
117
- {endIconAdornment}
118
- </span>
119
- );
120
- }
121
- );
@@ -1,30 +0,0 @@
1
- import { link, responsiveSprinkles } from '@jpmorganchase/mosaic-theme';
2
- import { style, globalStyle } from '@vanilla-extract/css';
3
-
4
- const iconStyle = style([
5
- {
6
- color: 'inherit',
7
- stroke: 'currentColor',
8
- height: '1em'
9
- },
10
- responsiveSprinkles({
11
- paddingX: ['x1', 'x1', 'x1', 'x1']
12
- })
13
- ]);
14
-
15
- export default {
16
- root: style([
17
- {
18
- display: 'inline-block'
19
- }
20
- ]),
21
- document: link({ variant: 'document' }),
22
- regular: link({ variant: 'regular' }),
23
- disabled: style({}),
24
- icon: iconStyle
25
- };
26
-
27
- globalStyle(`${iconStyle} > svg.saltIcon`, {
28
- height: 'calc(1em - 3px)',
29
- minHeight: 'auto'
30
- });
@@ -1,18 +0,0 @@
1
- import React, { Children } from 'react';
2
- import classnames from 'clsx';
3
-
4
- import styles from './styles.css';
5
-
6
- export interface LinksProps {
7
- /* Link components */
8
- children: React.ReactElement;
9
- /* Root classname override */
10
- className?: string;
11
- }
12
-
13
- export const Links: React.FC<LinksProps> = ({ children, className }) => {
14
- if (Children.count(children) > 7) {
15
- throw new Error('You can only have a maximum of 8 links in the Links component.');
16
- }
17
- return <div className={classnames(styles.root, className)}>{children}</div>;
18
- };
@@ -1,13 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { responsiveSprinkles } from '@jpmorganchase/mosaic-theme';
3
-
4
- export default {
5
- root: style([
6
- {
7
- display: 'flex',
8
- flexDirection: 'column',
9
- flexWrap: 'wrap'
10
- },
11
- responsiveSprinkles({ rowGap: ['x4', 'x4', 'x4', 'x4'] })
12
- ])
13
- };
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
-
3
- import { UnOrderedListProps } from './UnorderedList';
4
- import { Size } from '../common/types';
5
-
6
- export interface ListItemProps extends Omit<React.HTMLProps<HTMLLIElement>, 'checked' | 'size'> {
7
- checked?: boolean | null;
8
- size?: Size;
9
- variant?: 'regular' | 'document' | 'image';
10
- }
11
-
12
- export const ListItem: React.FC<React.PropsWithChildren<ListItemProps>> = ({
13
- children,
14
- size = 'small',
15
- variant = 'document',
16
- ...rest
17
- }) => {
18
- const formattedText = React.Children.map(children, child => {
19
- if (!React.isValidElement(child)) {
20
- return child;
21
- }
22
- if (child.props.mdxType === 'ul') {
23
- return React.cloneElement(child as React.ReactElement<UnOrderedListProps>, {
24
- size,
25
- variant
26
- });
27
- }
28
- return child;
29
- });
30
- return <li {...rest}>{formattedText}</li>;
31
- };
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import classnames from 'clsx';
3
- import { orderedList, orderedListItem } from '@jpmorganchase/mosaic-theme';
4
-
5
- import { ListItemProps } from './ListItem';
6
-
7
- export interface OrderedListProps extends Omit<React.HTMLProps<HTMLUListElement>, 'size'> {}
8
-
9
- export const OrderedList: React.FC<React.PropsWithChildren<OrderedListProps>> = ({
10
- children,
11
- className
12
- }) => {
13
- const formattedChildren = React.Children.map(children, child => {
14
- if (!React.isValidElement(child)) {
15
- return child;
16
- }
17
- return React.cloneElement(child as React.ReactElement<ListItemProps>, {
18
- className: classnames(child.props.className, orderedListItem)
19
- });
20
- });
21
- return <ol className={classnames(className, orderedList)}>{formattedChildren}</ol>;
22
- };
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
- import classnames from 'clsx';
3
- import { unorderedList, unorderedListItem } from '@jpmorganchase/mosaic-theme';
4
-
5
- import { Size } from '../common/types';
6
- import { ListItemProps } from './ListItem';
7
-
8
- export interface UnOrderedListProps extends Omit<React.HTMLProps<HTMLUListElement>, 'size'> {
9
- size?: Size;
10
- variant?: 'regular' | 'document' | 'image';
11
- }
12
-
13
- export const UnorderedList: React.FC<React.PropsWithChildren<UnOrderedListProps>> = ({
14
- children,
15
- className,
16
- size = 'small',
17
- variant = 'document',
18
- ...rest
19
- }) => {
20
- const formattedChildren = React.Children.map(children, child => {
21
- if (!React.isValidElement(child)) {
22
- return child;
23
- }
24
- return React.cloneElement(child as React.ReactElement<ListItemProps>, {
25
- className: classnames(child.props.className, unorderedListItem({ size, variant })),
26
- size,
27
- variant
28
- });
29
- });
30
- return (
31
- <ul className={classnames(className, unorderedList({ size, variant }))} {...rest}>
32
- {formattedChildren}
33
- </ul>
34
- );
35
- };
@@ -1,3 +0,0 @@
1
- export * from './ListItem';
2
- export * from './OrderedList';
3
- export * from './UnorderedList';
@@ -1,56 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import userEvents from '@testing-library/user-event';
4
-
5
- import { withAnchorHeading } from '../index';
6
- import * as Heading from '../../Heading';
7
-
8
- describe('GIVEN an AnchoredHeading', () => {
9
- describe('WHEN rendered', () => {
10
- test('THEN the Heading is rendered', () => {
11
- // arrange
12
- const TestHeading = withAnchorHeading(Heading.H1);
13
- render(<TestHeading LinkProps={{ link: 'http://example.com' }}>Mosaic Heading</TestHeading>);
14
- // assert
15
- expect(screen.getByText('Mosaic Heading')).toBeInTheDocument();
16
- });
17
- });
18
- describe('WHEN clicked', () => {
19
- test('THEN the Heading is copied to the clipboard', async () => {
20
- // arrange
21
- let clipboardData = ''; // initalizing clipboard data so it can be used in testing
22
- const mockClipboard = {
23
- writeText: jest.fn(data => {
24
- clipboardData = data;
25
- }),
26
- readText: jest.fn(() => clipboardData)
27
- };
28
- (global.navigator as any).clipboard = mockClipboard;
29
-
30
- const TestHeading = withAnchorHeading(Heading.H1);
31
- render(
32
- <TestHeading LinkProps={{ link: 'http://example.com', title: 'Mosaic Title' }}>
33
- Mosaic Heading
34
- </TestHeading>
35
- );
36
- // assert
37
- expect(screen.queryByLabelText('copied anchor link to clipboard')).not.toBeInTheDocument();
38
- expect(
39
- screen.queryByLabelText('click to copy anchor link to clipboard')
40
- ).not.toBeInTheDocument();
41
- expect(screen.queryByText('Mosaic Heading')).toBeInTheDocument();
42
- // act
43
- await userEvents.hover(screen.getByTitle('Mosaic Title'));
44
- // assert
45
- expect(screen.queryByLabelText('copied anchor link to clipboard')).not.toBeInTheDocument();
46
- expect(screen.queryByLabelText('click to copy anchor link to clipboard')).toBeInTheDocument();
47
- // act
48
- await userEvents.click(screen.getByTitle('Mosaic Title'));
49
- // assert
50
- expect(screen.queryByLabelText('copied anchor link to clipboard')).toBeInTheDocument();
51
- expect(
52
- screen.queryByLabelText('click to copy anchor link to clipboard')
53
- ).not.toBeInTheDocument();
54
- });
55
- });
56
- });