From d0821800bb3db9dcfb8cdc9bdb2c841c7141c354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABlle=20Huisman?= Date: Mon, 24 Jun 2024 20:59:12 +0200 Subject: [PATCH] Add start of collection --- .../primitives/leptos/collection/Cargo.toml | 14 +++++++++ .../primitives/leptos/collection/README.md | 13 ++++++++ .../leptos/collection/src/collection.rs | 30 +++++++++++++++++++ .../primitives/leptos/collection/src/lib.rs | 9 ++++++ 4 files changed, 66 insertions(+) create mode 100644 packages/primitives/leptos/collection/Cargo.toml create mode 100644 packages/primitives/leptos/collection/README.md create mode 100644 packages/primitives/leptos/collection/src/collection.rs create mode 100644 packages/primitives/leptos/collection/src/lib.rs diff --git a/packages/primitives/leptos/collection/Cargo.toml b/packages/primitives/leptos/collection/Cargo.toml new file mode 100644 index 0000000..0af6d30 --- /dev/null +++ b/packages/primitives/leptos/collection/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "radix-leptos-collection" +description = "Leptos port of Radix Collection." + +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +version.workspace = true + +[dependencies] +leptos.workspace = true +radix-leptos-compose-refs = { path = "../compose-refs", version = "0.0.1" } +radix-leptos-primitive = { path = "../primitive", version = "0.0.1" } diff --git a/packages/primitives/leptos/collection/README.md b/packages/primitives/leptos/collection/README.md new file mode 100644 index 0000000..3c4fa45 --- /dev/null +++ b/packages/primitives/leptos/collection/README.md @@ -0,0 +1,13 @@ +

+ + + +

+ +

radix-leptos-roving-focus

+ +This is an internal utility, not intended for public usage. + +## Rust Radix + +[Rust Radix](https://github.com/NixySoftware/radix) is a Rust port of [Radix](https://www.radix-ui.com/primitives). diff --git a/packages/primitives/leptos/collection/src/collection.rs b/packages/primitives/leptos/collection/src/collection.rs new file mode 100644 index 0000000..1c15f91 --- /dev/null +++ b/packages/primitives/leptos/collection/src/collection.rs @@ -0,0 +1,30 @@ +// TODO: remove +#![allow(dead_code, unused_variables)] + +use std::collections::HashMap; + +use leptos::{ + html::{AnyElement, ElementDescriptor}, + *, +}; + +#[derive(Clone)] +struct CollectionContextValue { + collection_ref: NodeRef, + item_map: RwSignal, ItemData)>>, +} + +#[component] +pub fn CollectionProvider(children: ChildrenFn) -> impl IntoView { + // TODO: generics + let context_value = CollectionContextValue:: { + collection_ref: create_node_ref(), + item_map: create_rw_signal(HashMap::new()), + }; + + view! { + + {children()} + + } +} diff --git a/packages/primitives/leptos/collection/src/lib.rs b/packages/primitives/leptos/collection/src/lib.rs new file mode 100644 index 0000000..e872802 --- /dev/null +++ b/packages/primitives/leptos/collection/src/lib.rs @@ -0,0 +1,9 @@ +//! Leptos port of [Radix Collection](https://www.radix-ui.com/primitives). +//! +//! This is an internal utility, not intended for public usage. +//! +//! See [`@radix-ui/react-collection`](https://www.npmjs.com/package/@radix-ui/react-collection) for the original package. + +mod collection; + +pub use collection::*;