/** * Renders every atom in `packages/patterns/primitives` at once, each embedded * as a JSX tag with real inputs passed from this pattern's own cells. * * This is the adopter the atoms are checked against. It is what a host doing * the same thing through a `cf:pattern:` import looks like with the import * resolved locally, so a cell that renders as `[object Object]` here would * render that way there too. */ import { computed, Default, NAME, pattern, UI, type VNode, Writable, } from "commonfabric"; import AmountLedger from "../amount-ledger.tsx"; import CheckList from "../check-list.tsx"; import Counter from "../counter.tsx"; import DiceRoller from "../dice-roller.tsx"; import OptionPicker from "../option-picker.tsx"; import SortableTable from "../sortable-table.tsx"; interface AtomsDemoInput { score?: Writable>; strength?: Writable>; dexterity?: Writable>; category?: Writable>; } interface AtomsDemoOutput { [NAME]: string; [UI]: VNode; score: number; statTotal: number; } export const AtomsDemo = pattern( ({ score, strength, dexterity, category, }) => { const statTotal = computed(() => (strength.get() ?? 1) + (dexterity.get() ?? 1) ); return { [NAME]: "Primitive atoms", [UI]: ( Primitive atoms SortableTable AmountLedger CheckList Counter DiceRoller Stat total: {statTotal} OptionPicker ), score, statTotal, }; }, ); export default AtomsDemo;