forked from sombochea/verdaccio-ui
fix: rest MUI components - Introduced ForwardRef (#224)
* refactor(162): added forwardRef Card * refactor(162): introduced forwardRefDivider * refactor(162): introduced forwardRef MuiComponents * refactor(162): introducing forwardRef * refactor(162): introduced forwardRef * refactor(162): introduced forwardRef * fix(162): fixed link * fix: fixed port number * fix: fixed duplicated id * fix: fixed ref iconbutton * fix: updated snaps * fix: fixed port * fix: fixed eslint errors * fix: the item should be a button * fix: fixed eslint errors
This commit is contained in:
committed by
Juan Picado @jotadeveloper
parent
a4cdd145d2
commit
b56e43846b
10
src/muiComponents/AppBar/AppBar.tsx
Normal file
10
src/muiComponents/AppBar/AppBar.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIAppBar, AppBarProps } from '@material-ui/core/AppBar';
|
||||
|
||||
type AppBarRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
const AppBar = forwardRef<AppBarRef, AppBarProps>(function AppBar(props, ref) {
|
||||
return <MaterialUIAppBar {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default AppBar;
|
||||
1
src/muiComponents/AppBar/index.ts
Normal file
1
src/muiComponents/AppBar/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './AppBar';
|
||||
6
src/muiComponents/Box/Box.tsx
Normal file
6
src/muiComponents/Box/Box.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { default as MaterialUIBox, BoxProps } from '@material-ui/core/Box';
|
||||
|
||||
const Box: React.FC<BoxProps> = props => <MaterialUIBox {...props} />;
|
||||
|
||||
export default Box;
|
||||
1
src/muiComponents/Box/index.ts
Normal file
1
src/muiComponents/Box/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Box';
|
||||
10
src/muiComponents/CardActions/CardActions.tsx
Normal file
10
src/muiComponents/CardActions/CardActions.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUICardActions, CardActionsProps } from '@material-ui/core/CardActions';
|
||||
|
||||
type CardActionsRef = HTMLDivElement;
|
||||
|
||||
const CardActions = forwardRef<CardActionsRef, CardActionsProps>(function CardContentActions(props, ref) {
|
||||
return <MaterialUICardActions {...props} innerRef={ref} />;
|
||||
});
|
||||
|
||||
export default CardActions;
|
||||
1
src/muiComponents/CardActions/index.ts
Normal file
1
src/muiComponents/CardActions/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './CardActions';
|
||||
10
src/muiComponents/CardContent/CardContent.tsx
Normal file
10
src/muiComponents/CardContent/CardContent.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUICardContent, CardContentProps } from '@material-ui/core/CardContent';
|
||||
|
||||
type CardContentRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
const CardContent = forwardRef<CardContentRef, CardContentProps>(function CardContent(props, ref) {
|
||||
return <MaterialUICardContent {...props} innerRef={ref} />;
|
||||
});
|
||||
|
||||
export default CardContent;
|
||||
1
src/muiComponents/CardContent/index.ts
Normal file
1
src/muiComponents/CardContent/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './CardContent';
|
||||
10
src/muiComponents/Chip/Chip.tsx
Normal file
10
src/muiComponents/Chip/Chip.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIChip, ChipProps } from '@material-ui/core/Chip';
|
||||
|
||||
type ChipRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
const Chip = forwardRef<ChipRef, ChipProps>(function Chip(props, ref) {
|
||||
return <MaterialUIChip {...props} innerRef={ref} />;
|
||||
});
|
||||
|
||||
export default Chip;
|
||||
1
src/muiComponents/Chip/index.ts
Normal file
1
src/muiComponents/Chip/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Chip';
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIDivider, DividerProps } from '@material-ui/core/Divider';
|
||||
|
||||
type DividerRef = keyof HTMLElementTagNameMap;
|
||||
type DividerRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
const Divider = forwardRef<DividerRef, DividerProps>(function Divider(props, ref) {
|
||||
return <MaterialUIDivider {...props} innerRef={ref} />;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIFab, FabProps } from '@material-ui/core/Fab';
|
||||
|
||||
type FloatingActionButtonRef = HTMLButtonElement;
|
||||
|
||||
const FloatingActionButton = forwardRef<FloatingActionButtonRef, FabProps>(function FloatingActionButton(props, ref) {
|
||||
return <MaterialUIFab {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default FloatingActionButton;
|
||||
1
src/muiComponents/FloatingActionButton/index.ts
Normal file
1
src/muiComponents/FloatingActionButton/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './FloatingActionButton';
|
||||
10
src/muiComponents/FormControl/FormControl.tsx
Normal file
10
src/muiComponents/FormControl/FormControl.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIFormControl, FormControlProps } from '@material-ui/core/FormControl';
|
||||
|
||||
type FormControlRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
const FormControl = forwardRef<FormControlRef, FormControlProps>(function FormControl(props, ref) {
|
||||
return <MaterialUIFormControl {...props} innerRef={ref} />;
|
||||
});
|
||||
|
||||
export default FormControl;
|
||||
1
src/muiComponents/FormControl/index.ts
Normal file
1
src/muiComponents/FormControl/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './FormControl';
|
||||
10
src/muiComponents/FormHelperText/FormHelperText.tsx
Normal file
10
src/muiComponents/FormHelperText/FormHelperText.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIFormHelperText, FormHelperTextProps } from '@material-ui/core/FormHelperText';
|
||||
|
||||
type FormHelperTextRef = HTMLButtonElement;
|
||||
|
||||
const FormHelperText = forwardRef<FormHelperTextRef, FormHelperTextProps>(function FormHelperText(props, ref) {
|
||||
return <MaterialUIFormHelperText {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default FormHelperText;
|
||||
1
src/muiComponents/FormHelperText/index.ts
Normal file
1
src/muiComponents/FormHelperText/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './FormHelperText';
|
||||
10
src/muiComponents/Grid/Grid.tsx
Normal file
10
src/muiComponents/Grid/Grid.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIGrid, GridProps } from '@material-ui/core/Grid';
|
||||
|
||||
type GridRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
const Grid = forwardRef<GridRef, GridProps>(function Grid(props, ref) {
|
||||
return <MaterialUIGrid {...props} innerRef={ref} />;
|
||||
});
|
||||
|
||||
export default Grid;
|
||||
1
src/muiComponents/Grid/index.ts
Normal file
1
src/muiComponents/Grid/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Grid';
|
||||
10
src/muiComponents/Input/Input.tsx
Normal file
10
src/muiComponents/Input/Input.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIInput, InputProps } from '@material-ui/core/Input';
|
||||
|
||||
type InputRef = HTMLDivElement;
|
||||
|
||||
const Input = forwardRef<InputRef, InputProps>(function Input(props, ref) {
|
||||
return <MaterialUIInput {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default Input;
|
||||
1
src/muiComponents/Input/index.ts
Normal file
1
src/muiComponents/Input/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Input';
|
||||
10
src/muiComponents/InputAdornment/InputAdornment.tsx
Normal file
10
src/muiComponents/InputAdornment/InputAdornment.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIInputAdornment, InputAdornmentProps } from '@material-ui/core/InputAdornment';
|
||||
|
||||
type InputAdornmentRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
const InputAdornment = forwardRef<InputAdornmentRef, InputAdornmentProps>(function InputAdornment(props, ref) {
|
||||
return <MaterialUIInputAdornment {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default InputAdornment;
|
||||
1
src/muiComponents/InputAdornment/index.ts
Normal file
1
src/muiComponents/InputAdornment/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './InputAdornment';
|
||||
10
src/muiComponents/InputLabel/InputLabel.tsx
Normal file
10
src/muiComponents/InputLabel/InputLabel.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIInputLabel, InputLabelProps } from '@material-ui/core/InputLabel';
|
||||
|
||||
type InputLabelRef = HTMLLabelElement;
|
||||
|
||||
const InputLabel = forwardRef<InputLabelRef, InputLabelProps>(function InputLabel(props, ref) {
|
||||
return <MaterialUIInputLabel {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default InputLabel;
|
||||
1
src/muiComponents/InputLabel/index.ts
Normal file
1
src/muiComponents/InputLabel/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './InputLabel';
|
||||
10
src/muiComponents/ListItemText/ListItemText.tsx
Normal file
10
src/muiComponents/ListItemText/ListItemText.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIListItemText, ListItemTextProps } from '@material-ui/core/ListItemText';
|
||||
|
||||
type ListItemTextRef = HTMLDivElement;
|
||||
|
||||
const ListItemText = forwardRef<ListItemTextRef, ListItemTextProps>(function ListItemText(props, ref) {
|
||||
return <MaterialUIListItemText {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default ListItemText;
|
||||
1
src/muiComponents/ListItemText/index.ts
Normal file
1
src/muiComponents/ListItemText/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './ListItemText';
|
||||
10
src/muiComponents/Menu/Menu.tsx
Normal file
10
src/muiComponents/Menu/Menu.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIMenu, MenuProps } from '@material-ui/core/Menu';
|
||||
|
||||
type MenuRef = HTMLDivElement;
|
||||
|
||||
const Menu = forwardRef<MenuRef, MenuProps>(function Menu(props, ref) {
|
||||
return <MaterialUIMenu {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default Menu;
|
||||
1
src/muiComponents/Menu/index.ts
Normal file
1
src/muiComponents/Menu/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Menu';
|
||||
21
src/muiComponents/MenuItem/MenuItem.tsx
Normal file
21
src/muiComponents/MenuItem/MenuItem.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIMenuItem, MenuItemProps } from '@material-ui/core/MenuItem';
|
||||
|
||||
type HTMLElementTagName = keyof HTMLElementTagNameMap;
|
||||
type MenuItemRef = HTMLElementTagNameMap[HTMLElementTagName];
|
||||
|
||||
interface Props extends Omit<MenuItemProps, 'component'> {
|
||||
component?: HTMLElementTagName;
|
||||
}
|
||||
|
||||
const MenuItem = forwardRef<MenuItemRef, Props>(function MenuItem({ button, ...props }, ref) {
|
||||
// it seems typescript has some discrimination type limitions. Please see: https://github.com/mui-org/material-ui/issues/14971
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return <MaterialUIMenuItem {...props} button={button as any} innerRef={ref} />;
|
||||
});
|
||||
|
||||
MenuItem.defaultProps = {
|
||||
component: 'li',
|
||||
};
|
||||
|
||||
export default MenuItem;
|
||||
1
src/muiComponents/MenuItem/index.ts
Normal file
1
src/muiComponents/MenuItem/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './MenuItem';
|
||||
10
src/muiComponents/Paper/Paper.tsx
Normal file
10
src/muiComponents/Paper/Paper.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIPaper, PaperProps } from '@material-ui/core/Paper';
|
||||
|
||||
type PaperRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
const Paper = forwardRef<PaperRef, PaperProps>(function Paper(props, ref) {
|
||||
return <MaterialUIPaper {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default Paper;
|
||||
1
src/muiComponents/Paper/index.ts
Normal file
1
src/muiComponents/Paper/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Paper';
|
||||
10
src/muiComponents/SnackbarContent/SnackbarContent.tsx
Normal file
10
src/muiComponents/SnackbarContent/SnackbarContent.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUISnackbarContent, SnackbarContentProps } from '@material-ui/core/SnackbarContent';
|
||||
|
||||
type SnackbarContentRef = HTMLDivElement;
|
||||
|
||||
const SnackbarContent = forwardRef<SnackbarContentRef, SnackbarContentProps>(function SnackbarContent(props, ref) {
|
||||
return <MaterialUISnackbarContent {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default SnackbarContent;
|
||||
1
src/muiComponents/SnackbarContent/index.ts
Normal file
1
src/muiComponents/SnackbarContent/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './SnackbarContent';
|
||||
10
src/muiComponents/Tab/Tab.tsx
Normal file
10
src/muiComponents/Tab/Tab.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUITab, TabProps } from '@material-ui/core/Tab';
|
||||
|
||||
type TabRef = HTMLButtonElement;
|
||||
|
||||
const Tab = forwardRef<TabRef, TabProps>(function Tab(props, ref) {
|
||||
return <MaterialUITab {...props} innerRef={ref} />;
|
||||
});
|
||||
|
||||
export default Tab;
|
||||
1
src/muiComponents/Tab/index.ts
Normal file
1
src/muiComponents/Tab/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Tab';
|
||||
14
src/muiComponents/Tabs/Tabs.tsx
Normal file
14
src/muiComponents/Tabs/Tabs.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUITabs, TabsProps } from '@material-ui/core/Tabs';
|
||||
|
||||
type TabsRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
interface Props extends Omit<TabsProps, 'onChange'> {
|
||||
onChange: (event: React.ChangeEvent<{}>, value: number) => void;
|
||||
}
|
||||
|
||||
const Tabs = forwardRef<TabsRef, Props>(function Tabs(props, ref) {
|
||||
return <MaterialUITabs {...props} innerRef={ref} />;
|
||||
});
|
||||
|
||||
export default Tabs;
|
||||
1
src/muiComponents/Tabs/index.ts
Normal file
1
src/muiComponents/Tabs/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Tabs';
|
||||
@@ -2,14 +2,14 @@ import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUITypography, TypographyProps } from '@material-ui/core/Typography';
|
||||
|
||||
type TextType = 'subtitle1' | 'subtitle2' | 'body1' | 'body2';
|
||||
type TextRef = keyof HTMLElementTagNameMap;
|
||||
type TextRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
interface Props extends Omit<TypographyProps, 'variant'> {
|
||||
export interface TextProps extends Omit<TypographyProps, 'variant'> {
|
||||
variant?: TextType;
|
||||
}
|
||||
|
||||
// The reference is already from type of the Component, so the any below is not a problem
|
||||
const Text = forwardRef<TextRef, Props>(function Text(props, ref) {
|
||||
const Text = forwardRef<TextRef, TextProps>(function Text(props, ref) {
|
||||
return <MaterialUITypography {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { default } from './Text';
|
||||
export { default, TextProps } from './Text';
|
||||
|
||||
10
src/muiComponents/Toolbar/Toolbar.tsx
Normal file
10
src/muiComponents/Toolbar/Toolbar.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { default as MaterialUIToolbar, ToolbarProps } from '@material-ui/core/Toolbar';
|
||||
|
||||
type ToolbarRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
||||
|
||||
const Toolbar = forwardRef<ToolbarRef, ToolbarProps>(function Toolbar(props, ref) {
|
||||
return <MaterialUIToolbar {...props} ref={ref} />;
|
||||
});
|
||||
|
||||
export default Toolbar;
|
||||
1
src/muiComponents/Toolbar/index.ts
Normal file
1
src/muiComponents/Toolbar/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Toolbar';
|
||||
Reference in New Issue
Block a user