Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions src/components/OptionEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function OptionLabel({
}) {
return (
<div className="flex items-center gap-1.5 min-w-[80px]">
<AsyncIcon icon={icon} basePath={basePath} className="w-4 h-4 object-contain flex-shrink-0" />
{icon && <AsyncIcon icon={icon} basePath={basePath} className="w-4 h-4 object-contain flex-shrink-0" />}
<span className="text-sm text-text-secondary">{label}</span>
</div>
);
Expand Down Expand Up @@ -198,11 +198,13 @@ function InputField({
<div className="space-y-1">
<div className="flex items-center gap-3">
<div className="flex items-center gap-1.5 min-w-[80px]">
<AsyncIcon
icon={input.icon}
basePath={basePath}
className="w-4 h-4 object-contain flex-shrink-0"
/>
{input.icon && (
<AsyncIcon
icon={input.icon}
basePath={basePath}
className="w-4 h-4 object-contain flex-shrink-0"
/>
)}
<span className="text-sm text-text-tertiary">{inputLabel}</span>
{inputDescription && (
<Tooltip content={inputDescription} side="top" align="start" maxWidth="max-w-[200px]">
Expand Down Expand Up @@ -405,6 +407,7 @@ export function OptionEditor({
className="flex-1"
value={selectedCaseName}
disabled={disabled}
basePath={basePath}
options={optionDef.cases.map((caseItem) => {
// 对于 MXU 内置选项,使用 t() 翻译;否则使用 resolveI18nText
const label = isMxuOption
Expand All @@ -413,6 +416,7 @@ export function OptionEditor({
return {
value: caseItem.name,
label,
icon: caseItem.icon,
};
})}
onChange={(next) => {
Expand Down Expand Up @@ -451,9 +455,10 @@ export function OptionEditor({

interface OptionSelectDropdownProps {
value: string;
options: { value: string; label: string }[];
options: { value: string; label: string; icon?: string }[];
disabled?: boolean;
className?: string;
basePath: string;
onChange: (value: string) => void;
}

Expand All @@ -462,6 +467,7 @@ function OptionSelectDropdown({
options,
disabled = false,
className,
basePath,
onChange,
}: OptionSelectDropdownProps) {
const triggerId = useId();
Expand Down Expand Up @@ -580,7 +586,10 @@ function OptionSelectDropdown({
aria-expanded={open}
aria-controls={listboxId}
>
<span className="truncate">{selectedOption?.label}</span>
<span className="flex items-center gap-1.5 truncate">
{selectedOption?.icon && <AsyncIcon icon={selectedOption.icon} basePath={basePath} className="w-4 h-4 object-contain flex-shrink-0" />}
{selectedOption?.label}
</span>
<ChevronDown
className={clsx('w-4 h-4 text-text-secondary transition-transform', open && 'rotate-180')}
/>
Expand Down Expand Up @@ -620,7 +629,10 @@ function OptionSelectDropdown({
role="option"
aria-selected={isSelected}
>
<span className="truncate">{opt.label}</span>
<span className="flex items-center gap-1.5 truncate">
{opt.icon && <AsyncIcon icon={opt.icon} basePath={basePath} className="w-4 h-4 object-contain flex-shrink-0" />}
{opt.label}
</span>
{isSelected && <Check className="w-4 h-4 flex-shrink-0" />}
</button>
);
Expand All @@ -637,6 +649,7 @@ function OptionSelectComboBox({
options,
disabled = false,
className,
basePath,
onChange,
}: OptionSelectDropdownProps) {
const { t } = useTranslation();
Expand Down Expand Up @@ -777,7 +790,10 @@ function OptionSelectComboBox({
aria-expanded={open}
aria-controls={listboxId}
>
<span className="truncate">{selectedOption?.label}</span>
<span className="flex items-center gap-1.5 truncate">
{selectedOption?.icon && <AsyncIcon icon={selectedOption.icon} basePath={basePath} className="w-4 h-4 object-contain flex-shrink-0" />}
{selectedOption?.label}
</span>
<ChevronDown
className={clsx('w-4 h-4 text-text-secondary transition-transform', open && 'rotate-180')}
/>
Expand Down Expand Up @@ -842,7 +858,10 @@ function OptionSelectComboBox({
role="option"
aria-selected={isSelected}
>
<span className="truncate">{opt.label}</span>
<span className="flex items-center gap-1.5 truncate">
{opt.icon && <AsyncIcon icon={opt.icon} basePath={basePath} className="w-4 h-4 object-contain flex-shrink-0" />}
{opt.label}
</span>
{isSelected && <Check className="w-4 h-4 flex-shrink-0" />}
</button>
);
Expand Down
Loading