/** * TRANSFORM REPRO: mapped element field comparisons inside helper-call roots * * The mapped element is lowered to a cell input. A non-JSX comparison such as * `message.author === senderName(name.get())` must read `message.author` * through a reactive field dependency, not as a plain property on the cell. */ import { Default, pattern, UI, VNode, Writable, } from "commonfabric"; interface Message { author: string; body: string; } interface Input { name: Writable>; selectedRoom: Writable>; } interface Output { [UI]: VNode; } const senderName = (name?: string) => name?.trim() || "Anonymous"; export default pattern(({ name, selectedRoom }) => { return { [UI]: (
{selectedRoom.get()?.messages.map((message) => { const isMine = message.author === senderName(name.get()); const isKnownAuthor = message.author === "Alice"; return (
{message.author} {message.body}
); })}
), }; });