11import React , { Fragment , isValidElement , ReactEventHandler } from 'react' ;
22import ActionDelete from '@mui/icons-material/Delete' ;
3+ import {
4+ ComponentsOverrides ,
5+ styled ,
6+ useThemeProps ,
7+ } from '@mui/material/styles' ;
38import clsx from 'clsx' ;
49
510import { UseMutationOptions } from '@tanstack/react-query' ;
@@ -20,8 +25,13 @@ import { Button, ButtonProps } from './Button';
2025import { humanize , singularize } from 'inflection' ;
2126
2227export const DeleteWithConfirmButton = < RecordType extends RaRecord = any > (
23- props : DeleteWithConfirmButtonProps < RecordType >
28+ inProps : DeleteWithConfirmButtonProps < RecordType >
2429) => {
30+ const props = useThemeProps ( {
31+ props : inProps ,
32+ name : PREFIX ,
33+ } ) ;
34+
2535 const {
2636 className,
2737 confirmTitle : confirmTitleProp ,
@@ -80,7 +90,7 @@ export const DeleteWithConfirmButton = <RecordType extends RaRecord = any>(
8090
8191 return (
8292 < Fragment >
83- < Button
93+ < StyledButton
8494 onClick = { handleDialogOpen }
8595 label = { label }
8696 className = { clsx ( 'ra-delete-button' , className ) }
@@ -89,7 +99,7 @@ export const DeleteWithConfirmButton = <RecordType extends RaRecord = any>(
8999 { ...rest }
90100 >
91101 { icon }
92- </ Button >
102+ </ StyledButton >
93103 < Confirm
94104 isOpen = { open }
95105 loading = { isPending }
@@ -158,3 +168,29 @@ export interface DeleteWithConfirmButtonProps<
158168 resource ?: string ;
159169 successMessage ?: string ;
160170}
171+
172+ const PREFIX = 'RaDeleteWithConfirmButton' ;
173+
174+ const StyledButton = styled ( Button , {
175+ name : PREFIX ,
176+ overridesResolver : ( props , styles ) => styles . root ,
177+ } ) ( { } ) ;
178+
179+ declare module '@mui/material/styles' {
180+ interface ComponentNameToClassKey {
181+ [ PREFIX ] : 'root' ;
182+ }
183+
184+ interface ComponentsPropsList {
185+ [ PREFIX ] : Partial < DeleteWithConfirmButtonProps > ;
186+ }
187+
188+ interface Components {
189+ [ PREFIX ] ?: {
190+ defaultProps ?: ComponentsPropsList [ typeof PREFIX ] ;
191+ styleOverrides ?: ComponentsOverrides <
192+ Omit < Theme , 'components' >
193+ > [ typeof PREFIX ] ;
194+ } ;
195+ }
196+ }
0 commit comments