@@ -4,10 +4,20 @@ import Queue from '@mui/icons-material/Queue';
44import { Link } from 'react-router-dom' ;
55import { stringify } from 'query-string' ;
66import { useResourceContext , useRecordContext , useCreatePath } from 'ra-core' ;
7+ import {
8+ ComponentsOverrides ,
9+ styled ,
10+ useThemeProps ,
11+ } from '@mui/material/styles' ;
712
813import { Button , ButtonProps } from './Button' ;
914
10- export const CloneButton = ( props : CloneButtonProps ) => {
15+ export const CloneButton = ( inProps : CloneButtonProps ) => {
16+ const props = useThemeProps ( {
17+ props : inProps ,
18+ name : PREFIX ,
19+ } ) ;
20+
1121 const {
1222 label = 'ra.action.clone' ,
1323 scrollToTop = true ,
@@ -19,7 +29,7 @@ export const CloneButton = (props: CloneButtonProps) => {
1929 const createPath = useCreatePath ( ) ;
2030 const pathname = createPath ( { resource, type : 'create' } ) ;
2131 return (
22- < Button
32+ < StyledButton
2333 component = { Link }
2434 to = {
2535 record
@@ -37,7 +47,7 @@ export const CloneButton = (props: CloneButtonProps) => {
3747 { ...sanitizeRestProps ( rest ) }
3848 >
3949 { icon }
40- </ Button >
50+ </ StyledButton >
4151 ) ;
4252} ;
4353
@@ -63,3 +73,29 @@ interface Props {
6373export type CloneButtonProps = Props & Omit < ButtonProps < typeof Link > , 'to' > ;
6474
6575export default memo ( CloneButton ) ;
76+
77+ const PREFIX = 'RaCloneButton' ;
78+
79+ const StyledButton = styled ( Button , {
80+ name : PREFIX ,
81+ overridesResolver : ( props , styles ) => styles . root ,
82+ } ) ( { } ) ;
83+
84+ declare module '@mui/material/styles' {
85+ interface ComponentNameToClassKey {
86+ [ PREFIX ] : 'root' ;
87+ }
88+
89+ interface ComponentsPropsList {
90+ [ PREFIX ] : Partial < CloneButtonProps > ;
91+ }
92+
93+ interface Components {
94+ [ PREFIX ] ?: {
95+ defaultProps ?: ComponentsPropsList [ typeof PREFIX ] ;
96+ styleOverrides ?: ComponentsOverrides <
97+ Omit < Theme , 'components' >
98+ > [ typeof PREFIX ] ;
99+ } ;
100+ }
101+ }
0 commit comments