//! ContextMenu submenu components //! //! This module contains the ContextMenuSub, ContextMenuSubTrigger, //! and ContextMenuSubContent components for nested context menus. use leptos::prelude::*; use leptos_style::Style; use web_sys::MouseEvent; #[component] pub fn ContextMenuSub( #[prop(optional)] children: Option, ) -> impl IntoView { let open = RwSignal::new(false); provide_context(open); view! {
{children.map(|c| c())}
} } #[component] pub fn ContextMenuSubTrigger( #[prop(into, optional)] class: MaybeProp, #[prop(into, optional)] id: MaybeProp, #[prop(into, optional)] style: MaybeProp, #[prop(into, optional)] disabled: MaybeProp, #[prop(optional)] children: Option, ) -> impl IntoView { let open = expect_context::>(); let handle_mouse_enter = move |_| { if !disabled.get().unwrap_or(false) { open.set(true); } }; let handle_mouse_leave = move |_| { open.set(false); }; let trigger_class = move || { let base_class = "context-menu-sub-trigger"; let disabled_class = if disabled.get().unwrap_or(false) { " disabled" } else { "" }; let custom_class = class.get().unwrap_or_default(); format!("{}{} {}", base_class, disabled_class, custom_class) }; view! { } } #[component] pub fn ContextMenuSubContent( #[prop(into, optional)] class: MaybeProp, #[prop(into, optional)] id: MaybeProp, #[prop(into, optional)] style: MaybeProp, #[prop(optional)] children: Option, ) -> impl IntoView { let open = expect_context::>(); let handle_click = move |e: MouseEvent| { e.stop_propagation(); }; view! { } }