@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.
- package/package.json +8 -5
- package/.turbo/turbo-build.log +0 -4
- package/CHANGELOG.md +0 -686
- package/src/Accordion/__tests__/index.test.tsx +0 -82
- package/src/Accordion/index.tsx +0 -88
- package/src/Accordion/styles.css.ts +0 -16
- package/src/AudioPlayer/__tests__/index.test.tsx +0 -19
- package/src/AudioPlayer/index.tsx +0 -163
- package/src/AudioPlayer/styles.css.ts +0 -65
- package/src/BrowserOnly.tsx +0 -17
- package/src/Button.tsx +0 -25
- package/src/Callout/__tests__/index.test.tsx +0 -102
- package/src/Callout/index.tsx +0 -62
- package/src/Callout/styles.css.ts +0 -77
- package/src/Card/index.tsx +0 -35
- package/src/Card/styles.css.ts +0 -23
- package/src/Cards.tsx +0 -25
- package/src/ComponentExample/index.tsx +0 -23
- package/src/ComponentExample/styles.css.ts +0 -25
- package/src/DataTable.tsx +0 -114
- package/src/EditionFilterView/__tests__/index.test.tsx +0 -49
- package/src/EditionFilterView/index.tsx +0 -108
- package/src/EditionFilterView/styles.css.ts +0 -8
- package/src/EditionTileLink/index.tsx +0 -90
- package/src/EditionTileLink/styles.css.ts +0 -95
- package/src/Feature/Feature.tsx +0 -92
- package/src/Feature/FeatureActions/index.tsx +0 -34
- package/src/Feature/FeatureActions/styles.css.ts +0 -15
- package/src/Feature/FeatureContent/index.tsx +0 -30
- package/src/Feature/FeatureContent/styles.css.ts +0 -13
- package/src/Feature/FeatureEyebrow/index.tsx +0 -19
- package/src/Feature/FeatureEyebrow/styles.css.ts +0 -11
- package/src/Feature/FeatureTitle/index.tsx +0 -18
- package/src/Feature/FeatureTitle/styles.css.ts +0 -9
- package/src/Feature/index.tsx +0 -10
- package/src/Feature/styles.css.ts +0 -58
- package/src/Features/index.tsx +0 -33
- package/src/Features/styles.css.ts +0 -10
- package/src/FilterToolbar/ContentArea/index.tsx +0 -12
- package/src/FilterToolbar/ContentArea/styles.css.ts +0 -16
- package/src/FilterToolbar/FilterDropdown/__tests__/index.test.tsx +0 -22
- package/src/FilterToolbar/FilterDropdown/index.tsx +0 -62
- package/src/FilterToolbar/FilterDropdown/styles.css.ts +0 -16
- package/src/FilterToolbar/PillGroup/__tests__/index.test.tsx +0 -26
- package/src/FilterToolbar/PillGroup/index.tsx +0 -36
- package/src/FilterToolbar/PillGroup/styles.css.ts +0 -17
- package/src/FilterToolbar/Search/__tests__/index.test.tsx +0 -34
- package/src/FilterToolbar/Search/index.tsx +0 -33
- package/src/FilterToolbar/Search/styles.css.ts +0 -9
- package/src/FilterToolbar/SortDropdown/__tests__/index.test.tsx +0 -22
- package/src/FilterToolbar/SortDropdown/defaultSort.js +0 -8
- package/src/FilterToolbar/SortDropdown/index.tsx +0 -53
- package/src/FilterToolbar/SortDropdown/styles.css.ts +0 -15
- package/src/FilterToolbar/Toolbar.tsx +0 -38
- package/src/FilterToolbar/ToolbarProvider.tsx +0 -94
- package/src/FilterToolbar/__tests__/Toolbar.test.tsx +0 -127
- package/src/FilterToolbar/__tests__/ToolbarProvider.test.tsx +0 -85
- package/src/FilterToolbar/index.tsx +0 -9
- package/src/FilterToolbar/styles.css.ts +0 -19
- package/src/FilterView/ContentArea/index.tsx +0 -24
- package/src/FilterView/ContentArea/styles.css.ts +0 -16
- package/src/FilterView/FilterView.tsx +0 -205
- package/src/FilterView/FilterViewProvider.tsx +0 -23
- package/src/FilterView/NoResults/index.tsx +0 -19
- package/src/FilterView/NoResults/styles.css.ts +0 -13
- package/src/FilterView/Pagination/index.tsx +0 -40
- package/src/FilterView/Pagination/styles.css.ts +0 -40
- package/src/FilterView/Pagination/usePagination.ts +0 -31
- package/src/FilterView/ResultCount/index.tsx +0 -23
- package/src/FilterView/ResultCount/styles.css.ts +0 -11
- package/src/FilterView/__tests__/index.test.tsx +0 -109
- package/src/FilterView/index.tsx +0 -5
- package/src/FilterView/useResultCount.tsx +0 -8
- package/src/FormattedContent.tsx +0 -75
- package/src/Grid/index.tsx +0 -29
- package/src/Grid/styles.css.ts +0 -13
- package/src/GridBase/index.tsx +0 -60
- package/src/GridBase/styles.css.ts +0 -19
- package/src/HelpLinks/index.tsx +0 -80
- package/src/HelpLinks/styles.css.ts +0 -32
- package/src/Hero/__tests__/index.test.tsx +0 -19
- package/src/Hero/index.tsx +0 -172
- package/src/Hero/styles.css.ts +0 -111
- package/src/Icon/index.tsx +0 -50
- package/src/ImageProvider.ts +0 -9
- package/src/Impact/index.tsx +0 -36
- package/src/Impact/styles.css.ts +0 -72
- package/src/Impacts.tsx +0 -25
- package/src/IsomorphicSuspense.tsx +0 -9
- package/src/Label/__tests__/index.test.tsx +0 -27
- package/src/Label/index.tsx +0 -42
- package/src/Label/styles.css.ts +0 -14
- package/src/Link/index.tsx +0 -83
- package/src/Link/styles.css.ts +0 -15
- package/src/LinkBase/index.tsx +0 -32
- package/src/LinkButton.css.ts +0 -19
- package/src/LinkButton.tsx +0 -22
- package/src/LinkProvider.ts +0 -9
- package/src/LinkText/index.tsx +0 -121
- package/src/LinkText/styles.css.ts +0 -30
- package/src/Links/index.tsx +0 -18
- package/src/Links/styles.css.ts +0 -13
- package/src/List/ListItem.tsx +0 -31
- package/src/List/OrderedList.tsx +0 -22
- package/src/List/UnorderedList.tsx +0 -35
- package/src/List/index.tsx +0 -3
- package/src/Markdown/AnchorHeading/__tests__/index.test.tsx +0 -56
- package/src/Markdown/AnchorHeading/index.css.ts +0 -64
- package/src/Markdown/AnchorHeading/index.tsx +0 -97
- package/src/Markdown/BlockQuote/index.css.ts +0 -6
- package/src/Markdown/BlockQuote/index.tsx +0 -21
- package/src/Markdown/Heading.tsx +0 -39
- package/src/Markdown/InlineCode.tsx +0 -10
- package/src/Markdown/Link.tsx +0 -11
- package/src/Markdown/Pre/index.css.ts +0 -35
- package/src/Markdown/Pre/index.tsx +0 -155
- package/src/Markdown/Table.tsx +0 -11
- package/src/Markdown/Tbody.tsx +0 -9
- package/src/Markdown/Td.tsx +0 -9
- package/src/Markdown/Th.tsx +0 -9
- package/src/Markdown/Thead.tsx +0 -9
- package/src/Markdown/ThematicBreak/index.css.ts +0 -5
- package/src/Markdown/ThematicBreak/index.tsx +0 -10
- package/src/Markdown/Tr.tsx +0 -9
- package/src/Markdown/__tests__/Heading.test.tsx +0 -56
- package/src/Markdown/index.tsx +0 -210
- package/src/Markdown/markdownElements.tsx +0 -52
- package/src/Markdown/withMarkdownSpacing/index.tsx +0 -33
- package/src/Markdown/withMarkdownSpacing/styles.css.ts +0 -7
- package/src/PageFilterView/index.tsx +0 -86
- package/src/PageFilterView/styles.css.ts +0 -8
- package/src/ReactLive/index.tsx +0 -71
- package/src/ReactLive/styles.css.ts +0 -28
- package/src/SecondaryNavbar/index.tsx +0 -55
- package/src/SecondaryNavbar/styles.css.ts +0 -27
- package/src/SectionHeading/__tests__/index.test.tsx +0 -20
- package/src/SectionHeading/index.tsx +0 -33
- package/src/SectionHeading/styles.css.ts +0 -15
- package/src/StickyHeader/index.tsx +0 -52
- package/src/StickyHeader/styles.css.ts +0 -17
- package/src/Story/index.tsx +0 -70
- package/src/Story/styles.css.ts +0 -37
- package/src/Tabs/index.tsx +0 -65
- package/src/Tabs/styles.css.ts +0 -7
- package/src/TabsBase/TabsBase.tsx +0 -89
- package/src/TabsBase/TabsButton.tsx +0 -30
- package/src/TabsBase/TabsLink.tsx +0 -30
- package/src/TabsBase/TabsMenuButton.tsx +0 -41
- package/src/TabsBase/index.ts +0 -4
- package/src/TabsBase/styles.css.ts +0 -64
- package/src/TabsBase/tabsMenuButton.css.ts +0 -25
- package/src/Tag/__tests__/index.test.tsx +0 -58
- package/src/Tag/index.tsx +0 -62
- package/src/Tag/styles.css.ts +0 -48
- package/src/ThemeProvider.tsx +0 -37
- package/src/TileBase/TileBase.tsx +0 -159
- package/src/TileBase/TileStateProvider.tsx +0 -52
- package/src/TileBase/index.ts +0 -2
- package/src/TileBase/styles.css.ts +0 -15
- package/src/TileButton/index.tsx +0 -68
- package/src/TileContent/index.tsx +0 -155
- package/src/TileContent/styles.css.ts +0 -229
- package/src/TileContentLabel/index.tsx +0 -74
- package/src/TileContentLabel/styles.css.ts +0 -22
- package/src/TileLink/index.tsx +0 -83
- package/src/TileLink/styles.css.ts +0 -9
- package/src/Tiles.tsx +0 -17
- package/src/Typography/Typography.tsx +0 -22
- package/src/Typography/index.tsx +0 -54
- package/src/Typography/withStyledTypography.tsx +0 -25
- package/src/VideoPlayer/__tests__/index.test.tsx +0 -13
- package/src/VideoPlayer/index.tsx +0 -179
- package/src/VideoPlayer/styles.css.ts +0 -87
- package/src/ViewStack/View.tsx +0 -19
- package/src/ViewStack/ViewStack.tsx +0 -50
- package/src/ViewStack/__tests__/index.test.tsx +0 -86
- package/src/ViewStack/index.tsx +0 -2
- package/src/__tests__/Button.test.tsx +0 -13
- package/src/__tests__/LinkButton.test.tsx +0 -16
- package/src/__tests__/ReactLive.test.tsx +0 -21
- package/src/canUseDOM.ts +0 -5
- package/src/common/types/index.ts +0 -52
- package/src/index.tsx +0 -59
- package/src/styles.ts +0 -45
- package/src/useBreakpoint.ts +0 -28
- package/src/useLockBodyScroll.ts +0 -16
- package/src/useOutsideClick.ts +0 -25
- package/src/useSize.ts +0 -32
- package/src/useSpacing.ts +0 -17
- package/src/utils/hasProtocol.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/tsconfig.json +0 -8
|
@@ -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
|
-
}));
|
package/src/Label/index.tsx
DELETED
|
@@ -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
|
-
);
|
package/src/Label/styles.css.ts
DELETED
|
@@ -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
|
-
};
|
package/src/Link/index.tsx
DELETED
|
@@ -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
|
-
});
|
package/src/Link/styles.css.ts
DELETED
|
@@ -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
|
-
};
|
package/src/LinkBase/index.tsx
DELETED
|
@@ -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
|
-
);
|
package/src/LinkButton.css.ts
DELETED
|
@@ -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
|
-
};
|
package/src/LinkButton.tsx
DELETED
|
@@ -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
|
-
);
|
package/src/LinkProvider.ts
DELETED
|
@@ -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;
|
package/src/LinkText/index.tsx
DELETED
|
@@ -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
|
-
});
|
package/src/Links/index.tsx
DELETED
|
@@ -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
|
-
};
|
package/src/Links/styles.css.ts
DELETED
|
@@ -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
|
-
};
|
package/src/List/ListItem.tsx
DELETED
|
@@ -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
|
-
};
|
package/src/List/OrderedList.tsx
DELETED
|
@@ -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
|
-
};
|
package/src/List/index.tsx
DELETED
|
@@ -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
|
-
});
|