import type { components } from "../../../contracts/studio/generated.ts"; import { createNewItemId } from "../../../domain/studio/local-id.ts"; type CatalogEntry = components["schemas"]["CatalogEntry"]; type RelationInput = components["schemas"]["RelationInput"]; function ordered(relations: RelationInput[]): RelationInput[] { return relations.map((relation, order) => ({ ...relation, order })); } export function RelationEditor({ relations, catalog, evidence = false, onChange }: { relations: RelationInput[]; catalog: CatalogEntry[]; evidence?: boolean; onChange(relations: RelationInput[]): void }) { const noun = evidence ? "근거" : "관계"; const update = (index: number, patch: Partial) => onChange(ordered(relations.map((relation, candidateIndex) => candidateIndex === index ? { ...relation, ...patch } : relation))); const move = (index: number, delta: -1 | 1) => { const target = index + delta; if (target < 0 || target >= relations.length) return; const next = [...relations]; [next[index], next[target]] = [next[target]!, next[index]!]; onChange(ordered(next)); }; return (
{evidence ? "근거 기록" : "관계"} {relations.length === 0 ?

{evidence ? "연결한 근거 기록이 없습니다." : "연결한 공개 기록이 없습니다."}

: null} {relations.map((relation, index) => (
))}
); }