File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ function OptionList(p: OptionListProps) {
170170 role = "listbox"
171171 aria-multiselectable = "true"
172172 onKeyDown = { handleKeyDown }
173- class = { classArr ( p . innerClass ?? classesGridCols3xl + " gap-x-2 gap-y-1" ) }
173+ class = { getInnerClass ( options . length , p . innerClass ) }
174174 >
175175 < For each = { options } >
176176 { ( option , index ) => (
@@ -190,6 +190,16 @@ function OptionList(p: OptionListProps) {
190190 )
191191}
192192
193+ function getInnerClass ( optionAmount : number , innerClass ?: string ) : string {
194+ if ( innerClass ) return innerClass
195+ if ( optionAmount <= 0 ) return ""
196+ const base = " gap-x-2 gap-y-1"
197+ if ( optionAmount <= 5 ) return "grid grid-cols-1" + base
198+ if ( optionAmount <= 9 ) return "grid grid-cols-2" + base
199+ if ( optionAmount > 9 ) return classesGridCols3xl + base
200+ return ""
201+ }
202+
193203interface ListOptionProps extends HasId , MultiselectOptionState {
194204 index : number
195205 focusedIndex : number
You can’t perform that action at this time.
0 commit comments