@@ -14,24 +14,28 @@ import { cx } from "../tools/cx";
1414import { fr } from "../fr" ;
1515import { useAnalyticsId } from "../tools/useAnalyticsId" ;
1616
17- export type FieldsetProps = FieldsetProps . Radio | FieldsetProps . Checkbox ;
17+ export type FieldsetProps = FieldsetProps . Radio | FieldsetProps . Checkbox | FieldsetProps . RadioRich ;
1818
1919export namespace FieldsetProps {
20+ export type RegularOption = {
21+ label : ReactNode ;
22+ hintText ?: ReactNode ;
23+ nativeInputProps : DetailedHTMLProps <
24+ InputHTMLAttributes < HTMLInputElement > ,
25+ HTMLInputElement
26+ > ;
27+ } ;
28+ export type RadioRichOption = RegularOption & {
29+ illustration : ReactNode ;
30+ } ;
2031 export type Common = {
2132 className ?: string ;
2233 id ?: string ;
2334 classes ?: Partial < Record < "root" | "legend" | "content" , string > > ;
2435 style ?: CSSProperties ;
2536 legend ?: ReactNode ;
2637 hintText ?: ReactNode ;
27- options : {
28- label : ReactNode ;
29- hintText ?: ReactNode ;
30- nativeInputProps : DetailedHTMLProps <
31- InputHTMLAttributes < HTMLInputElement > ,
32- HTMLInputElement
33- > ;
34- } [ ] ;
38+
3539 /** Default: "vertical" */
3640 orientation ?: "vertical" | "horizontal" ;
3741 /** Default: "default" */
@@ -50,11 +54,22 @@ export namespace FieldsetProps {
5054 export type Radio = Common & {
5155 type : "radio" ;
5256 name ?: string ;
57+ rich ?: false ;
58+ options : RegularOption [ ] ;
5359 } ;
5460
5561 export type Checkbox = Common & {
5662 type : "checkbox" ;
5763 name ?: never ;
64+ rich ?: false ;
65+ options : RegularOption [ ] ;
66+ } ;
67+
68+ export type RadioRich = Common & {
69+ type : "radio" ;
70+ name ?: string ;
71+ rich : true ;
72+ options : RadioRichOption [ ] ;
5873 } ;
5974}
6075
@@ -76,6 +91,7 @@ export const Fieldset = memo(
7691 type,
7792 name : name_props ,
7893 small = false ,
94+ rich,
7995 ...rest
8096 } = props ;
8197
@@ -147,7 +163,11 @@ export const Fieldset = memo(
147163 < div className = { cx ( fr . cx ( "fr-fieldset__content" ) , classes . content ) } >
148164 { options . map ( ( { label, hintText, nativeInputProps } , i ) => (
149165 < div
150- className = { fr . cx ( `fr-${ type } -group` , small && `fr-${ type } -group--sm` ) }
166+ className = { fr . cx (
167+ `fr-${ type } -group` ,
168+ rich && "fr-radio-rich" ,
169+ small && `fr-${ type } -group--sm`
170+ ) }
151171 key = { i }
152172 >
153173 < input
@@ -162,6 +182,11 @@ export const Fieldset = memo(
162182 < span className = { fr . cx ( "fr-hint-text" ) } > { hintText } </ span >
163183 ) }
164184 </ label >
185+ { rich && (
186+ < div className = { fr . cx ( "fr-radio-rich__img" ) } >
187+ { options [ i ] . illustration }
188+ </ div >
189+ ) }
165190 </ div >
166191 ) ) }
167192 </ div >
0 commit comments