|
7 | 7 | SortPayload, |
8 | 8 | RaRecord, |
9 | 9 | } from 'ra-core'; |
| 10 | +import clsx from 'clsx'; |
10 | 11 | import { Typography, TypographyProps, CircularProgress } from '@mui/material'; |
11 | 12 | import { |
12 | 13 | ComponentsOverrides, |
@@ -42,6 +43,7 @@ export const ReferenceManyCount = <RecordType extends RaRecord = RaRecord>( |
42 | 43 | }); |
43 | 44 |
|
44 | 45 | const { |
| 46 | + className, |
45 | 47 | reference, |
46 | 48 | target, |
47 | 49 | filter, |
@@ -84,12 +86,14 @@ export const ReferenceManyCount = <RecordType extends RaRecord = RaRecord>( |
84 | 86 |
|
85 | 87 | return ( |
86 | 88 | <StyledTypography |
| 89 | + className={clsx(className, ReferenceManyCountClasses.root)} |
87 | 90 | component="span" |
88 | 91 | variant="body2" |
89 | 92 | {...sanitizeFieldRestProps(rest)} |
90 | 93 | > |
91 | 94 | {link && record ? ( |
92 | 95 | <Link |
| 96 | + className={ReferenceManyCountClasses.link} |
93 | 97 | to={{ |
94 | 98 | pathname: createPath({ |
95 | 99 | resource: reference, |
@@ -128,14 +132,22 @@ export interface ReferenceManyCountProps<RecordType extends RaRecord = RaRecord> |
128 | 132 |
|
129 | 133 | const PREFIX = 'RaReferenceManyCount'; |
130 | 134 |
|
| 135 | +export const ReferenceManyCountClasses = { |
| 136 | + root: `${PREFIX}-root`, |
| 137 | + link: `${PREFIX}-link`, |
| 138 | +}; |
| 139 | + |
131 | 140 | const StyledTypography = styled(Typography, { |
132 | 141 | name: PREFIX, |
133 | | - overridesResolver: (props, styles) => styles.root, |
| 142 | + overridesResolver: (props, styles) => ({ |
| 143 | + ['&']: styles.root, |
| 144 | + [`& .${ReferenceManyCountClasses.link}`]: styles.link, |
| 145 | + }), |
134 | 146 | })({}); |
135 | 147 |
|
136 | 148 | declare module '@mui/material/styles' { |
137 | 149 | interface ComponentNameToClassKey { |
138 | | - [PREFIX]: 'root'; |
| 150 | + [PREFIX]: 'root' | 'link'; |
139 | 151 | } |
140 | 152 |
|
141 | 153 | interface ComponentsPropsList { |
|
0 commit comments