@@ -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 : {
@@ -164,12 +143,22 @@ const ChromaticMenuWithVariants = (args) => {
164
143
165
144
export const MenuWithVariants = ( args ) => window . isChromatic ( ) ?
166
145
ChromaticMenuWithVariants ( args ) : Template ( args ) ;
146
+ MenuWithVariants . argTypes = {
147
+ hasDividers : {
148
+ name : "Has dividers" ,
149
+ description : "Shows dividers between sections" ,
150
+ table : {
151
+ type : { summary : "boolean" } ,
152
+ category : "Component" ,
153
+ } ,
154
+ control : "boolean" ,
155
+ } ,
156
+ } ;
167
157
MenuWithVariants . args = {
168
158
role : "listbox" ,
169
159
subrole : "option" ,
170
160
customStyles : { maxWidth : "400px" } ,
171
161
selectionMode : "none" ,
172
- hasActions : false ,
173
162
hasDividers : false ,
174
163
items : [
175
164
{
@@ -285,6 +274,9 @@ MenuWithVariants.args = {
285
274
} ;
286
275
287
276
export const Collapsible = Template . bind ( { } ) ;
277
+ Collapsible . argTypes = {
278
+ selectionMode : { table : { disable : true } } ,
279
+ } ;
288
280
Collapsible . args = {
289
281
shouldTruncate : true ,
290
282
items : [
@@ -355,6 +347,18 @@ Collapsible.args = {
355
347
} ;
356
348
357
349
export const TraySubmenu = Template . bind ( { } ) ;
350
+ TraySubmenu . argTypes = {
351
+ selectionMode : { table : { disable : true } } ,
352
+ isTraySubmenu : {
353
+ name : "Is tray submenu" ,
354
+ type : { name : "boolean" } ,
355
+ table : {
356
+ type : { summary : "boolean" } ,
357
+ category : "Component" ,
358
+ } ,
359
+ control : "boolean" ,
360
+ }
361
+ } ;
358
362
TraySubmenu . args = {
359
363
selectionMode : "multiple" ,
360
364
customStyles : {
@@ -478,6 +482,41 @@ const MultiCheckboxSelectedStates = (args) => {
478
482
` ;
479
483
} ;
480
484
485
+ const WithValueStates = ( args ) => {
486
+ const baseValueArgs = { ...args , hasValue : true , value : "Value" } ;
487
+ const valueData = [
488
+ {
489
+ stateTitle : "With value" ,
490
+ args : { ...baseValueArgs } ,
491
+ } ,
492
+ {
493
+ stateTitle : "With value, disabled" ,
494
+ args : { ...baseValueArgs , isDisabled : true } ,
495
+ } ,
496
+ {
497
+ stateTitle : "With value and switch" ,
498
+ args : { ...baseValueArgs , hasActions : true } ,
499
+ } ,
500
+ {
501
+ stateTitle : "With value, truncated label" ,
502
+ args : { ...baseValueArgs , shouldTruncate : true , maxInlineSize : "195px" , items : [ { label : "Truncated label on menu item" } ] } ,
503
+ } ,
504
+ ] ;
505
+
506
+ return valueData . map ( ( valueItem ) => html `
507
+ < div >
508
+ ${ Typography ( {
509
+ semantics : "detail" ,
510
+ size : "s" ,
511
+ content : [ valueItem . stateTitle ] ,
512
+ } ) }
513
+ < div >
514
+ ${ Template ( { ...args , ...valueItem . args } ) }
515
+ </ div >
516
+ </ div >
517
+ ` ) ;
518
+ } ;
519
+
481
520
const ChromaticMenuItem = ( args ) => {
482
521
const sectionData = [
483
522
{
@@ -512,6 +551,10 @@ const ChromaticMenuItem = (args) => {
512
551
sectionTitle : "Multi-selection with switches and switch label" ,
513
552
sectionMarkup : MultiCheckboxSelectedStates ( { ...args , selectionMode : "multiple" , hasActions : true , items : [ { label : "Menu item" , value : "switch label" } ] } ) ,
514
553
} ,
554
+ {
555
+ sectionTitle : "With values" ,
556
+ sectionMarkup : WithValueStates ( args ) ,
557
+ } ,
515
558
{
516
559
sectionTitle : "Sizes" ,
517
560
sectionMarkup : Sizes ( { ...args , items : [ { label : "With sizing" , iconName : "Share" } ] } ) ,
@@ -546,13 +589,15 @@ MenuItemOnly.args = {
546
589
} ,
547
590
] ,
548
591
hasActions : false ,
592
+ hasValue : false ,
549
593
hasItemDescription : false ,
550
594
isDisabled : false ,
551
595
isItemActive : false ,
552
596
isItemFocused : false ,
553
597
isItemHovered : false ,
554
598
isItemSelected : false ,
555
599
singleItemDescription : "Menu item description" ,
600
+ singleItemValue : "Value" ,
556
601
} ;
557
602
MenuItemOnly . argTypes = {
558
603
isItemActive : { table : { disable : true } } ,
@@ -582,6 +627,7 @@ MenuItemOnly.argTypes = {
582
627
} ,
583
628
if : { arg : "selectionMode" , not : { eq : "none" } } ,
584
629
} ,
630
+ hasDividers : { table : { disable : true } } ,
585
631
hasItemDescription : {
586
632
name : "Has menu item description" ,
587
633
type : { name : "boolean" } ,
@@ -591,6 +637,17 @@ MenuItemOnly.argTypes = {
591
637
control : "boolean" ,
592
638
} ,
593
639
} ,
640
+ hasActions : {
641
+ name : "Has switches" ,
642
+ description : "If multiple selection is enabled, show switches instead of checkboxes to show which items have been selected" ,
643
+ type : { name : "boolean" } ,
644
+ table : {
645
+ type : { summary : "boolean" } ,
646
+ category : "Selection" ,
647
+ } ,
648
+ control : "boolean" ,
649
+ if : { arg : "selectionMode" , eq : "multiple" } ,
650
+ } ,
594
651
singleItemDescription : {
595
652
name : "Menu item description for single menu item" ,
596
653
type : { name : "text" , required : true } ,
@@ -601,6 +658,25 @@ MenuItemOnly.argTypes = {
601
658
control : "text" ,
602
659
if : { arg : "hasItemDescription" , truthy : true } ,
603
660
} ,
661
+ hasValue : {
662
+ name : "Has value text" ,
663
+ type : { name : "boolean" } ,
664
+ table : {
665
+ type : { summary : "boolean" } ,
666
+ category : "Content" ,
667
+ control : "boolean" ,
668
+ } ,
669
+ } ,
670
+ singleItemValue : {
671
+ name : "Menu item value for single menu item" ,
672
+ type : { name : "text" , required : true } ,
673
+ table : {
674
+ type : { summary : "text" } ,
675
+ category : "Content" ,
676
+ } ,
677
+ control : "text" ,
678
+ if : { arg : "hasValue" , truthy : true } ,
679
+ } ,
604
680
} ;
605
681
606
682
// story used in Picker component
0 commit comments