import { Cell, computed, Default, pattern, UI, Writable } from "commonfabric"; interface Person { name: string; rank: number; } interface PatternInput { people?: Cell>; } // FIXTURE: computed-map-in-ternary-branch // Verifies: a computed array used inside a ternary JSX branch stays pattern-lowered // const adminData = computed(() => [...people.get()].sort(...).map(...)) // adminData.map((entry) =>
  • ...) → adminData.mapWithPattern(pattern(...), {}) // showAdmin ?
    ...
    : null → ifElse(showAdmin,
    ...
    , null) // Context: The outer `people.map(...)` is over a pattern input cell, while the // inner `adminData.map(...)` is over compute-owned data but still lowered in // pattern context when rendered from the ternary branch. export default pattern(({ people }) => { const showAdmin = new Writable(false); const adminData = computed(() => [...people.get()] .sort((a, b) => a.rank - b.rank) .map((p) => ({ name: p.name, rank: p.rank, isFirst: p.rank === 1 })) ); const count = computed(() => people.get().length); return { [UI]: (
    {people.map((person) => ( {person.name} ))} {showAdmin ? (
    {count + " people"}
      {adminData.map((entry) => (
    • {entry.isFirst ? "★ " : ""} {entry.name}
    • ))}
    ) : null}
    ), }; });