From 491d3fb0ae2fbe140aefa81618ee03c95f6849cb Mon Sep 17 00:00:00 2001 From: Israel Barbara Date: Thu, 19 Dec 2024 08:02:13 -0300 Subject: [PATCH 01/19] Create leptos input crate --- packages/leptos/input/Cargo.toml | 9 +++++++++ packages/leptos/input/src/lib.rs | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 packages/leptos/input/Cargo.toml create mode 100644 packages/leptos/input/src/lib.rs diff --git a/packages/leptos/input/Cargo.toml b/packages/leptos/input/Cargo.toml new file mode 100644 index 0000000..12b5be4 --- /dev/null +++ b/packages/leptos/input/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "input" +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +version.workspace = true + +[dependencies] diff --git a/packages/leptos/input/src/lib.rs b/packages/leptos/input/src/lib.rs new file mode 100644 index 0000000..b93cf3f --- /dev/null +++ b/packages/leptos/input/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: u64, right: u64) -> u64 { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} From 943df513063d19f215e3b77b9d2d975cceab9f1b Mon Sep 17 00:00:00 2001 From: Israel Barbara Date: Thu, 19 Dec 2024 08:05:07 -0300 Subject: [PATCH 02/19] Add README and Cargo.toml --- Cargo.lock | 9 +++++++++ packages/leptos/input/Cargo.toml | 9 ++++++++- packages/leptos/input/README.md | 21 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 packages/leptos/input/README.md diff --git a/Cargo.lock b/Cargo.lock index 1328a5b..964baec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3496,6 +3496,15 @@ dependencies = [ "tailwind_fuse", ] +[[package]] +name = "shadcn-ui-leptos-input" +version = "0.0.1" +dependencies = [ + "leptos 0.7.0", + "leptos-style", + "tailwind_fuse", +] + [[package]] name = "shadcn-ui-leptos-utils" version = "0.0.1" diff --git a/packages/leptos/input/Cargo.toml b/packages/leptos/input/Cargo.toml index 12b5be4..f2955a8 100644 --- a/packages/leptos/input/Cargo.toml +++ b/packages/leptos/input/Cargo.toml @@ -1,5 +1,9 @@ [package] -name = "input" +name = "shadcn-ui-leptos-input" +description = "Leptos port of shadcn/ui Input." +homepage = "https://shadcn-ui.rustforweb.org/components/input.html" +publish = false + authors.workspace = true edition.workspace = true license.workspace = true @@ -7,3 +11,6 @@ repository.workspace = true version.workspace = true [dependencies] +tailwind_fuse.workspace = true +leptos.workspace = true +leptos-style.workspace = true diff --git a/packages/leptos/input/README.md b/packages/leptos/input/README.md new file mode 100644 index 0000000..3624dc1 --- /dev/null +++ b/packages/leptos/input/README.md @@ -0,0 +1,21 @@ +

+ + Rust shadcn/ui Logo + +

+ +

shadcn-ui-leptos-input

+ +Displays a form input field or a component that looks like an input field. + +[Rust shadcn/ui](https://github.com/RustForWeb/shadcn-ui) is a Rust port of [shadcn/ui](https://ui.shadcn.com/). + +## Documentation + +See [the Rust shadcn/ui book](https://shadcn-ui.rustforweb.org/) for documentation. + +## Rust For Web + +The Rust shadcn/ui project is part of the [Rust For Web](https://github.com/RustForWeb). + +[Rust For Web](https://github.com/RustForWeb) creates and ports web UI libraries for Rust. All projects are free and open source. From b3ff447ba8b47d4c2661d7543d1952c266e56c34 Mon Sep 17 00:00:00 2001 From: Israel Barbara Date: Fri, 20 Dec 2024 15:31:50 -0300 Subject: [PATCH 03/19] Add input default/new-york with errors --- Cargo.lock | 2 + packages/leptos/input/Cargo.toml | 2 + packages/leptos/input/src/default.rs | 153 ++++++++++++++++++++++++++ packages/leptos/input/src/lib.rs | 20 ++-- packages/leptos/input/src/new_york.rs | 112 +++++++++++++++++++ 5 files changed, 276 insertions(+), 13 deletions(-) create mode 100644 packages/leptos/input/src/default.rs create mode 100644 packages/leptos/input/src/new_york.rs diff --git a/Cargo.lock b/Cargo.lock index 964baec..f1e4c92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3501,7 +3501,9 @@ name = "shadcn-ui-leptos-input" version = "0.0.1" dependencies = [ "leptos 0.7.0", + "leptos-node-ref", "leptos-style", + "shadcn-ui-leptos-utils", "tailwind_fuse", ] diff --git a/packages/leptos/input/Cargo.toml b/packages/leptos/input/Cargo.toml index f2955a8..321e020 100644 --- a/packages/leptos/input/Cargo.toml +++ b/packages/leptos/input/Cargo.toml @@ -13,4 +13,6 @@ version.workspace = true [dependencies] tailwind_fuse.workspace = true leptos.workspace = true +leptos-node-ref.workspace = true leptos-style.workspace = true +shadcn-ui-leptos-utils = { path = "../utils" } diff --git a/packages/leptos/input/src/default.rs b/packages/leptos/input/src/default.rs new file mode 100644 index 0000000..80f0653 --- /dev/null +++ b/packages/leptos/input/src/default.rs @@ -0,0 +1,153 @@ + +use leptos::{ev::InputEvent, ev::FocusEvent,prelude::*}; +use leptos_node_ref::AnyNodeRef; +use leptos_style::Style; +use shadcn_ui_leptos_utils::{self, BoxOneCallback}; +use tailwind_fuse::*; + + +// Define a generic type alias for an event handler +//type EventHandler = Box; + +#[component] +pub fn Input( + // Global attributes + #[prop(into, optional)] class: MaybeProp, + #[prop(into, optional)] id: MaybeProp, + #[prop(into, optional)] style: Signal