1
1
import type { ChakraProps , ComboboxOnChange , ComboboxOption } from '@invoke-ai/ui-library' ;
2
- import { Combobox , FormControl , Icon } from '@invoke-ai/ui-library' ;
2
+ import { Combobox , Flex , FormControl , Icon } from '@invoke-ai/ui-library' ;
3
3
import { skipToken } from '@reduxjs/toolkit/query' ;
4
4
import { useAppSelector } from 'app/store/storeHooks' ;
5
5
import type { GroupBase } from 'chakra-react-select' ;
@@ -18,7 +18,7 @@ import { isNonRefinerMainModelConfig } from 'services/api/types';
18
18
19
19
const noOptionsMessage = ( ) => t ( 'prompt.noMatchingTriggers' ) ;
20
20
21
- type RelatedEmbedding = ComboboxOption & { starred ?: boolean } ;
21
+ type ComboboxOptionWithStarred = ComboboxOption & { starred ?: boolean } ;
22
22
23
23
export const PromptTriggerSelect = memo ( ( { onSelect, onClose } : PromptTriggerSelectProps ) => {
24
24
const { t } = useTranslation ( ) ;
@@ -65,7 +65,7 @@ export const PromptTriggerSelect = memo(({ onSelect, onClose }: PromptTriggerSel
65
65
) ;
66
66
67
67
const options = useMemo ( ( ) => {
68
- const _options : GroupBase < ComboboxOption > [ ] = [ ] ;
68
+ const _options : GroupBase < ComboboxOptionWithStarred > [ ] = [ ] ;
69
69
70
70
if ( loraModels ) {
71
71
const triggerPhraseOptions = loraModels
@@ -88,7 +88,7 @@ export const PromptTriggerSelect = memo(({ onSelect, onClose }: PromptTriggerSel
88
88
89
89
if ( tiModels ) {
90
90
// Create embedding options with starred property for related models
91
- const embeddingOptions : RelatedEmbedding [ ] = tiModels
91
+ const embeddingOptions : ComboboxOptionWithStarred [ ] = tiModels
92
92
. filter ( ( ti ) => ti . base === mainModelConfig ?. base )
93
93
. map ( ( model ) => ( {
94
94
label : model . name ,
@@ -128,27 +128,26 @@ export const PromptTriggerSelect = memo(({ onSelect, onClose }: PromptTriggerSel
128
128
return _options ;
129
129
} , [ tiModels , loraModels , mainModelConfig , t , addedLoRAs , relatedModelKeys ] ) ;
130
130
131
- const formatOptionLabel = useCallback ( ( option : ComboboxOption ) => {
132
- const embeddingOption = option as RelatedEmbedding ;
133
- if ( embeddingOption . starred ) {
134
- return (
135
- < div style = { { display : 'flex' , alignItems : 'center' , gap : '8px' } } >
136
- < Icon as = { PiLinkSimple } color = "invokeYellow.500" boxSize = { 3 } />
137
- { option . label }
138
- </ div >
139
- ) ;
140
- }
141
- return option . label ;
131
+ const formatOptionLabel = useCallback ( ( option : ComboboxOptionWithStarred ) => {
132
+ return (
133
+ < Flex alignItems = "center" gap = { 2 } >
134
+ { option . starred && < Icon as = { PiLinkSimple } color = "invokeYellow.500" boxSize = { 4 } /> }
135
+ { option . label }
136
+ </ Flex >
137
+ ) ;
142
138
} , [ ] ) ;
143
139
140
+ const placeholder = useMemo ( ( ) => {
141
+ if ( isLoadingLoRAs || isLoadingTIs || isLoadingMainModelConfig ) {
142
+ return t ( 'common.loading' ) ;
143
+ }
144
+ return t ( 'prompt.addPromptTrigger' ) ;
145
+ } , [ t , isLoadingLoRAs , isLoadingTIs , isLoadingMainModelConfig ] ) ;
146
+
144
147
return (
145
148
< FormControl >
146
149
< Combobox
147
- placeholder = {
148
- isLoadingLoRAs || isLoadingTIs || isLoadingMainModelConfig
149
- ? t ( 'common.loading' )
150
- : t ( 'prompt.addPromptTrigger' )
151
- }
150
+ placeholder = { placeholder }
152
151
defaultMenuIsOpen
153
152
autoFocus
154
153
value = { null }
0 commit comments