summary refs log tree commit diff stats
path: root/rocie-macros/src/form/mod.rs
blob: 7abd8f60fe1613a370bff5e19de7947eeff4dc04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use syn::{Expr, Ident, LitStr, Type};

mod generate;
mod parse;

pub use generate::form_impl;

#[derive(Debug)]
pub struct ParsedOnSubmit {
    inputs: Vec<Ident>,
    block: Expr,
    pub(crate) should_use_move: bool,
}

#[derive(Debug)]
pub enum ParsedChild {
    Input {
        name: Ident,
        rust_type: Type,
        html_type: LitStr,
        label: LitStr,
        reactive: Option<Ident>,
        auto_complete: Option<Ident>,
    },
    Select {
        name: Ident,
        label: LitStr,
        rust_type: Type,
        options: Expr, // Vec<(String, Uuid)>
    },
    Show { when: Expr, children: Vec<ParsedChild> },
}

#[derive(Debug)]
pub struct ParsedInput {
    on_submit: ParsedOnSubmit,
    children: Vec<ParsedChild>,
}