mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-09 23:20:04 +00:00
## Summary Redesigned node search with categories ## Changes - **What**: Adds a v2 search component, leaving the existing implementation untouched - It also brings onboard the incomplete node library & preview changes, disabled and behind a hidden setting - **Breaking**: Changes the 'default' value of the node search setting to v2, adding v1 (legacy) as an option ## Screenshots (if applicable) https://github.com/user-attachments/assets/2ab797df-58f0-48e8-8b20-2a1809e3735f ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8987-V2-Node-Search-hidden-Node-Library-changes-30c6d73d36508160902bcb92553f147c) by [Unito](https://www.unito.io) --------- Co-authored-by: Yourz <crazilou@vip.qq.com> Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Christian Byrne <cbyrne@comfy.org>
118 lines
2.8 KiB
Vue
118 lines
2.8 KiB
Vue
<template>
|
|
<div class="flex flex-col gap-2 flex-auto">
|
|
<ComboboxRoot :ignore-filter="true" :open="false">
|
|
<ComboboxAnchor
|
|
:class="
|
|
cn(
|
|
'relative flex w-full cursor-text items-center',
|
|
'rounded-lg bg-comfy-input text-comfy-input-foreground',
|
|
showBorder &&
|
|
'border border-solid border-border-default box-border',
|
|
sizeClasses,
|
|
className
|
|
)
|
|
"
|
|
>
|
|
<i
|
|
v-if="!searchTerm"
|
|
:class="cn('absolute left-4 pointer-events-none', icon, iconClass)"
|
|
/>
|
|
<Button
|
|
v-else
|
|
class="absolute left-2"
|
|
variant="textonly"
|
|
size="icon"
|
|
:aria-label="$t('g.clear')"
|
|
@click="clearSearch"
|
|
>
|
|
<i class="icon-[lucide--x] size-4" />
|
|
</Button>
|
|
|
|
<ComboboxInput
|
|
ref="inputRef"
|
|
v-model="searchTerm"
|
|
:class="
|
|
cn(
|
|
'size-full border-none bg-transparent text-sm outline-none',
|
|
inputPadding
|
|
)
|
|
"
|
|
:placeholder="placeholderText"
|
|
:auto-focus="autofocus"
|
|
/>
|
|
</ComboboxAnchor>
|
|
</ComboboxRoot>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { cn } from '@/utils/tailwindUtil'
|
|
import { watchDebounced } from '@vueuse/core'
|
|
import { ComboboxAnchor, ComboboxInput, ComboboxRoot } from 'reka-ui'
|
|
import { computed, ref } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
import Button from '@/components/ui/button/Button.vue'
|
|
|
|
const { t } = useI18n()
|
|
|
|
const {
|
|
placeholder,
|
|
icon = 'icon-[lucide--search]',
|
|
debounceTime = 300,
|
|
autofocus = false,
|
|
showBorder = false,
|
|
size = 'md',
|
|
class: className
|
|
} = defineProps<{
|
|
placeholder?: string
|
|
icon?: string
|
|
debounceTime?: number
|
|
autofocus?: boolean
|
|
showBorder?: boolean
|
|
size?: 'md' | 'lg'
|
|
class?: string
|
|
}>()
|
|
|
|
const emit = defineEmits<{
|
|
search: [value: string]
|
|
}>()
|
|
|
|
const searchTerm = defineModel<string>({ required: true })
|
|
|
|
const inputRef = ref<InstanceType<typeof ComboboxInput> | null>(null)
|
|
|
|
defineExpose({
|
|
focus: () => {
|
|
inputRef.value?.$el?.focus()
|
|
}
|
|
})
|
|
|
|
const isLarge = computed(() => size === 'lg')
|
|
const placeholderText = computed(
|
|
() => placeholder ?? t('g.searchPlaceholder', { subject: '' })
|
|
)
|
|
|
|
const sizeClasses = computed(() => {
|
|
if (showBorder) {
|
|
return isLarge.value ? 'h-10 p-2' : 'h-8 p-2'
|
|
}
|
|
return isLarge.value ? 'h-12 px-4 py-2' : 'h-10 px-4 py-2'
|
|
})
|
|
|
|
const iconClass = computed(() => (isLarge.value ? 'size-5' : 'size-4'))
|
|
const inputPadding = computed(() => (isLarge.value ? 'pl-8' : 'pl-6'))
|
|
|
|
function clearSearch() {
|
|
searchTerm.value = ''
|
|
}
|
|
|
|
watchDebounced(
|
|
searchTerm,
|
|
(value: string) => {
|
|
emit('search', value)
|
|
},
|
|
{ debounce: debounceTime }
|
|
)
|
|
</script>
|