@@ -2,12 +2,10 @@ import type { BoxProps, FormLabelProps, InputProps, SystemStyleObject } from '@i
2
2
import {
3
3
Box ,
4
4
Button ,
5
- Collapse ,
6
5
Expander ,
7
6
Flex ,
8
7
FormControlGroup ,
9
8
FormLabel ,
10
- Icon ,
11
9
IconButton ,
12
10
Input ,
13
11
Popover ,
@@ -27,7 +25,6 @@ import { InformationalPopover } from 'common/components/InformationalPopover/Inf
27
25
import type { Group , ImperativeModelPickerHandle } from 'common/components/Picker/Picker' ;
28
26
import { getRegex , Picker } from 'common/components/Picker/Picker' ;
29
27
import { useDisclosure } from 'common/hooks/useBoolean' ;
30
- import { useStateImperative } from 'common/hooks/useStateImperative' ;
31
28
import { fixedForwardRef } from 'common/util/fixedForwardRef' ;
32
29
import { typedMemo } from 'common/util/typedMemo' ;
33
30
import { selectLoRAsSlice } from 'features/controlLayers/store/lorasSlice' ;
@@ -52,7 +49,7 @@ import { selectActiveTab, selectCompactModelPicker } from 'features/ui/store/uiS
52
49
import { compactModelPickerToggled } from 'features/ui/store/uiSlice' ;
53
50
import { filesize } from 'filesize' ;
54
51
import type { PropsWithChildren } from 'react' ;
55
- import { memo , useCallback , useEffect , useMemo , useRef } from 'react' ;
52
+ import { memo , useCallback , useMemo , useRef } from 'react' ;
56
53
import { useTranslation } from 'react-i18next' ;
57
54
import { PiArrowsInLineVerticalBold , PiArrowsOutLineVerticalBold , PiCaretDownBold } from 'react-icons/pi' ;
58
55
import { useMainModels } from 'services/api/hooks/modelsByType' ;
@@ -274,28 +271,8 @@ const SearchBarComponent = typedMemo(
274
271
) ;
275
272
SearchBarComponent . displayName = 'SearchBarComponent' ;
276
273
277
- const toggleButtonSx = {
278
- "&[data-expanded='true']" : {
279
- transform : 'rotate(180deg)' ,
280
- } ,
281
- } satisfies SystemStyleObject ;
282
-
283
274
const PickerGroupComponent = memo (
284
- ( {
285
- group,
286
- activeOptionId,
287
- children,
288
- } : PropsWithChildren < { group : Group < AnyModelConfig , GroupData > ; activeOptionId : string | undefined } > ) => {
289
- const [ isOpen , setIsOpen , getIsOpen ] = useStateImperative ( true ) ;
290
- useEffect ( ( ) => {
291
- if ( group . options . some ( ( option ) => option . key === activeOptionId ) && ! getIsOpen ( ) ) {
292
- setIsOpen ( true ) ;
293
- }
294
- } , [ activeOptionId , getIsOpen , group . options , setIsOpen ] ) ;
295
- const toggle = useCallback ( ( ) => {
296
- setIsOpen ( ( prev ) => ! prev ) ;
297
- } , [ setIsOpen ] ) ;
298
-
275
+ ( { group, children } : PropsWithChildren < { group : Group < AnyModelConfig , GroupData > } > ) => {
299
276
return (
300
277
< Flex
301
278
flexDir = "column"
@@ -304,20 +281,19 @@ const PickerGroupComponent = memo(
304
281
borderLeftWidth = { 4 }
305
282
ps = { 2 }
306
283
>
307
- < GroupHeader group = { group } isOpen = { isOpen } toggle = { toggle } />
308
- < Collapse in = { isOpen } animateOpacity >
309
- < Flex flexDir = "column" gap = { 1 } w = "full" py = { 1 } >
310
- { children }
311
- </ Flex >
312
- </ Collapse >
284
+ < GroupHeader group = { group } />
285
+ < Flex flexDir = "column" gap = { 1 } w = "full" py = { 1 } >
286
+ { children }
287
+ </ Flex >
313
288
</ Flex >
314
289
) ;
315
290
}
316
291
) ;
317
292
PickerGroupComponent . displayName = 'PickerGroupComponent' ;
318
293
319
294
const groupSx = {
320
- alignItems : 'center' ,
295
+ flexDir : 'column' ,
296
+ flex : 1 ,
321
297
ps : 2 ,
322
298
pe : 4 ,
323
299
py : 1 ,
@@ -326,43 +302,30 @@ const groupSx = {
326
302
top : 0 ,
327
303
bg : 'base.800' ,
328
304
minH : 8 ,
329
- borderRadius : 'base' ,
330
- _hover : { bg : 'base.750' } ,
331
305
} satisfies SystemStyleObject ;
332
306
333
- const GroupHeader = memo (
334
- ( {
335
- group,
336
- isOpen,
337
- toggle,
338
- ...rest
339
- } : { group : Group < AnyModelConfig , GroupData > ; isOpen : boolean ; toggle : ( ) => void } & BoxProps ) => {
340
- const { t } = useTranslation ( ) ;
341
- const compactModelPicker = useAppSelector ( selectCompactModelPicker ) ;
307
+ const GroupHeader = memo ( ( { group, ...rest } : { group : Group < AnyModelConfig , GroupData > } & BoxProps ) => {
308
+ const { t } = useTranslation ( ) ;
309
+ const compactModelPicker = useAppSelector ( selectCompactModelPicker ) ;
342
310
343
- return (
344
- < Flex { ...rest } role = "button" sx = { groupSx } onClick = { toggle } >
345
- < Flex flexDir = "column" flex = { 1 } >
346
- < Flex gap = { 2 } alignItems = "center" >
347
- < Text fontSize = "sm" fontWeight = "semibold" color = { `${ BASE_COLOR_MAP [ group . data . base ] } .300` } >
348
- { MODEL_TYPE_SHORT_MAP [ group . data . base ] }
349
- </ Text >
350
- < Text fontSize = "sm" color = "base.300" noOfLines = { 1 } >
351
- { t ( 'common.model_withCount' , { count : group . options . length } ) }
352
- </ Text >
353
- </ Flex >
354
- { ! compactModelPicker && (
355
- < Text color = "base.200" fontStyle = "italic" >
356
- { group . data . description }
357
- </ Text >
358
- ) }
359
- < Spacer />
360
- </ Flex >
361
- < Icon color = "base.300" as = { PiCaretDownBold } sx = { toggleButtonSx } data-expanded = { isOpen } boxSize = { 4 } />
311
+ return (
312
+ < Flex { ...rest } sx = { groupSx } >
313
+ < Flex gap = { 2 } alignItems = "center" >
314
+ < Text fontSize = "sm" fontWeight = "semibold" color = { `${ BASE_COLOR_MAP [ group . data . base ] } .300` } >
315
+ { MODEL_TYPE_SHORT_MAP [ group . data . base ] }
316
+ </ Text >
317
+ < Text fontSize = "sm" color = "base.300" noOfLines = { 1 } >
318
+ { t ( 'common.model_withCount' , { count : group . options . length } ) }
319
+ </ Text >
362
320
</ Flex >
363
- ) ;
364
- }
365
- ) ;
321
+ { ! compactModelPicker && (
322
+ < Text color = "base.200" fontStyle = "italic" >
323
+ { group . data . description }
324
+ </ Text >
325
+ ) }
326
+ </ Flex >
327
+ ) ;
328
+ } ) ;
366
329
GroupHeader . displayName = 'GroupHeader' ;
367
330
368
331
const optionSx : SystemStyleObject = {
@@ -389,6 +352,15 @@ const optionSx: SystemStyleObject = {
389
352
scrollMarginTop : '42px' , // magic number, this is the height of the header
390
353
} ;
391
354
355
+ const optionNameSx : SystemStyleObject = {
356
+ fontSize : 'sm' ,
357
+ noOfLines : 1 ,
358
+ fontWeight : 'semibold' ,
359
+ '&[data-is-compact="true"]' : {
360
+ fontWeight : 'normal' ,
361
+ } ,
362
+ } ;
363
+
392
364
export const PickerOptionComponent = typedMemo ( ( { option, ...rest } : { option : AnyModelConfig } & BoxProps ) => {
393
365
const compactModelPicker = useAppSelector ( selectCompactModelPicker ) ;
394
366
@@ -397,7 +369,7 @@ export const PickerOptionComponent = typedMemo(({ option, ...rest }: { option: A
397
369
{ ! compactModelPicker && < ModelImage image_url = { option . cover_image } /> }
398
370
< Flex flexDir = "column" gap = { 2 } flex = { 1 } >
399
371
< Flex gap = { 2 } alignItems = "center" >
400
- < Text fontSize = "sm" fontWeight = "semibold" noOfLines = { 1 } >
372
+ < Text sx = { optionNameSx } data-is-compact = { compactModelPicker } >
401
373
{ option . name }
402
374
</ Text >
403
375
< Spacer />
0 commit comments