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
use crate::{
    unpack_named_slots, widget,
    widget::{unit::size::SizeBoxNode, utils::Rect},
    widget_component,
};
use serde::{Deserialize, Serialize};

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct WrapBoxProps {
    #[serde(default)]
    pub margin: Rect,
}
implement_props_data!(WrapBoxProps, "WrapBoxProps");

widget_component! {
    pub wrap_box(id, props, named_slots) {
        unpack_named_slots!(named_slots => content);
        let WrapBoxProps { margin } = props.read_cloned_or_default();

        widget! {{{
            SizeBoxNode {
                id: id.to_owned(),
                props: props.clone(),
                slot: Box::new(content),
                margin,
                ..Default::default()
            }
        }}}
    }
}