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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
mod view;
mod titlebar;
mod text;
mod grid;
mod card;
mod button;
mod vstack;
mod hstack;
mod field;
mod picker;
mod icon;
mod image;
mod complex_text;
mod popover;
mod form;
mod divider;
mod menu;
mod table;
mod checkbox;
mod avatar;
mod tag;
mod popup;
mod file_input;
mod color_picker;
mod signature_field;
mod snackbar;
mod tabs;
mod badge;
mod dynamic_content;
mod sortable_stack;
mod gauge;
mod stepper;
mod disclosure;
mod table_of_content;

pub use badge::{BadgeModifiers, Badge, BadgeType};
pub use button::{Button, ButtonStyle};
pub use disclosure::{Disclosure};
pub use card::{Card, CardStyle};
pub use vstack::{VStack, Alignment};
pub use complex_text::ComplexText;
pub use titlebar::TitleBar;
pub use grid::Grid;
pub use view::View;
pub use field::{Field, FieldType};
pub use picker::{Picker, PickerStyle, PickerOption};
pub use icon::{Icon, icons};
pub use image::{Image, ObjectFit};
pub use popover::{Popover, Placement};
pub use hstack::HStack;
pub use text::{Text, TextStyle};
pub use form::Form;
pub use divider::Divider;
pub use menu::*;
pub use table::*;
pub use checkbox::*;
pub use avatar::*;
pub use tag::*;
pub use popup::*;
pub use file_input::*;
pub use color_picker::*;
pub use signature_field::*;
pub use gauge::{Gauge, GaugeStyle};
pub use snackbar::{Snackbar, SnackbarType};
pub use dynamic_content::{DynamicContent};
pub use stepper::{};
pub use tabs::{
    TabView,
    TabViewItem
};
pub use sortable_stack::SortableStack;
pub use table_of_content::{TableOfContents, TableOfContentsItem};

use crate::node::Node;
use crate::Renderable;

/// Trait that make the children property accessible for Appendable trait
pub trait ChildContainer {
    fn get_children(&mut self) -> &mut Vec<Box<dyn Renderable>>;
}

/// Trait that make a component capable of receiving children
pub trait Appendable: ChildContainer + Clone {

    /// Adds a node to the end of the list of children of a specified parent node.
    /// ```rust
    /// View::new()
    ///     .append_child({
    ///         View::new()
    ///     })
    /// ```
    fn append_child<C>(&mut self, child: C) -> Self
        where
            C: 'static + Renderable,
    {
        self.get_children().push(Box::new(child));
        self.clone()
    }

    /// Adds a node before the first child of the list of children of a specified parent node.
    /// ```rust
    /// View::new()
    ///     .prepend_child({
    ///         View::new()
    ///     })
    /// ```
    fn prepend_child<C>(&mut self, child: C) -> Self
        where
            C: 'static + Renderable,
    {
        self.get_children().insert(0, Box::new(child));
        self.clone()
    }
}