ratatui_kit/components/
context_provider.rs1use crate::{AnyElement, Component, Context};
2use ratatui_kit_macros::Props;
3
4#[derive(Default, Props)]
5pub struct ContextProviderProps<'a> {
6 pub children: Vec<AnyElement<'a>>,
7 pub value: Option<Context<'a>>,
8}
9
10pub struct ContextProvider;
11
12impl Component for ContextProvider {
13 type Props<'a> = ContextProviderProps<'a>;
14 fn new(_props: &Self::Props<'_>) -> Self {
15 Self
16 }
17
18 fn update(
19 &mut self,
20 props: &mut Self::Props<'_>,
21 _hooks: crate::Hooks,
22 updater: &mut crate::ComponentUpdater,
23 ) {
24 updater.set_transparent_layout(true);
25 updater.update_children(
26 props.children.iter_mut(),
27 props.value.as_mut().map(|v| v.borrow()),
28 );
29 }
30}