@@ -4,8 +4,7 @@ import React, {
44 forwardRef ,
55 type ReactNode ,
66 type CSSProperties ,
7- type InputHTMLAttributes ,
8- type DetailedHTMLProps
7+ type ComponentProps
98} from "react" ;
109import { symToStr } from "tsafe/symToStr" ;
1110import { assert } from "tsafe/assert" ;
@@ -27,11 +26,9 @@ export namespace FieldsetProps {
2726 options : {
2827 label : ReactNode ;
2928 hintText ?: ReactNode ;
30- nativeInputProps : DetailedHTMLProps <
31- InputHTMLAttributes < HTMLInputElement > ,
32- HTMLInputElement
33- > ;
29+ nativeInputProps : ComponentProps < "input" > ;
3430 } [ ] ;
31+
3532 /** Default: "vertical" */
3633 orientation ?: "vertical" | "horizontal" ;
3734 /** Default: "default" */
@@ -47,9 +44,12 @@ export namespace FieldsetProps {
4744 small ?: boolean ;
4845 } ;
4946
50- export type Radio = Common & {
47+ export type Radio = Omit < Common , "options" > & {
5148 type : "radio" ;
5249 name ?: string ;
50+ options : ( Common [ "options" ] [ number ] & {
51+ illustration ?: ReactNode ;
52+ } ) [ ] ;
5353 } ;
5454
5555 export type Checkbox = Common & {
@@ -79,6 +79,10 @@ export const Fieldset = memo(
7979 ...rest
8080 } = props ;
8181
82+ const isRichRadio =
83+ type === "radio" &&
84+ options . find ( options => options . illustration !== undefined ) !== undefined ;
85+
8286 assert < Equals < keyof typeof rest , never > > ( ) ;
8387
8488 const id = useAnalyticsId ( {
@@ -145,9 +149,13 @@ export const Fieldset = memo(
145149 </ legend >
146150 ) }
147151 < div className = { cx ( fr . cx ( "fr-fieldset__content" ) , classes . content ) } >
148- { options . map ( ( { label, hintText, nativeInputProps } , i ) => (
152+ { options . map ( ( { label, hintText, nativeInputProps, ... rest } , i ) => (
149153 < div
150- className = { fr . cx ( `fr-${ type } -group` , small && `fr-${ type } -group--sm` ) }
154+ className = { fr . cx (
155+ `fr-${ type } -group` ,
156+ isRichRadio && "fr-radio-rich" ,
157+ small && `fr-${ type } -group--sm`
158+ ) }
151159 key = { i }
152160 >
153161 < input
@@ -162,6 +170,11 @@ export const Fieldset = memo(
162170 < span className = { fr . cx ( "fr-hint-text" ) } > { hintText } </ span >
163171 ) }
164172 </ label >
173+ { "illustration" in rest && (
174+ < div className = { fr . cx ( "fr-radio-rich__img" ) } >
175+ { rest . illustration }
176+ </ div >
177+ ) }
165178 </ div >
166179 ) ) }
167180 </ div >
0 commit comments