/* Copyright (C) 2023-2026 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { Button } from '@/components/ui/button' import { Combobox } from '@/components/ui/combobox' import { getLobeIcon, getLobeIconNames } from '@/lib/lobe-icon' export function LobeIconField(props: { id?: string value: string onChange: (value: string) => void allowInheritance?: boolean inheritedIcon?: string inheritedName?: string }) { const { t } = useTranslation() const [custom, setCustom] = useState(false) const usesCustom = !props.allowInheritance || Boolean(props.value) || custom const options = useMemo( () => getLobeIconNames().map((name) => ({ value: name, label: name, icon: getLobeIcon(name, 18), })), [] ) const effectiveIcon = props.value || props.inheritedIcon return (
{props.allowInheritance && (
)} {usesCustom && (
props.onChange(value ?? '')} allowCustomValue searchPlaceholder={t('Search icons or enter an icon key')} emptyText={t('No matching icons')} className='min-w-0 flex-1' /> {props.value && ( )}
)}
{getLobeIcon(effectiveIcon, 28)}

{t('Effective icon')}

{effectiveIcon || t('Default placeholder')}

{props.allowInheritance && !props.value && (

{t('Inherited from {{vendor}}', { vendor: props.inheritedName || t('No vendor'), })}

)}
{usesCustom && (

{t('Select a suggested icon or keep an existing advanced icon key.')}

)}
) }