File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import {
1111 Button ,
1212 Radio ,
1313 RadioGroup ,
14+ ListBox ,
15+ Item ,
1416} from '../src' ;
1517
1618const meta : Meta = {
@@ -154,3 +156,41 @@ export const Controlled = () => {
154156 </ Provider >
155157 ) ;
156158} ;
159+
160+ export const DropdownWithListBox = ( ) => {
161+ const [ isOpen , setIsOpen ] = useState < boolean > ( false ) ;
162+ const [ selectedKeys , setSelectedKeys ] = useState ( [ 'dogs' ] ) ;
163+ return (
164+ < Provider >
165+ < Dropdown
166+ triggerProps = { {
167+ isOpen : isOpen ,
168+ onOpenChange : open => setIsOpen ( open ) ,
169+ } }
170+ menu = {
171+ < ListBox
172+ style = { { width : 200 } }
173+ aria-label = "Pick your favorite"
174+ selectionMode = "multiple"
175+ selectedKeys = { selectedKeys }
176+ onSelectionChange = { selected =>
177+ // @ts -ignore we know the keys are strings
178+ setSelectedKeys ( Array . from ( selected ) )
179+ }
180+ >
181+ < Item key = "Aardvark" > Aardvark</ Item >
182+ < Item key = "Kangaroo" > Kangaroo</ Item >
183+ < Item key = "Snake" > Snake</ Item >
184+ < Item key = "Danni" > Danni</ Item >
185+ < Item key = "Devon" > Devon</ Item >
186+ < Item key = "Ross" > Ross</ Item >
187+ </ ListBox >
188+ }
189+ >
190+ { selectedKeys . length < 2
191+ ? selectedKeys . join ( ', ' )
192+ : `${ selectedKeys . length } selected` }
193+ </ Dropdown >
194+ </ Provider >
195+ ) ;
196+ } ;
Original file line number Diff line number Diff line change @@ -82,3 +82,22 @@ const ListBoxWithSections: Story<ListBoxProps<string>> = args => {
8282} ;
8383
8484export const listBoxWithSections = ListBoxWithSections . bind ( { } ) ;
85+
86+ const ListBoxMultiSelect : Story < ListBoxProps < string > > = args => {
87+ return (
88+ < ListBox
89+ style = { { width : 200 } }
90+ aria-label = "Pick your favorite"
91+ selectionMode = "multiple"
92+ >
93+ < Item key = "Aardvark" > Aardvark</ Item >
94+ < Item key = "Kangaroo" > Kangaroo</ Item >
95+ < Item key = "Snake" > Snake</ Item >
96+ < Item key = "Danni" > Danni</ Item >
97+ < Item key = "Devon" > Devon</ Item >
98+ < Item key = "Ross" > Ross</ Item >
99+ </ ListBox >
100+ ) ;
101+ } ;
102+
103+ export const listBoxMultiSelect = ListBoxMultiSelect . bind ( { } ) ;
You can’t perform that action at this time.
0 commit comments