11import * as React from 'react' ;
22import Typography from '@mui/material/Typography' ;
33import { Link , LinkProps } from '@mui/material' ;
4+ import {
5+ ComponentsOverrides ,
6+ styled ,
7+ useThemeProps ,
8+ } from '@mui/material/styles' ;
49import { useFieldValue , useTranslate } from 'ra-core' ;
510
611import { sanitizeFieldRestProps } from './sanitizeFieldRestProps' ;
@@ -10,8 +15,13 @@ import { genericMemo } from './genericMemo';
1015const EmailFieldImpl = <
1116 RecordType extends Record < string , any > = Record < string , any > ,
1217> (
13- props : EmailFieldProps < RecordType >
18+ inProps : EmailFieldProps < RecordType >
1419) => {
20+ const props = useThemeProps ( {
21+ props : inProps ,
22+ name : PREFIX ,
23+ } ) ;
24+
1525 const { className, emptyText, ...rest } = props ;
1626 const value = useFieldValue ( props ) ;
1727 const translate = useTranslate ( ) ;
@@ -30,15 +40,15 @@ const EmailFieldImpl = <
3040 }
3141
3242 return (
33- < Link
43+ < StyledLink
3444 className = { className }
3545 href = { `mailto:${ value } ` }
3646 onClick = { stopPropagation }
3747 variant = "body2"
3848 { ...sanitizeFieldRestProps ( rest ) }
3949 >
4050 { value }
41- </ Link >
51+ </ StyledLink >
4252 ) ;
4353} ;
4454EmailFieldImpl . displayName = 'EmailFieldImpl' ;
@@ -52,3 +62,29 @@ export interface EmailFieldProps<
5262
5363// useful to prevent click bubbling in a Datagrid with rowClick
5464const stopPropagation = e => e . stopPropagation ( ) ;
65+
66+ const PREFIX = 'RaEmailField' ;
67+
68+ const StyledLink = styled ( Link , {
69+ name : PREFIX ,
70+ overridesResolver : ( props , styles ) => styles . root ,
71+ } ) ( { } ) ;
72+
73+ declare module '@mui/material/styles' {
74+ interface ComponentNameToClassKey {
75+ [ PREFIX ] : 'root' ;
76+ }
77+
78+ interface ComponentsPropsList {
79+ [ PREFIX ] : Partial < EmailFieldProps > ;
80+ }
81+
82+ interface Components {
83+ [ PREFIX ] ?: {
84+ defaultProps ?: ComponentsPropsList [ typeof PREFIX ] ;
85+ styleOverrides ?: ComponentsOverrides <
86+ Omit < Theme , 'components' >
87+ > [ typeof PREFIX ] ;
88+ } ;
89+ }
90+ }
0 commit comments