1use crate::{EzCptIds, Form, FormField, LayoutItem};
2use ratatui::layout::{Constraint, Direction};
3
4#[derive(Debug)]
6pub enum FormNode<FID>
7where
8 FID: EzCptIds,
9{
10 Field(FormField<FID>),
12 Form(Form<FID>),
14}
15impl<FID> FormNode<FID>
16where
17 FID: EzCptIds,
18{
19 pub(crate) fn as_layout_item(&self, _direction: Direction, _count: usize) -> LayoutItem<FID> {
20 match self {
21 FormNode::Field(field) => LayoutItem::Component(field.id().clone()),
22 FormNode::Form(form) => LayoutItem::NestedLayout(form.custom_layout()),
23 }
24 }
25 pub(crate) fn as_constraint(&self, direction: Direction, count: usize) -> Constraint {
26 match self {
27 FormNode::Field(field) => field.as_constraint(direction, count),
28 FormNode::Form(form) => form.as_constraint(direction, count),
29 }
30 }
31}