10
10
* governing permissions and limitations under the License.
11
11
*/
12
12
13
+ import { action } from '@storybook/addon-actions' ;
13
14
import { Button , Dialog , DialogTrigger , FieldError , Form , Label , Modal , ModalOverlay , Radio , RadioGroup } from 'react-aria-components' ;
14
- import { Meta , StoryFn } from '@storybook/react' ;
15
+ import { Meta , StoryFn , StoryObj } from '@storybook/react' ;
15
16
import React , { useState } from 'react' ;
16
17
import styles from '../example/index.css' ;
17
18
import './styles.css' ;
@@ -22,25 +23,34 @@ export default {
22
23
} as Meta < typeof RadioGroup > ;
23
24
24
25
export type RadioGroupStory = StoryFn < typeof RadioGroup > ;
26
+ export type RadioGroupStoryObj = StoryObj < typeof RadioGroup > ;
25
27
26
- export const RadioGroupExample : RadioGroupStory = ( ) => {
27
- return (
28
- < RadioGroup
29
- data-testid = "radio-group-example"
30
- className = { styles . radiogroup } >
31
- < Label > Favorite pet</ Label >
32
- < Radio className = { styles . radio } value = "dogs" data-testid = "radio-dog" > Dog</ Radio >
33
- < Radio className = { styles . radio } value = "cats" > Cat</ Radio >
34
- < Radio className = { styles . radio } value = "dragon" > Dragon</ Radio >
35
- </ RadioGroup >
36
- ) ;
28
+ export const RadioGroupExample : RadioGroupStoryObj = {
29
+ render : ( props ) => {
30
+ return (
31
+ < RadioGroup
32
+ { ...props }
33
+ data-testid = "radio-group-example"
34
+ className = { styles . radiogroup } >
35
+ < Label > Favorite pet</ Label >
36
+ < Radio onFocus = { action ( 'radio focus' ) } onBlur = { action ( 'radio blur' ) } className = { styles . radio } value = "dogs" data-testid = "radio-dog" > Dog</ Radio >
37
+ < Radio onFocus = { action ( 'radio focus' ) } onBlur = { action ( 'radio blur' ) } className = { styles . radio } value = "cats" > Cat</ Radio >
38
+ < Radio onFocus = { action ( 'radio focus' ) } onBlur = { action ( 'radio blur' ) } className = { styles . radio } value = "dragon" > Dragon</ Radio >
39
+ </ RadioGroup >
40
+ ) ;
41
+ } ,
42
+ args : {
43
+ onFocus : action ( 'onFocus' ) ,
44
+ onBlur : action ( 'onBlur' )
45
+ }
37
46
} ;
38
47
39
- export const RadioGroupControlledExample : RadioGroupStory = ( ) => {
48
+ export const RadioGroupControlledExample : RadioGroupStory = ( props ) => {
40
49
let [ selected , setSelected ] = useState < string | null > ( null ) ;
41
50
42
51
return (
43
52
< RadioGroup
53
+ { ...props }
44
54
data-testid = "radio-group-example"
45
55
className = { styles . radiogroup }
46
56
value = { selected }
@@ -53,7 +63,7 @@ export const RadioGroupControlledExample: RadioGroupStory = () => {
53
63
) ;
54
64
} ;
55
65
56
- export const RadioGroupInDialogExample : RadioGroupStory = ( ) => {
66
+ export const RadioGroupInDialogExample : RadioGroupStory = ( props ) => {
57
67
return (
58
68
< DialogTrigger >
59
69
< Button > Open dialog</ Button >
@@ -88,6 +98,7 @@ export const RadioGroupInDialogExample: RadioGroupStory = () => {
88
98
< div style = { { display : 'flex' , flexDirection : 'row' , gap : 20 } } >
89
99
< div >
90
100
< RadioGroup
101
+ { ...props }
91
102
data-testid = "radio-group-example"
92
103
className = { styles . radiogroup } >
93
104
< Label > Favorite pet</ Label >
@@ -142,10 +153,11 @@ export const RadioGroupInDialogExample: RadioGroupStory = () => {
142
153
) ;
143
154
} ;
144
155
145
- export const RadioGroupSubmitExample : RadioGroupStory = ( ) => {
156
+ export const RadioGroupSubmitExample : RadioGroupStory = ( props ) => {
146
157
return (
147
158
< Form >
148
159
< RadioGroup
160
+ { ...props }
149
161
className = { styles . radiogroup }
150
162
data-testid = "radio-group-example"
151
163
isRequired >
0 commit comments