// Array Field Template - renders array fields with add/remove controls import type { ArrayFieldTemplateProps } from "@rjsf/utils"; import { Button } from "@/components/ui/button"; import { LuPlus } from "react-icons/lu"; import { useTranslation } from "react-i18next"; import { cn } from "@/lib/utils"; export function ArrayFieldTemplate(props: ArrayFieldTemplateProps) { const { items, canAdd, onAddClick, disabled, readonly, schema } = props; const { t } = useTranslation(["common"]); // Simple items (strings, numbers) render inline const isSimpleType = schema.items && typeof schema.items === "object" && "type" in schema.items && ["string", "number", "integer", "boolean"].includes( schema.items.type as string, ); return (
{items.length === 0 && !canAdd && (

{t("no_items", { ns: "common", defaultValue: "No items" })}

)} {items.map((element, index) => { // RJSF items are pre-rendered React elements, render them directly return (
{element}
); })} {canAdd && ( )}
); }