Files
flowgraph/tasks/component-conditional.md

42 lines
1.5 KiB
Markdown

---
id: component/conditional
name: Implement <Conditional> ujsx component
status: completed
depends_on:
- schema/edge-attrs
- setup/project-init
scope: narrow
risk: low
impact: component
level: implementation
---
## Description
Implement the `Conditional` ujsx component function. Represents conditional branching — children only execute if the test passes. Supports an optional `else` prop for the alternative branch.
## Acceptance Criteria
- [ ] `src/component/conditional.ts` exports `Conditional` component function
- [ ] `Conditional` produces `UElement` with `type: "conditional"`
- [ ] Props: `test: ((results: Record<string, CallResult>) => boolean) | string` (required), optional `else: UNode`
- [ ] `children` of Conditional are the then-branch
- [ ] `else` prop is the alternative branch
- [ ] String condition: operation name whose completion status determines the branch
- [ ] Function condition: receives predecessor results, returns boolean
- [ ] Conditional.test cannot reference an Operation inside the Conditional itself (would create circular dependency)
- [ ] Re-exported from `src/component/index.ts`
- [ ] Unit tests: correct UElement shape with test as function, test as string, else prop
## References
- docs/architecture/workflow-templates.md — Conditional component, else-branch behavior, string condition resolution
- docs/architecture/schema.md — TemplateEdgeAttrs.condition representation
## Notes
> To be filled by implementation agent
## Summary
> To be filled on completion