/// import { computed, equals, NAME, pattern, SELF, UI, Writable, } from "commontools"; type Piece = Writable<{ [NAME]?: string }>; type Input = { pieces: Piece[]; }; export default pattern(({ pieces, [SELF]: self }) => { // Filter out self to prevent infinite recursion if this grid view // appears in the pieces list it's rendering const filtered = computed(() => pieces.filter((piece: Piece) => !equals(piece, self)) ); return { [NAME]: "Grid View", [UI]: ( {filtered.map((piece: Piece) => (
))}
), }; });