@@ -19,16 +19,17 @@ interface ValueConfig<T, Q> {
1919}
2020
2121interface FormSelectProps < T , Q > extends ValueConfig < T , Q > {
22+ id ?: string ;
2223 onChange : OnChangeListener ;
2324 style ?: CSSProperties ;
2425}
2526
2627/**
2728 * Combobox component that takes in any object array as data. Each item of the array is rendered as an item, and the key and values are obtained by looking into the object by a specified key.
2829 */
29- export default function FormSelect < T > ( { onChange, style, ...restProps } : FormSelectProps < T , T > ) {
30+ export default function FormSelect < T > ( { id , onChange, style, ...restProps } : FormSelectProps < T , T > ) {
3031 return (
31- < FormSelectBody onChange = { onChange } style = { style } >
32+ < FormSelectBody id = { id } onChange = { onChange } style = { style } >
3233 < FormSelectGroup { ...restProps } />
3334 </ FormSelectBody >
3435 ) ;
@@ -37,9 +38,9 @@ export default function FormSelect<T>({ onChange, style, ...restProps }: FormSel
3738/**
3839 * Similar to {@link FormSelect}, but the top-level elements are actually groups.
3940 */
40- export function FormSelectWithGroups < T > ( { values, keyProperty, titleProperty, currentValue, onChange } : FormSelectProps < T , FormSelectGroup < T > > ) {
41+ export function FormSelectWithGroups < T > ( { id , values, keyProperty, titleProperty, currentValue, onChange } : FormSelectProps < T , FormSelectGroup < T > > ) {
4142 return (
42- < FormSelectBody onChange = { onChange } >
43+ < FormSelectBody id = { id } onChange = { onChange } >
4344 { values . map ( ( { title, items } ) => {
4445 return (
4546 < optgroup label = { title } >
@@ -51,9 +52,10 @@ export function FormSelectWithGroups<T>({ values, keyProperty, titleProperty, cu
5152 )
5253}
5354
54- function FormSelectBody ( { children, onChange, style } : { children : ComponentChildren , onChange : OnChangeListener , style ?: CSSProperties } ) {
55+ function FormSelectBody ( { id , children, onChange, style } : { id ?: string , children : ComponentChildren , onChange : OnChangeListener , style ?: CSSProperties } ) {
5556 return (
5657 < select
58+ id = { id }
5759 class = "form-select"
5860 onChange = { e => onChange ( ( e . target as HTMLInputElement ) . value ) }
5961 style = { style }
0 commit comments