11import React , {
22 memo ,
33 forwardRef ,
4- ReactNode ,
54 useId ,
6- type InputHTMLAttributes ,
7- type TextareaHTMLAttributes ,
5+ type CSSProperties ,
86 type DetailedHTMLProps ,
9- type CSSProperties
7+ type InputHTMLAttributes ,
8+ type LabelHTMLAttributes ,
9+ type ReactNode ,
10+ type TextareaHTMLAttributes
1011} from "react" ;
1112import { symToStr } from "tsafe/symToStr" ;
1213import { assert } from "tsafe/assert" ;
@@ -50,6 +51,11 @@ export namespace InputProps {
5051 InputHTMLAttributes < HTMLInputElement > ,
5152 HTMLInputElement
5253 > ;
54+ /** Props forwarded to the underlying <label /> element */
55+ nativeLabelProps ?: DetailedHTMLProps <
56+ LabelHTMLAttributes < HTMLInputElement > ,
57+ HTMLInputElement
58+ > ;
5359
5460 nativeTextAreaProps ?: never ;
5561 } ;
@@ -62,6 +68,11 @@ export namespace InputProps {
6268 TextareaHTMLAttributes < HTMLTextAreaElement > ,
6369 HTMLTextAreaElement
6470 > ;
71+ /** Props forwarded to the underlying <label /> element */
72+ nativeLabelProps ?: DetailedHTMLProps <
73+ LabelHTMLAttributes < HTMLTextAreaElement > ,
74+ HTMLTextAreaElement
75+ > ;
6576
6677 nativeInputProps ?: never ;
6778 } ;
@@ -89,6 +100,7 @@ export const Input = memo(
89100 nativeInputProps,
90101 addon,
91102 action,
103+ nativeLabelProps,
92104 ...rest
93105 } = props ;
94106
@@ -137,6 +149,7 @@ export const Input = memo(
137149 < label
138150 className = { cx ( fr . cx ( "fr-label" , hideLabel && "fr-sr-only" ) , classes . label ) }
139151 htmlFor = { inputId }
152+ { ...( nativeLabelProps as { } ) }
140153 >
141154 { label }
142155 { hintText !== undefined && < span className = "fr-hint-text" > { hintText } </ span > }
0 commit comments