@@ -46,128 +46,139 @@ const data = [
4646 } ,
4747 {
4848 id : 5 ,
49+ prop : "disableGroupSelect" ,
50+ type : "boolean" ,
51+ default : "-" ,
52+ description :
53+ "Remove checkbox on group label for selecting all group options." ,
54+ } ,
55+ {
56+ id : 6 ,
4957 prop : "errorMessage" ,
5058 type : "string" ,
5159 default : "-" ,
5260 description : "Displays an error message below the component." ,
5361 } ,
5462 {
55- id : 6 ,
63+ id : 7 ,
5664 prop : "enableTooltip" ,
5765 type : "boolean" ,
5866 default : "false" ,
5967 description :
6068 "When enableTooltip is true, select component renders the <Tooltip> component for the selected value." ,
6169 } ,
6270 {
63- id : 7 ,
71+ id : 8 ,
6472 prop : "hasError" ,
6573 type : "boolean" ,
6674 default : "-" ,
6775 description : "If true, error in component." ,
6876 } ,
6977 {
70- id : 8 ,
78+ id : 9 ,
7179 prop : "helperText" ,
7280 type : "string" ,
7381 default : "-" ,
7482 description : "Displays an error message below the component." ,
7583 } ,
7684 {
77- id : 9 ,
85+ id : 10 ,
7886 prop : "hideIfSingleOption" ,
7987 type : "boolean" ,
8088 default : "false" ,
8189 description :
8290 "If there is only one option, and multiple is false, the Select component will not render the dropdown at all when set to true." ,
8391 } ,
8492 {
85- id : 10 ,
93+ id : 11 ,
8694 prop : "label" ,
8795 type : "string" ,
8896 default : "-" ,
8997 description : "Label of the component." ,
9098 } ,
9199 {
92- id : 11 ,
100+ id : 12 ,
93101 prop : "labelKey" ,
94102 type : "string" ,
95103 default : "-" ,
96104 description : "The key in option object to use as the display label." ,
97105 } ,
98106 {
99- id : 12 ,
107+ id : 13 ,
100108 prop : "multiple" ,
101109 type : "boolean" ,
102110 default : "false" ,
103111 description : "If true, multiple selection is enabled." ,
104112 } ,
105113 {
106- id : 13 ,
114+ id : 14 ,
107115 prop : "name" ,
108116 type : "string" ,
109117 default : "-" ,
110118 description : "Name of the component." ,
111119 } ,
112120 {
113- id : 14 ,
121+ id : 15 ,
114122 prop : "options" ,
115- type : "Option[]" ,
123+ type : "Option[] | GroupedOption[] " ,
116124 default : "-" ,
117125 description : "Options to pass in the select component." ,
118126 } ,
119127 {
120- id : 15 ,
128+ id : 16 ,
121129 prop : "placeholder" ,
122130 type : "string" ,
123131 default : "-" ,
124132 description : "Placeholder in the component." ,
125133 } ,
126134 {
127- id : 16 ,
135+ id : 17 ,
128136 prop : "showRemoveSelection" ,
129137 type : "boolean" ,
130138 default : "true" ,
131139 description : "If true, icon to remove selected options is visible." ,
132140 } ,
133141 {
134- id : 17 ,
142+ id : 18 ,
135143 prop : "tooltipOptions" ,
136144 type : "TooltipOptions" ,
137145 default : "-" ,
138146 description :
139147 "Options to customize the tooltip’s behavior(example: position, offset)." ,
140148 } ,
141149 {
142- id : 18 ,
150+ id : 19 ,
143151 prop : "value" ,
144152 type : "Value" ,
145153 default : "-" ,
146154 description : "Selected values of the component." ,
147155 } ,
148156 {
149- id : 19 ,
157+ id : 20 ,
150158 prop : "valueKey" ,
151159 type : "string" ,
152160 default : "-" ,
153161 description : "The key in option object to use as value." ,
154162 } ,
155163 {
156- id : 20 ,
164+ id : 21 ,
157165 prop : "renderOption" ,
158- type : "(option: Option[] ) => React.ReactNode" ,
166+ type : "(option: Option<T> | GroupedOption<T> ) => React.ReactNode" ,
159167 default : "-" ,
160168 description : "Function to be called to render custom select options." ,
161169 } ,
162170 {
163- id : 21 ,
171+ id : 22 ,
164172 prop : "renderValue" ,
165- type : "(value?: Value, options?: Option[]) => React.ReactNode" ,
173+ type : `(
174+ value?: T | T[],
175+ options?: Option<T>[] | GroupedOption<T>[]
176+ ) => React.ReactNode` ,
166177 default : "-" ,
167178 description : "Function to be called to render custom select value." ,
168179 } ,
169180 {
170- id : 22 ,
181+ id : 23 ,
171182 prop : "onChange" ,
172183 type : " (newValue: T | T[]) => void" ,
173184 default : "-" ,
@@ -182,6 +193,15 @@ export const SelectDemo = () => {
182193 const [ multiselectValue , setMultiselectValue ] = useState < string [ ] > ( [ ] ) ;
183194
184195 const [ singleSelectValue , setSingleSelectValue ] = useState < string > ( "" ) ;
196+ const [ singleSelectGroupValue , setSingleSelectGroupValue ] =
197+ useState < string > ( "" ) ;
198+ const [ multiSelectGroupValue , setMultiSelectGroupValue ] = useState < string [ ] > (
199+ [ ] ,
200+ ) ;
201+ const [
202+ multiSelectGroupSelectDisableValue ,
203+ setMultiSelectGroupSelectDisableValue ,
204+ ] = useState < string [ ] > ( [ ] ) ;
185205 const [ selectedValue , setSelectedValue ] = useState < string > ( "" ) ;
186206 const [ renderedValue , setRenderedValue ] = useState < string [ ] > ( [ ] ) ;
187207 const [ renderedOption , setRenderedOption ] = useState < string [ ] > ( [ ] ) ;
@@ -592,13 +612,13 @@ const [selectedValue, setSelectedValue] = useState<string>("");
592612 ] ,
593613 } ,
594614 ] }
595- value = { singleSelectValue }
596- onChange = { ( value : string ) => setSingleSelectValue ( value ) }
615+ value = { singleSelectGroupValue }
616+ onChange = { ( value : string ) => setSingleSelectGroupValue ( value ) }
597617 placeholder = { t ( "select.placeholder" ) }
598618 />
599619 < CodeBlock
600620 exampleCode = '
601- const [singleSelectValue, setSingleSelectValue ] = useState<string>("");
621+ const [singleSelectGroupValue, setSingleSelectGroupValue ] = useState<string>("");
602622
603623<Select
604624 label={t("select.label")}
@@ -620,8 +640,8 @@ const [singleSelectValue, setSingleSelectValue] = useState<string>("");
620640 ],
621641 },
622642 ]}
623- value={singleSelectValue }
624- onChange={(value: string) => setSingleSelectValue (value)}
643+ value={singleSelectGroupValue }
644+ onChange={(value: string) => setSingleSelectGroupValue (value)}
625645 placeholder={t("select.placeholder")}
626646/>'
627647 />
@@ -654,13 +674,13 @@ const [singleSelectValue, setSingleSelectValue] = useState<string>("");
654674 } ,
655675 ] }
656676 multiple = { true }
657- value = { multiselectValue }
658- onChange = { ( value : string [ ] ) => setMultiselectValue ( value ) }
677+ value = { multiSelectGroupValue }
678+ onChange = { ( value : string [ ] ) => setMultiSelectGroupValue ( value ) }
659679 placeholder = { t ( "select.multiSelectPlaceholder" ) }
660680 />
661681 < CodeBlock
662682 exampleCode = '
663- const [multiSelectPlaceholder, setMultiSelectPlaceholder ] = useState<string>("" );
683+ const [multiSelectGroupValue, setMultiSelectGroupValue ] = useState<string[]>([] );
664684
665685<Select
666686 label={t("select.label")}
@@ -684,8 +704,8 @@ const [multiSelectPlaceholder, setMultiSelectPlaceholder] = useState<string>("")
684704 },
685705 ]}
686706 multiple={true}
687- value={multiselectValue }
688- onChange={(value: string[]) => setMultiselectValue (value)}
707+ value={multiSelectGroupValue }
708+ onChange={(value: string[]) => setMultiSelectGroupValue (value)}
689709 placeholder={t("select.multiSelectPlaceholder")}
690710/>'
691711 />
@@ -713,13 +733,15 @@ const [multiSelectPlaceholder, setMultiSelectPlaceholder] = useState<string>("")
713733 } ,
714734 ] }
715735 multiple = { true }
716- value = { multiselectValue }
717- onChange = { ( value : string [ ] ) => setMultiselectValue ( value ) }
736+ value = { multiSelectGroupSelectDisableValue }
737+ onChange = { ( value : string [ ] ) =>
738+ setMultiSelectGroupSelectDisableValue ( value )
739+ }
718740 placeholder = { t ( "select.multiSelectPlaceholder" ) }
719741 />
720742 < CodeBlock
721743 exampleCode = '
722- const [multiSelectPlaceholder, setMultiSelectPlaceholder ] = useState<string>("" );
744+ const [multiSelectGroupSelectDisableValue, setMultiSelectGroupSelectDisableValue ] = useState<string[]>([] );
723745
724746<Select
725747 label={t("select.label")}
@@ -744,8 +766,8 @@ const [multiSelectPlaceholder, setMultiSelectPlaceholder] = useState<string>("")
744766 },
745767 ]}
746768 multiple={true}
747- value={multiselectValue }
748- onChange={(value: string[]) => setMultiselectValue (value)}
769+ value={multiSelectGroupSelectDisableValue }
770+ onChange={(value: string[]) => setMultiSelectGroupSelectDisableValue (value)}
749771 placeholder={t("select.multiSelectPlaceholder")}
750772/>'
751773 />
@@ -779,7 +801,7 @@ const [multiSelectPlaceholder, setMultiSelectPlaceholder] = useState<string>("")
779801 />
780802 </ Section >
781803
782- < Section title = "Type" >
804+ < Section title = { t ( "headers.types" ) } >
783805 < CodeBlock
784806 exampleCode = '
785807type Option<T extends string | number> = {
@@ -788,6 +810,11 @@ type Option<T extends string | number> = {
788810 value: T;
789811};
790812
813+ type GroupedOption<T = string | number> = {
814+ label: string;
815+ options: Option<T>[];
816+ };
817+
791818type Value = string | number | (string | number)[]
792819
793820type TooltipOptions = {
0 commit comments