Skip to content
Merged
Show file tree
Hide file tree
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
44 changes: 19 additions & 25 deletions src/components/prompts/PromptArgsForm.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useCallback, useId, useMemo } from "react";
import { useIntl } from "react-intl";

import { Field } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import type { PromptArgument } from "@/generated/types";

export interface PromptArgsFormProps {
Expand Down Expand Up @@ -76,30 +76,24 @@ export function PromptArgsForm({ args, schema, onChange }: PromptArgsFormProps)
const fieldId = `${fieldIdPrefix}-${arg.name}`;
const required = Boolean(arg.required);
return (
<div key={arg.name} className="space-y-1.5">
<Label htmlFor={fieldId} className="inline-flex items-center gap-0.5">
<span className="font-mono text-[12px] text-foreground">{arg.name}</span>
{required && (
<>
<span className="text-red-500" aria-hidden="true">
*
</span>
<span className="sr-only">
{intl.formatMessage({ id: "prompts.details.code.args.required" })}
</span>
</>
)}
</Label>
<Input
id={fieldId}
value={args[arg.name] ?? ""}
onChange={(event) => handleChange(arg.name, event.target.value)}
placeholder={toPlaceholder(arg.description)}
required={required}
aria-required={required}
className="placeholder:text-neutral-400 dark:placeholder:text-neutral-500"
/>
</div>
<Field
key={arg.name}
id={fieldId}
label={arg.name}
required={required}
labelProps={{ className: "font-mono text-[12px] text-foreground" }}
>
{(controlProps) => (
<Input
{...controlProps}
value={args[arg.name] ?? ""}
onChange={(event) => handleChange(arg.name, event.target.value)}
placeholder={toPlaceholder(arg.description)}
required={required}
className="placeholder:text-neutral-400 dark:placeholder:text-neutral-500"
/>
)}
</Field>
);
})}
</div>
Expand Down
38 changes: 18 additions & 20 deletions src/components/resources/ResourceArgsForm.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useCallback, useId } from "react";
import { useIntl } from "react-intl";

import { Field } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";

export interface ResourceArgsFormProps {
args: Record<string, string>;
Expand Down Expand Up @@ -43,25 +43,23 @@ export function ResourceArgsForm({ args, placeholders, onChange }: ResourceArgsF
{placeholders.map((name) => {
const fieldId = `${fieldIdPrefix}-${name}`;
return (
<div key={name} className="space-y-1.5">
<Label htmlFor={fieldId} className="inline-flex items-center gap-0.5">
<span className="font-mono text-[12px] text-foreground">{name}</span>
<span className="text-red-500" aria-hidden="true">
*
</span>
<span className="sr-only">
{intl.formatMessage({ id: "resources.details.code.args.required" })}
</span>
</Label>
<Input
id={fieldId}
value={args[name] ?? ""}
onChange={(event) => handleChange(name, event.target.value)}
required
aria-required
className="placeholder:text-neutral-400 dark:placeholder:text-neutral-500"
/>
</div>
<Field
key={name}
id={fieldId}
label={name}
required
labelProps={{ className: "font-mono text-[12px] text-foreground" }}
>
{(controlProps) => (
<Input
{...controlProps}
value={args[name] ?? ""}
onChange={(event) => handleChange(name, event.target.value)}
required
className="placeholder:text-neutral-400 dark:placeholder:text-neutral-500"
/>
)}
</Field>
);
})}
</div>
Expand Down
1 change: 0 additions & 1 deletion src/i18n/locales/en-US/prompts.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"prompts.card.activateAriaLabel": "Activate {name}",
"prompts.card.deactivateAriaLabel": "Deactivate {name}",
"prompts.details.code.args.heading": "Arguments",
"prompts.details.code.args.required": "Required",
"prompts.details.code.tab.curl": "curl",
"prompts.details.code.tab.jsonRpc": "JSON-RPC",
"prompts.details.code.tab.python": "Python",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/locales/en-US/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"resources.details.resourcePreview": "Resource preview",
"resources.details.selectResource": "Select resource",
"resources.details.code.args.heading": "Arguments",
"resources.details.code.args.required": "Required",
"resources.details.code.tab.curl": "curl",
"resources.details.code.tab.jsonRpc": "JSON-RPC",
"resources.details.code.tab.python": "Python",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/locales/es-ES/prompts.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"prompts.card.activateAriaLabel": "Activar {name}",
"prompts.card.deactivateAriaLabel": "Desactivar {name}",
"prompts.details.code.args.heading": "Argumentos",
"prompts.details.code.args.required": "Requerido",
"prompts.details.code.tab.curl": "curl",
"prompts.details.code.tab.jsonRpc": "JSON-RPC",
"prompts.details.code.tab.python": "Python",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/locales/es-ES/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"resources.details.resourcePreview": "Vista previa del recurso",
"resources.details.selectResource": "Seleccionar recurso",
"resources.details.code.args.heading": "Argumentos",
"resources.details.code.args.required": "Requerido",
"resources.details.code.tab.curl": "curl",
"resources.details.code.tab.jsonRpc": "JSON-RPC",
"resources.details.code.tab.python": "Python",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/locales/pt-BR/prompts.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"prompts.card.activateAriaLabel": "Ativar {name}",
"prompts.card.deactivateAriaLabel": "Desativar {name}",
"prompts.details.code.args.heading": "Argumentos",
"prompts.details.code.args.required": "Obrigat贸rio",
"prompts.details.code.tab.curl": "curl",
"prompts.details.code.tab.jsonRpc": "JSON-RPC",
"prompts.details.code.tab.python": "Python",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/locales/pt-BR/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"resources.details.resourcePreview": "Pr茅-visualiza莽茫o do recurso",
"resources.details.selectResource": "Selecionar recurso",
"resources.details.code.args.heading": "Argumentos",
"resources.details.code.args.required": "Obrigat贸rio",
"resources.details.code.tab.curl": "curl",
"resources.details.code.tab.jsonRpc": "JSON-RPC",
"resources.details.code.tab.python": "Python",
Expand Down
Loading