@@ -51,38 +51,17 @@ export default {
51
51
control : "text" ,
52
52
if : { arg : "shouldTruncate" , truthy : true } ,
53
53
} ,
54
- hasActions : {
55
- name : "Has switches" ,
56
- description : "If multiple selection is enabled, show switches instead of checkboxes to show which items have been selected" ,
57
- type : { name : "boolean" } ,
58
- table : {
59
- type : { summary : "boolean" } ,
60
- category : "Selection" ,
61
- } ,
62
- control : "boolean" ,
63
- if : { arg : "selectionMode" , eq : "multiple" } ,
64
- } ,
65
54
labelledby : { table : { disable : true } } ,
66
55
items : { table : { disable : true } } ,
67
56
role : { table : { disable : true } } ,
68
57
subrole : { table : { disable : true } } ,
69
- hasDividers : {
70
- name : "Has dividers" ,
71
- description : "Shows dividers between sections" ,
72
- table : {
73
- type : { summary : "boolean" } ,
74
- category : "Component" ,
75
- } ,
76
- control : "boolean" ,
77
- } ,
78
58
} ,
79
59
args : {
80
60
rootClass : "spectrum-Menu" ,
81
61
selectionMode : "none" ,
82
62
size : "m" ,
83
63
shouldTruncate : false ,
84
64
maxInlineSize : "150px" ,
85
- hasDividers : false ,
86
65
} ,
87
66
parameters : {
88
67
actions : {
@@ -167,12 +146,22 @@ const ChromaticMenuWithVariants = (args) => {
167
146
168
147
export const MenuWithVariants = ( args ) => window . isChromatic ( ) ?
169
148
ChromaticMenuWithVariants ( args ) : Template ( args ) ;
149
+ MenuWithVariants . argTypes = {
150
+ hasDividers : {
151
+ name : "Has dividers" ,
152
+ description : "Shows dividers between sections" ,
153
+ table : {
154
+ type : { summary : "boolean" } ,
155
+ category : "Component" ,
156
+ } ,
157
+ control : "boolean" ,
158
+ } ,
159
+ } ;
170
160
MenuWithVariants . args = {
171
161
role : "listbox" ,
172
162
subrole : "option" ,
173
163
customStyles : { maxWidth : "400px" } ,
174
164
selectionMode : "none" ,
175
- hasActions : false ,
176
165
hasDividers : false ,
177
166
items : [
178
167
{
@@ -288,6 +277,9 @@ MenuWithVariants.args = {
288
277
} ;
289
278
290
279
export const Collapsible = Template . bind ( { } ) ;
280
+ Collapsible . argTypes = {
281
+ selectionMode : { table : { disable : true } } ,
282
+ } ;
291
283
Collapsible . args = {
292
284
shouldTruncate : true ,
293
285
items : [
@@ -358,6 +350,18 @@ Collapsible.args = {
358
350
} ;
359
351
360
352
export const TraySubmenu = Template . bind ( { } ) ;
353
+ TraySubmenu . argTypes = {
354
+ selectionMode : { table : { disable : true } } ,
355
+ isTraySubmenu : {
356
+ name : "Is tray submenu" ,
357
+ type : { name : "boolean" } ,
358
+ table : {
359
+ type : { summary : "boolean" } ,
360
+ category : "Component" ,
361
+ } ,
362
+ control : "boolean" ,
363
+ }
364
+ } ;
361
365
TraySubmenu . args = {
362
366
selectionMode : "multiple" ,
363
367
customStyles : {
@@ -481,6 +485,41 @@ const MultiCheckboxSelectedStates = (args) => {
481
485
` ;
482
486
} ;
483
487
488
+ const WithValueStates = ( args ) => {
489
+ const baseValueArgs = { ...args , hasValue : true , singleItemValue : "Value" } ;
490
+ const valueData = [
491
+ {
492
+ stateTitle : "With value" ,
493
+ args : { ...baseValueArgs } ,
494
+ } ,
495
+ {
496
+ stateTitle : "With value, disabled" ,
497
+ args : { ...baseValueArgs , isDisabled : true } ,
498
+ } ,
499
+ {
500
+ stateTitle : "With value and switch" ,
501
+ args : { ...baseValueArgs , hasActions : true } ,
502
+ } ,
503
+ {
504
+ stateTitle : "With value, truncated label" ,
505
+ args : { ...baseValueArgs , shouldTruncate : true , maxInlineSize : "195px" , items : [ { label : "Truncated label on menu item" } ] } ,
506
+ } ,
507
+ ] ;
508
+
509
+ return valueData . map ( ( valueItem ) => html `
510
+ < div >
511
+ ${ Typography ( {
512
+ semantics : "detail" ,
513
+ size : "s" ,
514
+ content : [ valueItem . stateTitle ] ,
515
+ } ) }
516
+ < div >
517
+ ${ Template ( { ...args , ...valueItem . args } ) }
518
+ </ div >
519
+ </ div >
520
+ ` ) ;
521
+ } ;
522
+
484
523
const ChromaticMenuItem = ( args ) => {
485
524
const sectionData = [
486
525
{
@@ -515,6 +554,10 @@ const ChromaticMenuItem = (args) => {
515
554
sectionTitle : "Multi-selection with switches and switch label" ,
516
555
sectionMarkup : MultiCheckboxSelectedStates ( { ...args , selectionMode : "multiple" , hasActions : true , items : [ { label : "Menu item" , value : "switch label" } ] } ) ,
517
556
} ,
557
+ {
558
+ sectionTitle : "With values" ,
559
+ sectionMarkup : WithValueStates ( args ) ,
560
+ } ,
518
561
{
519
562
sectionTitle : "Sizes" ,
520
563
sectionMarkup : Sizes ( { ...args , items : [ { label : "With sizing" , iconName : "Share" } ] } ) ,
@@ -549,13 +592,15 @@ MenuItemOnly.args = {
549
592
} ,
550
593
] ,
551
594
hasActions : false ,
595
+ hasValue : false ,
552
596
hasItemDescription : false ,
553
597
isDisabled : false ,
554
598
isItemActive : false ,
555
599
isItemFocused : false ,
556
600
isItemHovered : false ,
557
601
isItemSelected : false ,
558
602
singleItemDescription : "Menu item description" ,
603
+ singleItemValue : "Value" ,
559
604
} ;
560
605
MenuItemOnly . argTypes = {
561
606
isItemActive : { table : { disable : true } } ,
@@ -594,6 +639,17 @@ MenuItemOnly.argTypes = {
594
639
control : "boolean" ,
595
640
} ,
596
641
} ,
642
+ hasActions : {
643
+ name : "Has switches" ,
644
+ description : "If multiple selection is enabled, show switches instead of checkboxes to show which items have been selected" ,
645
+ type : { name : "boolean" } ,
646
+ table : {
647
+ type : { summary : "boolean" } ,
648
+ category : "Selection" ,
649
+ } ,
650
+ control : "boolean" ,
651
+ if : { arg : "selectionMode" , eq : "multiple" } ,
652
+ } ,
597
653
singleItemDescription : {
598
654
name : "Menu item description for single menu item" ,
599
655
type : { name : "text" , required : true } ,
@@ -604,6 +660,25 @@ MenuItemOnly.argTypes = {
604
660
control : "text" ,
605
661
if : { arg : "hasItemDescription" , truthy : true } ,
606
662
} ,
663
+ hasValue : {
664
+ name : "Has value text" ,
665
+ type : { name : "boolean" } ,
666
+ table : {
667
+ type : { summary : "boolean" } ,
668
+ category : "Content" ,
669
+ control : "boolean" ,
670
+ } ,
671
+ } ,
672
+ singleItemValue : {
673
+ name : "Menu item value for single menu item" ,
674
+ type : { name : "text" , required : true } ,
675
+ table : {
676
+ type : { summary : "text" } ,
677
+ category : "Content" ,
678
+ } ,
679
+ control : "text" ,
680
+ if : { arg : "hasValue" , truthy : true } ,
681
+ } ,
607
682
} ;
608
683
609
684
// story used in Picker component
0 commit comments