@@ -2,10 +2,20 @@ import * as React from 'react';
22import { MouseEvent , useCallback } from 'react' ;
33import NavigationRefresh from '@mui/icons-material/Refresh' ;
44import { useRefresh } from 'ra-core' ;
5+ import {
6+ ComponentsOverrides ,
7+ styled ,
8+ useThemeProps ,
9+ } from '@mui/material/styles' ;
510
611import { Button , ButtonProps } from './Button' ;
712
8- export const RefreshButton = ( props : RefreshButtonProps ) => {
13+ export const RefreshButton = ( inProps : RefreshButtonProps ) => {
14+ const props = useThemeProps ( {
15+ props : inProps ,
16+ name : PREFIX ,
17+ } ) ;
18+
919 const {
1020 label = 'ra.action.refresh' ,
1121 icon = defaultIcon ,
@@ -25,9 +35,9 @@ export const RefreshButton = (props: RefreshButtonProps) => {
2535 ) ;
2636
2737 return (
28- < Button label = { label } onClick = { handleClick } { ...rest } >
38+ < StyledButton label = { label } onClick = { handleClick } { ...rest } >
2939 { icon }
30- </ Button >
40+ </ StyledButton >
3141 ) ;
3242} ;
3343
@@ -40,3 +50,29 @@ interface Props {
4050}
4151
4252export type RefreshButtonProps = Props & ButtonProps ;
53+
54+ const PREFIX = 'RaRefreshButton' ;
55+
56+ const StyledButton = styled ( Button , {
57+ name : PREFIX ,
58+ overridesResolver : ( props , styles ) => styles . root ,
59+ } ) ( { } ) ;
60+
61+ declare module '@mui/material/styles' {
62+ interface ComponentNameToClassKey {
63+ [ PREFIX ] : 'root' ;
64+ }
65+
66+ interface ComponentsPropsList {
67+ [ PREFIX ] : Partial < RefreshButtonProps > ;
68+ }
69+
70+ interface Components {
71+ [ PREFIX ] ?: {
72+ defaultProps ?: ComponentsPropsList [ typeof PREFIX ] ;
73+ styleOverrides ?: ComponentsOverrides <
74+ Omit < Theme , 'components' >
75+ > [ typeof PREFIX ] ;
76+ } ;
77+ }
78+ }
0 commit comments