use leptos::ev;
use leptos::prelude::*;
use leptos_router::hooks::use_navigate;
use super::Ctx;
use super::icons::{IconSvg, icon_label};
use crate::api::get_members;
use crate::model::{Category, Icon, Item, ItemInput, ItemOp, ListColor, Quantity, ShoppingList, Unit};
#[derive(Clone, Debug, PartialEq)]
pub enum ItemEditor {
New,
Edit(Item),
}
#[derive(Clone, Debug, PartialEq)]
pub enum ListEditor {
New,
Edit(ShoppingList),
}
/// Bottom sheet with a backdrop; `on_close` runs on backdrop tap or Escape.
#[component]
pub fn Sheet(title: String, on_close: impl Fn() + Copy + Send + Sync + 'static, children: Children) -> impl IntoView {
let handle = window_event_listener(ev::keydown, move |ev| {
if ev.key() == "Escape" {
on_close();
}
});
on_cleanup(move || handle.remove());
view! {
}
}
#[component]
pub fn ItemSheet(#[prop(into)] list_id: Signal