ratatui_kit/components/
context_provider.rs1use crate::{AnyElement, Component, Context};
14use ratatui_kit_macros::Props;
15
16#[derive(Default, Props)]
17pub struct ContextProviderProps<'a> {
19 pub children: Vec<AnyElement<'a>>,
21 pub value: Option<Context<'a>>,
23}
24
25pub struct ContextProvider;
27
28impl Component for ContextProvider {
29 type Props<'a> = ContextProviderProps<'a>;
30 fn new(_props: &Self::Props<'_>) -> Self {
31 Self
32 }
33
34 fn update(
35 &mut self,
36 props: &mut Self::Props<'_>,
37 _hooks: crate::Hooks,
38 updater: &mut crate::ComponentUpdater,
39 ) {
40 updater.set_transparent_layout(true);
41 updater.update_children(
42 props.children.iter_mut(),
43 props.value.as_mut().map(|v| v.borrow()),
44 );
45 }
46}