/// /** * Test case for ternary transformation inside nested Cell.map callbacks. * * The key scenario: A ternary inside a nested .map() callback should be * transformed to ifElse, because the callback body of a Cell.map is * back in "pattern mode" where ternaries need transformation. * * This structure mirrors pattern-nested-jsx-map: outer ternary wraps items.map, * causing ifElse → derive, then inner ternary is inside nested .map callback. */ import { Cell, computed, Default, pattern, UI } from "commontools"; interface Tag { name: string; active: boolean; } interface Item { label: string; tags: Tag[]; } interface PatternInput { items?: Cell>; showInactive?: Default; } export default pattern(({ items, showInactive }) => { const hasItems = computed(() => items.get().length > 0); return { [UI]: (
{hasItems ? ( items.map((item) => (
{/* Ternary in outer map, outside inner map - should also be ifElse */} {item.tags.length > 0 ? item.label : "No tags"}
    {item.tags.map((tag) => (
  • {/* This ternary should be transformed to ifElse */} {tag.active ? tag.name : showInactive ? `(${tag.name})` : ""}
  • ))}
)) ) : (

No items

)}
), }; });