@@ -11,6 +11,7 @@ import {
11
11
} from "../__tests__/DialogDataTestIds" ;
12
12
import useSwitch from "../../../hooks/useSwitch" ;
13
13
import "./Dialog.stories.scss" ;
14
+ import { HideShowEvent } from "../../../constants/dialog" ;
14
15
15
16
const metaSettings = createStoryMetaSettingsDecorator ( {
16
17
component : Dialog ,
@@ -19,14 +20,30 @@ const metaSettings = createStoryMetaSettingsDecorator({
19
20
actionPropsArray : [ ] // List the component's actions here
20
21
} ) ;
21
22
23
+ const showHideArgTypes = {
24
+ options : Object . values ( HideShowEvent ) ,
25
+ control : {
26
+ type : "multi-select"
27
+ } ,
28
+ table : {
29
+ type : {
30
+ summary : Object . values ( HideShowEvent ) . join ( " | " )
31
+ }
32
+ }
33
+ } ;
34
+
22
35
export default {
23
36
title : "Popover/Dialog" ,
24
37
component : Dialog ,
25
- argTypes : metaSettings . argTypes ,
38
+ argTypes : {
39
+ ...metaSettings . argTypes ,
40
+ hideTrigger : showHideArgTypes ,
41
+ showTrigger : showHideArgTypes
42
+ } ,
26
43
decorators : metaSettings . decorators
27
44
} ;
28
45
29
- const dialogTemplate = ( { shouldShowOnMount, position, ...dialogProps } ) => {
46
+ const dialogTemplate = ( { showTrigger , hideTrigger , shouldShowOnMount = true , position, ...dialogProps } ) => {
30
47
// for prevent dialog to move while scrolling
31
48
const modifiers = [
32
49
{
@@ -40,10 +57,10 @@ const dialogTemplate = ({ shouldShowOnMount, position, ...dialogProps }) => {
40
57
< div className = "monday-storybook-dialog--story-padding" >
41
58
< Dialog
42
59
modifiers = { modifiers }
43
- shouldShowOnMount = { shouldShowOnMount || true }
60
+ shouldShowOnMount = { shouldShowOnMount }
44
61
{ ...dialogProps }
45
- showTrigger = { [ Dialog . hideShowTriggers . CLICK ] }
46
- hideTrigger = { [ Dialog . hideShowTriggers . CLICK ] }
62
+ showTrigger = { showTrigger || [ Dialog . hideShowTriggers . CLICK ] }
63
+ hideTrigger = { hideTrigger || [ Dialog . hideShowTriggers . CLICK ] }
47
64
position = { position || Dialog . positions . RIGHT }
48
65
content = {
49
66
< DialogContentContainer >
@@ -59,16 +76,12 @@ const dialogTemplate = ({ shouldShowOnMount, position, ...dialogProps }) => {
59
76
60
77
export const Overview = {
61
78
render : dialogTemplate . bind ( { } ) ,
62
-
79
+ name : "Overview" ,
63
80
parameters : {
64
81
docs : {
65
- source : {
66
- type : "code"
67
- }
82
+ liveEdit : { isEnabled : false }
68
83
}
69
- } ,
70
-
71
- name : "Overview"
84
+ }
72
85
} ;
73
86
74
87
export const Positions = {
@@ -171,7 +184,14 @@ export const Positions = {
171
184
) ;
172
185
} ,
173
186
174
- name : "Positions"
187
+ name : "Positions" ,
188
+ parameters : {
189
+ docs : {
190
+ liveEdit : {
191
+ scope : { useSwitch, ExampleContent }
192
+ }
193
+ }
194
+ }
175
195
} ;
176
196
177
197
export const ShowTriggers = {
@@ -273,6 +293,11 @@ export const ShowTriggers = {
273
293
parameters : {
274
294
chromatic : {
275
295
pauseAnimationAtEnd : true
296
+ } ,
297
+ docs : {
298
+ liveEdit : {
299
+ scope : { useSwitch, ExampleContent }
300
+ }
276
301
}
277
302
}
278
303
} ;
@@ -481,6 +506,18 @@ export const HideTriggers = {
481
506
parameters : {
482
507
chromatic : {
483
508
pauseAnimationAtEnd : true
509
+ } ,
510
+ docs : {
511
+ liveEdit : {
512
+ scope : {
513
+ useSwitch,
514
+ ExampleContent,
515
+ HIDE_TRIGGERS_CONTAINER ,
516
+ CLICK_OUTSIDE_DIALOG ,
517
+ CLICK_OUTSIDE_DIALOG_BUTTON ,
518
+ CONTEXT_MENU_DIALOG
519
+ }
520
+ }
484
521
}
485
522
}
486
523
} ;
@@ -512,7 +549,14 @@ export const ControlledDialog = {
512
549
) ;
513
550
} ,
514
551
515
- name : "Controlled Dialog"
552
+ name : "Controlled Dialog" ,
553
+ parameters : {
554
+ docs : {
555
+ liveEdit : {
556
+ scope : { useSwitch }
557
+ }
558
+ }
559
+ }
516
560
} ;
517
561
518
562
export const DialogWithTooltip = {
@@ -548,7 +592,14 @@ export const DialogWithTooltip = {
548
592
) ;
549
593
} ,
550
594
551
- name : "Dialog with tooltip"
595
+ name : "Dialog with tooltip" ,
596
+ parameters : {
597
+ docs : {
598
+ liveEdit : {
599
+ scope : { ExampleContent, Info }
600
+ }
601
+ }
602
+ }
552
603
} ;
553
604
554
605
export const DisableScrollWhenDialogOpen = {
@@ -596,5 +647,12 @@ export const DisableScrollWhenDialogOpen = {
596
647
) ;
597
648
} ,
598
649
599
- name : "Disable scroll when dialog open"
650
+ name : "Disable scroll when dialog open" ,
651
+ parameters : {
652
+ docs : {
653
+ liveEdit : {
654
+ scope : { ExampleContent, useSwitch }
655
+ }
656
+ }
657
+ }
600
658
} ;
0 commit comments