@@ -34,6 +34,7 @@ const meta: any = {
3434 controls : {
3535 exclude : baseProps ,
3636 } ,
37+ layout : 'centered' ,
3738 } ,
3839 argTypes : {
3940 /* Content */
@@ -313,7 +314,13 @@ const herbs = [
313314 } ,
314315] ;
315316
316- const permissions = [
317+ interface Permission {
318+ key : string ;
319+ label : string ;
320+ description : string ;
321+ }
322+
323+ const permissions : Permission [ ] = [
317324 { key : 'read' , label : 'Read' , description : 'View content and data' } ,
318325 { key : 'write' , label : 'Write' , description : 'Create and edit content' } ,
319326 { key : 'delete' , label : 'Delete' , description : 'Remove content permanently' } ,
@@ -324,7 +331,7 @@ const permissions = [
324331 description : 'Review and approve content' ,
325332 } ,
326333 { key : 'share' , label : 'Share' , description : 'Share content with others' } ,
327- ] ;
334+ ] as const ;
328335
329336const languages = [
330337 {
@@ -400,15 +407,15 @@ export const SingleSelection: Story = {
400407
401408export const MultipleSelection : Story = {
402409 render : ( args ) => (
403- < FilterListBox { ...args } >
404- { permissions . map ( ( permission ) => (
410+ < FilterListBox < Permission > { ...args } items = { permissions } >
411+ { ( permission ) => (
405412 < FilterListBox . Item
406413 key = { permission . key }
407414 description = { permission . description }
408415 >
409416 { permission . label }
410417 </ FilterListBox . Item >
411- ) ) }
418+ ) }
412419 </ FilterListBox >
413420 ) ,
414421 args : {
@@ -543,15 +550,15 @@ WithHeaderAndFooter.args = {
543550
544551export const CheckableMultipleSelection : Story = {
545552 render : ( args ) => (
546- < FilterListBox { ...args } >
547- { permissions . map ( ( permission ) => (
553+ < FilterListBox { ...args } items = { permissions } >
554+ { ( permission : ( typeof permissions ) [ number ] ) => (
548555 < FilterListBox . Item
549556 key = { permission . key }
550557 description = { permission . description }
551558 >
552559 { permission . label }
553560 </ FilterListBox . Item >
554- ) ) }
561+ ) }
555562 </ FilterListBox >
556563 ) ,
557564 args : {
@@ -896,16 +903,17 @@ export const MultipleControlledExample: StoryFn<
896903 selectionMode = "multiple"
897904 isCheckable = { true }
898905 searchPlaceholder = "Filter permissions..."
906+ items = { permissions }
899907 onSelectionChange = { ( keys ) => setSelectedKeys ( keys as string [ ] ) }
900908 >
901- { permissions . map ( ( permission ) => (
909+ { ( permission : ( typeof permissions ) [ number ] ) => (
902910 < FilterListBox . Item
903911 key = { permission . key }
904912 description = { permission . description }
905913 >
906914 { permission . label }
907915 </ FilterListBox . Item >
908- ) ) }
916+ ) }
909917 </ FilterListBox >
910918
911919 < Text >
@@ -932,11 +940,10 @@ export const MultipleControlledExample: StoryFn<
932940} ;
933941
934942export const InForm : StoryFn = ( ) => {
935- const [ value , setValue ] = useState < string | null > ( null ) ;
936-
937943 return (
938944 < Form
939945 style = { { width : '400px' } }
946+ defaultValues = { { country : 'ca' } }
940947 onSubmit = { ( data ) => {
941948 alert ( `Form submitted with: ${ JSON . stringify ( data , null , 2 ) } ` ) ;
942949 } }
@@ -945,9 +952,7 @@ export const InForm: StoryFn = () => {
945952 isRequired
946953 name = "country"
947954 label = "Country"
948- value = { value }
949955 searchPlaceholder = "Search countries..."
950- onSelectionChange = { ( key ) => setValue ( key as string ) }
951956 >
952957 < FilterListBox . Section title = "North America" >
953958 < FilterListBox . Item key = "us" > United States</ FilterListBox . Item >
0 commit comments