1+ import { useArgs } from 'storybook/preview-api' ;
2+
13import Select from '#ui/Common/Select' ;
24import StatelessSelect from '#ui/Common/Select/StatelessSelect' ;
35import * as OSIcons from '#ui/Icons/OperatingSystem' ;
@@ -10,22 +12,22 @@ type Meta = MetaObj<typeof Select>;
1012export const Default : Story = {
1113 args : {
1214 values : [ 'v20.8.0' , 'v19.9.0' , 'v18.18.0' , 'v17.9.1' , 'v16.20.2' ] ,
13- defaultValue : 'v16.20.2' ,
15+ value : 'v16.20.2' ,
1416 label : 'Node.js version' ,
1517 } ,
1618} ;
1719
1820export const WithoutLabel : Story = {
1921 args : {
2022 values : [ 'v20.8.0' , 'v19.9.0' , 'v18.18.0' , 'v17.9.1' , 'v16.20.2' ] ,
21- defaultValue : 'v16.20.2' ,
23+ value : 'v16.20.2' ,
2224 } ,
2325} ;
2426
2527export const WithScrollButtons : Story = {
2628 args : {
2729 values : Array . from ( { length : 100 } , ( _ , i ) => `Item ${ i } ` ) ,
28- defaultValue : 'Item 50' ,
30+ value : 'Item 50' ,
2931 } ,
3032} ;
3133
@@ -35,14 +37,8 @@ export const DropdownLabel: Story = {
3537 {
3638 label : 'Getting Started' ,
3739 items : [
38- {
39- value : 'section-1' ,
40- label : 'Getting Started' ,
41- } ,
42- {
43- value : 'section-2' ,
44- label : 'How to install Node.js' ,
45- } ,
40+ { value : 'section-1' , label : 'Getting Started' } ,
41+ { value : 'section-2' , label : 'How to install Node.js' } ,
4642 {
4743 value : 'section-3' ,
4844 label : 'How much JavaScript do you need to know to use Node.js?' ,
@@ -51,18 +47,12 @@ export const DropdownLabel: Story = {
5147 value : 'section-4' ,
5248 label : 'Differences between Node.js and the Browser' ,
5349 } ,
54- {
55- value : 'section-5' ,
56- label : 'The V8 JavaScript Engine' ,
57- } ,
50+ { value : 'section-5' , label : 'The V8 JavaScript Engine' } ,
5851 {
5952 value : 'section-6' ,
6053 label : 'An introduction to the npm package manager' ,
6154 } ,
62- {
63- value : 'section-7' ,
64- label : 'ECMAScript 2015 (ES6) and beyond' ,
65- } ,
55+ { value : 'section-7' , label : 'ECMAScript 2015 (ES6) and beyond' } ,
6656 {
6757 value : 'section-8' ,
6858 label : 'Node.js, the difference between development and production' ,
@@ -104,7 +94,7 @@ export const InlineSelect: Story = {
10494 ] ,
10595 } ,
10696 ] ,
107- defaultValue : 'macos' ,
97+ value : 'macos' ,
10898 inline : true ,
10999 } ,
110100} ;
@@ -118,4 +108,17 @@ export const WithNoScriptSelect: Story = {
118108 ) ,
119109} ;
120110
121- export default { component : Select } as Meta ;
111+ export default {
112+ component : Select ,
113+ render : args => {
114+ // eslint-disable-next-line @eslint-react/rules-of-hooks
115+ const [ , setArgs ] = useArgs ( ) ;
116+
117+ const onChange = ( value : string ) => {
118+ args . onChange ?.( value ) ;
119+ setArgs ( { value } ) ;
120+ } ;
121+
122+ return < Select { ...args } onChange = { onChange } /> ;
123+ } ,
124+ } as Meta ;
0 commit comments