Refactor code structure for improved readability and maintainability

This commit is contained in:
catlog22
2026-02-15 23:35:48 +08:00
parent 8938c47f88
commit dc03862ca7
18 changed files with 384 additions and 3743 deletions

View File

@@ -127,6 +127,7 @@ export const RadioGroupComponentSchema = z.object({
label: TextContentSchema,
value: z.string(),
description: TextContentSchema.optional(),
isDefault: z.boolean().optional(),
})),
selectedValue: TextContentSchema.optional(),
onChange: ActionSchema,

View File

@@ -43,7 +43,9 @@ export const A2UIRadioGroup: ComponentRenderer = ({ component, onAction, resolve
return (
<RadioGroup value={selectedValue} onValueChange={handleChange} className="space-y-2">
{radioConfig.options.map((option, idx) => {
const labelText = resolveTextContent(option.label, resolveBinding);
const rawLabel = resolveTextContent(option.label, resolveBinding);
const labelText = rawLabel.replace(/\s*\(Recommended\)\s*/i, '');
const isDefault = (option as any).isDefault === true || /\(Recommended\)/i.test(rawLabel);
const descriptionText = option.description
? resolveTextContent(option.description, resolveBinding)
: undefined;
@@ -61,6 +63,11 @@ export const A2UIRadioGroup: ComponentRenderer = ({ component, onAction, resolve
className="text-sm font-medium leading-none cursor-pointer"
>
{labelText}
{isDefault && (
<span className="ml-2 inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-primary/10 text-primary">
</span>
)}
</Label>
{descriptionText && (
<span className="text-xs text-muted-foreground mt-1">