@@ -28,25 +28,22 @@ import {
28
28
FieldValidationHint ,
29
29
FieldLegend ,
30
30
FieldSet ,
31
- FieldWrapper ,
32
- FieldDescription ,
33
31
} from '../Field/index.js' ;
34
32
import {
35
33
AccessibilityError ,
36
34
isSufficientlyLabelled ,
37
35
} from '../../util/errors.js' ;
38
36
import { isEmpty } from '../../util/helpers.js' ;
39
- import { utilClasses } from '../../styles/utility.js' ;
40
37
import { clsx } from '../../styles/clsx.js' ;
41
-
42
38
import {
43
- RadioButtonInput ,
44
- type RadioButtonInputProps ,
45
- } from './RadioButtonInput.js' ;
39
+ RadioButton ,
40
+ type RadioButtonProps ,
41
+ } from '../RadioButton/RadioButton.js' ;
42
+
46
43
import classes from './RadioButtonGroup.module.css' ;
47
44
48
45
type Option = Omit <
49
- RadioButtonInputProps ,
46
+ RadioButtonProps ,
50
47
'onChange' | 'onBlur' | 'name' | 'children'
51
48
> & {
52
49
/**
@@ -73,12 +70,12 @@ export interface RadioButtonGroupProps
73
70
* A callback that is called when any of the inputs change their values.
74
71
* Passed on to the RadioButtons.
75
72
*/
76
- onChange ?: RadioButtonInputProps [ 'onChange' ] ;
73
+ onChange ?: RadioButtonProps [ 'onChange' ] ;
77
74
/**
78
75
* A callback that is called when any of the inputs lose focus.
79
76
* Passed on to the RadioButtons.
80
77
*/
81
- onBlur ?: RadioButtonInputProps [ 'onBlur' ] ;
78
+ onBlur ?: RadioButtonProps [ 'onBlur' ] ;
82
79
/**
83
80
* A visually hidden description of the selector group for screen readers.
84
81
*/
@@ -91,11 +88,11 @@ export interface RadioButtonGroupProps
91
88
/**
92
89
* The value of the currently checked RadioButton.
93
90
*/
94
- value ?: RadioButtonInputProps [ 'value' ] ;
91
+ value ?: RadioButtonProps [ 'value' ] ;
95
92
/**
96
93
* The value of the currently checked RadioButton.
97
94
*/
98
- defaultValue ?: RadioButtonInputProps [ 'value' ] ;
95
+ defaultValue ?: RadioButtonProps [ 'value' ] ;
99
96
/**
100
97
* The ref to the HTML DOM element
101
98
*/
@@ -194,64 +191,22 @@ export const RadioButtonGroup = forwardRef(
194
191
/>
195
192
</ FieldLegend >
196
193
< div className = { classes . base } >
197
- { options . map (
198
- ( {
199
- className,
200
- style,
201
- label : optionLabel ,
202
- description,
203
- 'aria-describedby' : describedBy ,
204
- ...option
205
- } ) => {
206
- const optionDescriptionId = useId ( ) ;
207
- const optionDescriptionIds = clsx (
208
- description && optionDescriptionId ,
209
- describedBy ,
210
- ) ;
211
-
212
- return (
213
- < FieldWrapper
214
- key = { option . value ?. toString ( ) || optionLabel }
215
- className = { className }
216
- style = { style }
217
- disabled = { disabled || option . disabled }
218
- >
219
- < RadioButtonInput
220
- { ...option }
221
- name = { name }
222
- onChange = { onChange }
223
- onBlur = { onBlur }
224
- disabled = { disabled || option . disabled }
225
- checked = { value ? option . value === value : option . checked }
226
- aria-describedby = { optionDescriptionIds }
227
- defaultChecked = {
228
- defaultValue
229
- ? option . value === defaultValue
230
- : option . defaultChecked
231
- }
232
- align = "start"
233
- >
234
- < span className = { classes [ 'label-text' ] } >
235
- { optionLabel }
236
- { description && (
237
- < FieldDescription aria-hidden = "true" >
238
- { description }
239
- </ FieldDescription >
240
- ) }
241
- </ span >
242
- </ RadioButtonInput >
243
- { description && (
244
- < p
245
- id = { optionDescriptionId }
246
- className = { utilClasses . hideVisually }
247
- >
248
- { description }
249
- </ p >
250
- ) }
251
- </ FieldWrapper >
252
- ) ;
253
- } ,
254
- ) }
194
+ { options . map ( ( option ) => (
195
+ < RadioButton
196
+ { ...option }
197
+ key = { option . value ?. toString ( ) || option . label }
198
+ disabled = { disabled || option . disabled }
199
+ name = { name }
200
+ onChange = { onChange }
201
+ onBlur = { onBlur }
202
+ checked = { value ? option . value === value : option . checked }
203
+ defaultChecked = {
204
+ defaultValue
205
+ ? option . value === defaultValue
206
+ : option . defaultChecked
207
+ }
208
+ />
209
+ ) ) }
255
210
</ div >
256
211
< FieldValidationHint
257
212
id = { validationHintId }
0 commit comments