/// import { computed, Default, NAME, pattern, UI, type VNode, wish, } from "commontools"; // ===== Types ===== type PersonListInput = Record; type Person = { contact: { name: string; email: Default; }; }; type PersonListOutput = { [NAME]: string; [UI]: VNode; people: Person[]; }; // ===== Pattern ===== const PersonList = pattern(() => { const people = wish({ query: "#person", scope: [".", "~"] }); return { [NAME]: computed(() => people.candidates?.length ? `People: ${people.candidates?.length}` : "People" ), [UI]: ( {people.candidates.map((person) => ( {person.contact.name} {person.contact.email} ))} ), people: people.candidates, }; }); export default PersonList;