forked from sombochea/verdaccio-ui
fix: introduced forwardRef (#163)
This commit is contained in:
parent
909a8d9fb8
commit
626bcce5cb
@ -1,13 +1,14 @@
|
||||
import React, { FC, useContext } from 'react';
|
||||
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import List from '@material-ui/core/List';
|
||||
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import { Heading, AuthorListItem, AuthorListItemText } from './styles';
|
||||
import { isEmail } from '../../utils/url';
|
||||
|
||||
const Authors: FC = () => {
|
||||
import Avatar from '../../muiComponents/Avatar';
|
||||
|
||||
const Author: FC = () => {
|
||||
const { packageMeta } = useContext(DetailContext);
|
||||
|
||||
if (!packageMeta) {
|
||||
@ -41,4 +42,4 @@ const Authors: FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default Authors;
|
||||
export default Author;
|
||||
|
@ -1,9 +1,9 @@
|
||||
import React, { FC } from 'react';
|
||||
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import { isEmail } from '../../utils/url';
|
||||
|
||||
import Tooltip from '../../muiComponents/Tooltip';
|
||||
import Avatar from '../../muiComponents/Avatar';
|
||||
|
||||
export interface AvatarDeveloper {
|
||||
name: string;
|
||||
|
@ -106,6 +106,9 @@ exports[`test Developers should render the component for contributors with items
|
||||
onTouchStart={[Function]}
|
||||
target="_top"
|
||||
title="dmethvin"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="dmethvin"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="dmethvin"
|
||||
@ -126,6 +129,7 @@ exports[`test Developers should render the component for contributors with items
|
||||
/>
|
||||
</ForwardRef(Avatar)>
|
||||
</WithStyles(ForwardRef(Avatar))>
|
||||
</ForwardRef(Avatar)>
|
||||
</a>
|
||||
<ForwardRef(Popper)
|
||||
anchorEl={
|
||||
@ -198,6 +202,9 @@ exports[`test Developers should render the component for contributors with items
|
||||
onTouchStart={[Function]}
|
||||
target="_top"
|
||||
title="mgol"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="mgol"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="mgol"
|
||||
@ -218,6 +225,7 @@ exports[`test Developers should render the component for contributors with items
|
||||
/>
|
||||
</ForwardRef(Avatar)>
|
||||
</WithStyles(ForwardRef(Avatar))>
|
||||
</ForwardRef(Avatar)>
|
||||
</a>
|
||||
<ForwardRef(Popper)
|
||||
anchorEl={
|
||||
@ -356,6 +364,9 @@ exports[`test Developers should render the component for maintainers with items
|
||||
onTouchStart={[Function]}
|
||||
target="_top"
|
||||
title="dmethvin"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="dmethvin"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="dmethvin"
|
||||
@ -376,6 +387,7 @@ exports[`test Developers should render the component for maintainers with items
|
||||
/>
|
||||
</ForwardRef(Avatar)>
|
||||
</WithStyles(ForwardRef(Avatar))>
|
||||
</ForwardRef(Avatar)>
|
||||
</a>
|
||||
<ForwardRef(Popper)
|
||||
anchorEl={
|
||||
@ -448,6 +460,9 @@ exports[`test Developers should render the component for maintainers with items
|
||||
onTouchStart={[Function]}
|
||||
target="_top"
|
||||
title="mgol"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="mgol"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="mgol"
|
||||
@ -468,6 +483,7 @@ exports[`test Developers should render the component for maintainers with items
|
||||
/>
|
||||
</ForwardRef(Avatar)>
|
||||
</WithStyles(ForwardRef(Avatar))>
|
||||
</ForwardRef(Avatar)>
|
||||
</a>
|
||||
<ForwardRef(Popper)
|
||||
anchorEl={
|
||||
|
@ -1,12 +1,14 @@
|
||||
import React, { Component, ReactElement } from 'react';
|
||||
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import List from '@material-ui/core/List';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
|
||||
import { VersionPageConsumerProps, DetailContextConsumer } from '../../pages/Version';
|
||||
import { Heading, EngineListItem } from './styles';
|
||||
|
||||
import Avatar from '../../muiComponents/Avatar';
|
||||
|
||||
// @ts-ignore
|
||||
import node from './img/node.png';
|
||||
import npm from '../Install/img/npm.svg';
|
||||
|
@ -1,10 +1,10 @@
|
||||
import React from 'react';
|
||||
import styled from 'react-emotion';
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
|
||||
import CopyToClipBoard from '../CopyToClipBoard';
|
||||
import Avatar from '../../muiComponents/Avatar';
|
||||
|
||||
// logos of package managers
|
||||
import npmLogo from './img/npm.svg';
|
||||
|
@ -4,7 +4,6 @@ import { Link } from 'react-router-dom';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import List from '@material-ui/core/List';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
import Photo from '@material-ui/core/Avatar';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
|
||||
import { breakpoints } from '../../utils/styles/media';
|
||||
@ -13,6 +12,7 @@ import Label from '../Label';
|
||||
import colors from '../../utils/styles/colors';
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import { default as MuiIconButton } from '../../muiComponents/IconButton';
|
||||
import { default as Photo } from '../../muiComponents/Avatar';
|
||||
|
||||
export const OverviewItem = styled('span')`
|
||||
&& {
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* eslint react/jsx-max-depth: 0 */
|
||||
|
||||
import React, { Component, Fragment, ReactElement } from 'react';
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import List from '@material-ui/core/List';
|
||||
|
||||
import { DetailContextConsumer } from '../../pages/Version';
|
||||
@ -12,6 +11,8 @@ import { Heading, GithubLink, RepositoryListItem, RepositoryListItemText } from
|
||||
import git from './img/git.png';
|
||||
import { isURL } from '../../utils/url';
|
||||
|
||||
import Avatar from '../../muiComponents/Avatar';
|
||||
|
||||
class Repository extends Component {
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
return (
|
||||
|
13
src/muiComponents/Avatar/Avatar.tsx
Normal file
13
src/muiComponents/Avatar/Avatar.tsx
Normal file
@ -0,0 +1,13 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIAvatar, AvatarProps } from '@material-ui/core/Avatar';
|
||||
|
||||
// The default element type of MUI's Avatar is 'div' and we don't allow the change of this prop
|
||||
type AvatarRef = HTMLElementTagNameMap['div'];
|
||||
|
||||
/* eslint-disable verdaccio/jsx-spread */
|
||||
// eslint-disable-next-line react/display-name
|
||||
const Avatar = forwardRef<AvatarRef, AvatarProps>(function Avatar(props, ref) {
|
||||
return <MaterialUIAvatar {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default Avatar;
|
1
src/muiComponents/Avatar/index.ts
Normal file
1
src/muiComponents/Avatar/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export { default } from './Avatar';
|
@ -1,12 +1,12 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MuiIconButton, IconButtonProps } from '@material-ui/core/IconButton';
|
||||
import { default as MaterialUIIconButton, IconButtonProps } from '@material-ui/core/IconButton';
|
||||
|
||||
type IconButtonRef = HTMLElementTagNameMap['button'];
|
||||
|
||||
/* eslint-disable verdaccio/jsx-spread */
|
||||
// eslint-disable-next-line react/display-name
|
||||
const IconButton = forwardRef<IconButtonRef, IconButtonProps>(function IconButton(props, ref) {
|
||||
return <MuiIconButton {...props} ref={ref} />;
|
||||
return <MaterialUIIconButton {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default IconButton;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as TextFieldMaterialUI, TextFieldProps } from '@material-ui/core/TextField';
|
||||
import { default as MaterialUITextField, TextFieldProps } from '@material-ui/core/TextField';
|
||||
|
||||
// The default element type of MUI's TextField is 'div'
|
||||
type TextFieldRef = HTMLElementTagNameMap['div'];
|
||||
@ -8,7 +8,7 @@ type TextFieldRef = HTMLElementTagNameMap['div'];
|
||||
// eslint-disable-next-line react/display-name
|
||||
const TextField = forwardRef<TextFieldRef, TextFieldProps>(function ToolTip({ InputProps, classes, ...props }, ref) {
|
||||
return (
|
||||
<TextFieldMaterialUI
|
||||
<MaterialUITextField
|
||||
{...props}
|
||||
InputProps={{
|
||||
...InputProps,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MuiTooltip, TooltipProps } from '@material-ui/core/Tooltip';
|
||||
import { default as MaterialUITooltip, TooltipProps } from '@material-ui/core/Tooltip';
|
||||
|
||||
// The default element type of MUI's Tooltip is 'div' and the change of this prop is not allowed
|
||||
type TooltipRef = HTMLElementTagNameMap['div'];
|
||||
@ -7,7 +7,7 @@ type TooltipRef = HTMLElementTagNameMap['div'];
|
||||
/* eslint-disable verdaccio/jsx-spread */
|
||||
// eslint-disable-next-line react/display-name
|
||||
const Tooltip = forwardRef<TooltipRef, TooltipProps>(function ToolTip(props, ref) {
|
||||
return <MuiTooltip {...props} innerRef={ref} />;
|
||||
return <MaterialUITooltip {...props} innerRef={ref} />;
|
||||
});
|
||||
|
||||
export default Tooltip;
|
||||
|
@ -10,7 +10,7 @@ import { waitForElement } from '@testing-library/dom';
|
||||
import ErrorBoundary from '../../App/AppError';
|
||||
|
||||
// :-) we mock this otherways fails on render, some weird issue on material-ui
|
||||
jest.mock('@material-ui/core/Avatar');
|
||||
jest.mock('../../muiComponents/Avatar');
|
||||
|
||||
// eslint-disable-next-line react/display-name
|
||||
jest.mock('../../components/NotFound', () => () => <div>{'Not found'}</div>);
|
||||
|
Loading…
Reference in New Issue
Block a user