diff --git a/Cargo.toml b/Cargo.toml index b8d2d67..21b947b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,4 +17,7 @@ leptos = "0.3" web-sys = { version = "0.3", features = ["ScrollToOptions", "ScrollBehavior", "CssStyleDeclaration"] } wasm-bindgen = "0.2" js-sys = "0.3" -default-struct-builder = "0.1" \ No newline at end of file +default-struct-builder = "0.1" + +[features] +docs = [] \ No newline at end of file diff --git a/docs/book/post_build.py b/docs/book/post_build.py index ce8afab..d6cc821 100644 --- a/docs/book/post_build.py +++ b/docs/book/post_build.py @@ -30,9 +30,9 @@ def build_and_copy_demo(category, md_name): dirs_exist_ok=True) with open(os.path.join(target_path, "index.html"), "r") as f: - html = f.read().replace("./demo", f"./{name}/demo") - head = html.split("")[1].split("")[0] - body = html.split("")[1].split("")[0] + html = f.read().replace("/demo", f"./{name}/demo") + demo_head = html.split("")[1].split("")[0] + demo_body = html.split("")[1].split("")[0] book_html_path = os.path.join("book", category, f"{name}.html") with open(book_html_path, "r") as f: @@ -46,11 +46,11 @@ def build_and_copy_demo(category, md_name): f.write( f"""{head_split[0]} - {head} + {demo_head} {target_head} - {body} + {demo_body} {target_body} {body_split[1]}""") diff --git a/docs/book/src/custom.css b/docs/book/src/custom.css index a400dc7..78faaf9 100644 --- a/docs/book/src/custom.css +++ b/docs/book/src/custom.css @@ -1,5 +1,20 @@ +:root { + --brand-color: #EF3939; + --brand-color-dark: #9c2525; + --background-color: #ffffff; + --text-color: #856464; + --devider-light-color: #bbb; +} + .light { --fg: #333; + --links: #c42f2f; + --sidebar-active: var(--links); +} + +.coal { + --links: #ee6f6f; + --sidebar-active: var(--links); } pre > code { diff --git a/docs/book/src/demo.css b/docs/book/src/demo.css index a0d77f5..7adf66a 100644 --- a/docs/book/src/demo.css +++ b/docs/book/src/demo.css @@ -1,8 +1,3 @@ -:root { - --brand-color: #EF3939; - --brand-color-dark: #9c2525; -} - .demo-container { position: relative; } @@ -29,6 +24,8 @@ .ayu .demo-container, .navy .demo-container, .coal .demo-container { background-color: #1d1f21; + --background-color: #1d1f21; + --text-color: #aaaaaa; } .demo-container button { @@ -63,4 +60,17 @@ .demo-container .note { opacity: 0.7; font-size: 1.4rem; +} + +.demo-container input[type="text"], .demo-container input[type="search"], .demo-container input[type="number"] { + display: block; + font-size: 90%; + padding: .5em 1em .4em; + border: 1px solid var(--divider-light-color); + border-radius: 4px; + outline: none; + background: var(--background-color); + color: var(--text-color); + min-width: 20rem; + margin: .5rem 0; } \ No newline at end of file diff --git a/examples/use_debounce_fn/Cargo.toml b/examples/use_debounce_fn/Cargo.toml index df49a7a..21f7aa5 100644 --- a/examples/use_debounce_fn/Cargo.toml +++ b/examples/use_debounce_fn/Cargo.toml @@ -8,7 +8,7 @@ leptos = "0.3" console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../.." } +leptos-use = { path = "../..", features = ["docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_debounce_fn/Trunk.toml b/examples/use_debounce_fn/Trunk.toml index f521021..3e4be08 100644 --- a/examples/use_debounce_fn/Trunk.toml +++ b/examples/use_debounce_fn/Trunk.toml @@ -1,2 +1,2 @@ [build] -public_url = "./demo/" \ No newline at end of file +public_url = "/demo/" \ No newline at end of file diff --git a/examples/use_debounce_fn/src/main.rs b/examples/use_debounce_fn/src/main.rs index 6801092..9416a02 100644 --- a/examples/use_debounce_fn/src/main.rs +++ b/examples/use_debounce_fn/src/main.rs @@ -1,6 +1,6 @@ use leptos::*; -use leptos_use::use_debounce_fn_with_options; -use leptos_use::utils::{demo_or_body, DebounceOptions}; +use leptos_use::docs::demo_or_body; +use leptos_use::{use_debounce_fn_with_options, DebounceOptions}; #[component] fn Demo(cx: Scope) -> impl IntoView { @@ -10,9 +10,7 @@ fn Demo(cx: Scope) -> impl IntoView { let debounced_fn = use_debounce_fn_with_options( move || set_debounced_count(debounced_count() + 1), 1000.0, - DebounceOptions { - max_wait: Some(5000.0), - }, + DebounceOptions::default().max_wait(Some(5000.0)), ); view! { cx, diff --git a/examples/use_scroll/Cargo.toml b/examples/use_scroll/Cargo.toml index 4defd6f..07cf122 100644 --- a/examples/use_scroll/Cargo.toml +++ b/examples/use_scroll/Cargo.toml @@ -8,7 +8,7 @@ leptos = "0.3" console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../.." } +leptos-use = { path = "../..", features = ["docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_scroll/README.md b/examples/use_scroll/README.md index c2cc20d..4fb813a 100644 --- a/examples/use_scroll/README.md +++ b/examples/use_scroll/README.md @@ -5,7 +5,7 @@ as well as the nightly toolchain for Rust and the wasm32-unknown-unknown target: ```bash cargo install trunk -npm install -D tailwindcss +npm install -D tailwindcss @tailwindcss/forms rustup toolchain install nightly rustup target add wasm32-unknown-unknown ``` diff --git a/examples/use_scroll/Trunk.toml b/examples/use_scroll/Trunk.toml index f521021..3e4be08 100644 --- a/examples/use_scroll/Trunk.toml +++ b/examples/use_scroll/Trunk.toml @@ -1,2 +1,2 @@ [build] -public_url = "./demo/" \ No newline at end of file +public_url = "/demo/" \ No newline at end of file diff --git a/examples/use_scroll/src/main.rs b/examples/use_scroll/src/main.rs index ab63782..60d4131 100644 --- a/examples/use_scroll/src/main.rs +++ b/examples/use_scroll/src/main.rs @@ -1,10 +1,143 @@ use leptos::*; -use leptos_use::utils::demo_or_body; +use leptos_use::docs::{demo_or_body, BooleanDisplay}; +use leptos_use::{use_scroll_with_options, ScrollBehavior, UseScrollOptions, UseScrollReturn}; #[component] fn Demo(cx: Scope) -> impl IntoView { - view! { cx, + let el = create_node_ref(cx); + let (smooth, set_smooth) = create_signal(cx, false); + let behavior = Signal::derive(cx, move || { + if smooth() { + ScrollBehavior::Smooth + } else { + ScrollBehavior::Auto + } + }); + let UseScrollReturn { + x, + y, + set_x, + set_y, + is_scrolling, + arrived_state, + directions, + .. + } = use_scroll_with_options(cx, el, UseScrollOptions::default().behavior(behavior)); + + view! { cx, +
+
+
+
+ "top_left" +
+
+ "bottom_left" +
+
+ "top_right" +
+
+ "bottom_right" +
+ +
+ "Scroll Me" +
+
+
+ +
+
+ + "X Position" + +
+
+ () { + set_x(num); + } + } + type="number" + min="0" + max="200" + step="10" + /> +
+
+ + "Y Position" + +
+
+ () { + set_y(num); + } + } + type="number" + min="0" + max="200" + step="10" + /> +
+
+ + + + + + "Is Scrolling" + + +
+ "Top Arrived" +
+ +
+ "Right Arrived" +
+ +
+ "Bottom Arrived" +
+ +
+ "Left Arrived" +
+ +
+ "Scrolling Up" +
+ +
+ "Scrolling Right" +
+ +
+ "Scrolling Down" +
+ +
+ "Scrolling Left" +
+ +
+
+
} } diff --git a/examples/use_scroll/style/output.css b/examples/use_scroll/style/output.css index 3093b1b..888eb5c 100644 --- a/examples/use_scroll/style/output.css +++ b/examples/use_scroll/style/output.css @@ -1,3 +1,169 @@ +[type='text'],[type='email'],[type='url'],[type='password'],[type='number'],[type='date'],[type='datetime-local'],[type='month'],[type='search'],[type='tel'],[type='time'],[type='week'],[multiple],textarea,select { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + background-color: #fff; + border-color: #6b7280; + border-width: 1px; + border-radius: 0px; + padding-top: 0.5rem; + padding-right: 0.75rem; + padding-bottom: 0.5rem; + padding-left: 0.75rem; + font-size: 1rem; + line-height: 1.5rem; + --tw-shadow: 0 0 #0000; +} + +[type='text']:focus, [type='email']:focus, [type='url']:focus, [type='password']:focus, [type='number']:focus, [type='date']:focus, [type='datetime-local']:focus, [type='month']:focus, [type='search']:focus, [type='tel']:focus, [type='time']:focus, [type='week']:focus, [multiple]:focus, textarea:focus, select:focus { + outline: 2px solid transparent; + outline-offset: 2px; + --tw-ring-inset: var(--tw-empty,/*!*/ /*!*/); + --tw-ring-offset-width: 0px; + --tw-ring-offset-color: #fff; + --tw-ring-color: #2563eb; + --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); + --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color); + box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow); + border-color: #2563eb; +} + +input::-moz-placeholder, textarea::-moz-placeholder { + color: #6b7280; + opacity: 1; +} + +input::placeholder,textarea::placeholder { + color: #6b7280; + opacity: 1; +} + +::-webkit-datetime-edit-fields-wrapper { + padding: 0; +} + +::-webkit-date-and-time-value { + min-height: 1.5em; +} + +::-webkit-datetime-edit,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-meridiem-field { + padding-top: 0; + padding-bottom: 0; +} + +select { + background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); + background-position: right 0.5rem center; + background-repeat: no-repeat; + background-size: 1.5em 1.5em; + padding-right: 2.5rem; + -webkit-print-color-adjust: exact; + print-color-adjust: exact; +} + +[multiple] { + background-image: initial; + background-position: initial; + background-repeat: unset; + background-size: initial; + padding-right: 0.75rem; + -webkit-print-color-adjust: unset; + print-color-adjust: unset; +} + +[type='checkbox'],[type='radio'] { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + padding: 0; + -webkit-print-color-adjust: exact; + print-color-adjust: exact; + display: inline-block; + vertical-align: middle; + background-origin: border-box; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + flex-shrink: 0; + height: 1rem; + width: 1rem; + color: #2563eb; + background-color: #fff; + border-color: #6b7280; + border-width: 1px; + --tw-shadow: 0 0 #0000; +} + +[type='checkbox'] { + border-radius: 0px; +} + +[type='radio'] { + border-radius: 100%; +} + +[type='checkbox']:focus,[type='radio']:focus { + outline: 2px solid transparent; + outline-offset: 2px; + --tw-ring-inset: var(--tw-empty,/*!*/ /*!*/); + --tw-ring-offset-width: 2px; + --tw-ring-offset-color: #fff; + --tw-ring-color: #2563eb; + --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); + --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color); + box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow); +} + +[type='checkbox']:checked,[type='radio']:checked { + border-color: transparent; + background-color: currentColor; + background-size: 100% 100%; + background-position: center; + background-repeat: no-repeat; +} + +[type='checkbox']:checked { + background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e"); +} + +[type='radio']:checked { + background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e"); +} + +[type='checkbox']:checked:hover,[type='checkbox']:checked:focus,[type='radio']:checked:hover,[type='radio']:checked:focus { + border-color: transparent; + background-color: currentColor; +} + +[type='checkbox']:indeterminate { + background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e"); + border-color: transparent; + background-color: currentColor; + background-size: 100% 100%; + background-position: center; + background-repeat: no-repeat; +} + +[type='checkbox']:indeterminate:hover,[type='checkbox']:indeterminate:focus { + border-color: transparent; + background-color: currentColor; +} + +[type='file'] { + background: unset; + border-color: inherit; + border-width: 0; + border-radius: 0; + padding: 0; + font-size: unset; + line-height: inherit; +} + +[type='file']:focus { + outline: 1px solid ButtonText; + outline: 1px auto -webkit-focus-ring-color; +} + *, ::before, ::after { --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; @@ -12,6 +178,9 @@ --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; + --tw-gradient-from-position: ; + --tw-gradient-via-position: ; + --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; @@ -42,7 +211,7 @@ --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; - --tw-backdrop-sepia: + --tw-backdrop-sepia: ; } ::backdrop { @@ -59,6 +228,9 @@ --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; + --tw-gradient-from-position: ; + --tw-gradient-via-position: ; + --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; @@ -89,5 +261,186 @@ --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; - --tw-backdrop-sepia: + --tw-backdrop-sepia: ; +} + +.absolute { + position: absolute; +} + +.relative { + position: relative; +} + +.bottom-0 { + bottom: 0px; +} + +.left-0 { + left: 0px; +} + +.left-1\/3 { + left: 33.333333%; +} + +.right-0 { + right: 0px; +} + +.top-0 { + top: 0px; +} + +.top-1\/3 { + top: 33.333333%; +} + +.m-auto { + margin: auto; +} + +.flex { + display: flex; +} + +.grid { + display: grid; +} + +.h-\[300px\] { + height: 300px; +} + +.h-\[400px\] { + height: 400px; +} + +.w-\[300px\] { + width: 300px; +} + +.w-\[500px\] { + width: 500px; +} + +.w-full { + width: 100%; +} + +.\!min-w-0 { + min-width: 0px !important; +} + +.grid-cols-\[120px_auto\] { + grid-template-columns: 120px auto; +} + +.gap-2 { + gap: 0.5rem; +} + +.gap-5 { + gap: 1.25rem; +} + +.gap-4 { + gap: 1rem; +} + +.overflow-scroll { + overflow: scroll; +} + +.rounded { + border-radius: 0.25rem; +} + +.bg-gray-500\/5 { + background-color: rgb(107 114 128 / 0.05); +} + +.px-2 { + padding-left: 0.5rem; + padding-right: 0.5rem; +} + +.px-6 { + padding-left: 1.5rem; + padding-right: 1.5rem; +} + +.py-1 { + padding-top: 0.25rem; + padding-bottom: 0.25rem; +} + +.py-4 { + padding-top: 1rem; + padding-bottom: 1rem; +} + +.pl-4 { + padding-left: 1rem; +} + +.text-right { + text-align: right; +} + +.font-bold { + font-weight: 700; +} + +.text-orange-400 { + --tw-text-opacity: 1; + color: rgb(251 146 60 / var(--tw-text-opacity)); +} + +.text-\[\] { + color: ; +} + +.text-\[--\] { + color: var(--); +} + +.text-\[--brand-color\] { + color: var(--brand-color); +} + +.text-green-300 { + --tw-text-opacity: 1; + color: rgb(134 239 172 / var(--tw-text-opacity)); +} + +.text-green-700 { + --tw-text-opacity: 1; + color: rgb(21 128 61 / var(--tw-text-opacity)); +} + +.text-green-500 { + --tw-text-opacity: 1; + color: rgb(34 197 94 / var(--tw-text-opacity)); +} + +.text-green-600 { + --tw-text-opacity: 1; + color: rgb(22 163 74 / var(--tw-text-opacity)); +} + +.opacity-75 { + opacity: 0.75; +} + +@media (prefers-color-scheme: dark) { + .dark\:text-orange-300 { + --tw-text-opacity: 1; + color: rgb(253 186 116 / var(--tw-text-opacity)); + } + + .dark\:text-green-500 { + --tw-text-opacity: 1; + color: rgb(34 197 94 / var(--tw-text-opacity)); + } } \ No newline at end of file diff --git a/examples/use_scroll/tailwind.config.js b/examples/use_scroll/tailwind.config.js index dc5562c..bc09f5e 100644 --- a/examples/use_scroll/tailwind.config.js +++ b/examples/use_scroll/tailwind.config.js @@ -1,7 +1,7 @@ /** @type {import('tailwindcss').Config} */ module.exports = { content: { - files: ["*.html", "./src/**/*.rs"], + files: ["*.html", "./src/**/*.rs", "../../src/docs/**/*.rs"], }, theme: { extend: {}, @@ -9,5 +9,7 @@ module.exports = { corePlugins: { preflight: false, }, - plugins: [], + plugins: [ + require('@tailwindcss/forms'), + ], } \ No newline at end of file diff --git a/examples/use_throttle_fn/Cargo.toml b/examples/use_throttle_fn/Cargo.toml index c6f0650..2c4e1f8 100644 --- a/examples/use_throttle_fn/Cargo.toml +++ b/examples/use_throttle_fn/Cargo.toml @@ -8,7 +8,7 @@ leptos = "0.3" console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../.." } +leptos-use = { path = "../..", features = ["docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_throttle_fn/Trunk.toml b/examples/use_throttle_fn/Trunk.toml index f521021..3e4be08 100644 --- a/examples/use_throttle_fn/Trunk.toml +++ b/examples/use_throttle_fn/Trunk.toml @@ -1,2 +1,2 @@ [build] -public_url = "./demo/" \ No newline at end of file +public_url = "/demo/" \ No newline at end of file diff --git a/examples/use_throttle_fn/src/main.rs b/examples/use_throttle_fn/src/main.rs index 1db6efc..225ed4e 100644 --- a/examples/use_throttle_fn/src/main.rs +++ b/examples/use_throttle_fn/src/main.rs @@ -1,6 +1,6 @@ use leptos::*; +use leptos_use::docs::demo_or_body; use leptos_use::use_throttle_fn; -use leptos_use::utils::demo_or_body; #[component] fn Demo(cx: Scope) -> impl IntoView { diff --git a/src/docs/boolean_display.rs b/src/docs/boolean_display.rs new file mode 100644 index 0000000..d2c8e62 --- /dev/null +++ b/src/docs/boolean_display.rs @@ -0,0 +1,27 @@ +use leptos::*; + +#[component] +pub fn BooleanDisplay( + cx: Scope, + #[prop(into)] value: MaybeSignal, + #[prop(optional)] class: String, +) -> impl IntoView { + let true_class = "text-green-600 dark:text-green-500"; + let false_class = "text-[--brand-color]"; + let true_str = "true"; + let false_str = "false"; + + let class = move || { + format!( + "{} {} opacity-75", + if value.get() { true_class } else { false_class }, + class + ) + }; + + view! { cx, + + { move || if value() { true_str} else { false_str } } + + } +} diff --git a/src/utils/demo.rs b/src/docs/demo.rs similarity index 100% rename from src/utils/demo.rs rename to src/docs/demo.rs diff --git a/src/docs/mod.rs b/src/docs/mod.rs new file mode 100644 index 0000000..961c8fa --- /dev/null +++ b/src/docs/mod.rs @@ -0,0 +1,5 @@ +mod boolean_display; +mod demo; + +pub use boolean_display::*; +pub use demo::*; diff --git a/src/lib.rs b/src/lib.rs index 9fcce26..a9a3552 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,8 +7,11 @@ mod use_scroll; mod use_throttle_fn; pub mod utils; +#[cfg(feature = "docs")] +pub mod docs; + pub use use_debounce_fn::*; -pub use use_event_listener::use_event_listener; +pub use use_event_listener::*; pub use use_scroll::*; pub use use_throttle_fn::*; diff --git a/src/use_scroll.rs b/src/use_scroll.rs index 25bd98f..390d4f4 100644 --- a/src/use_scroll.rs +++ b/src/use_scroll.rs @@ -235,7 +235,7 @@ where let on_stop = options.on_stop.clone(); let on_scroll_end = move |e| { - if !is_scrolling.get() { + if !is_scrolling.get_untracked() { return; } @@ -272,8 +272,8 @@ where let scroll_left_abs = scroll_left.abs(); directions.update(|directions| { - directions.left = scroll_left < internal_x.get(); - directions.right = scroll_left > internal_x.get(); + directions.left = scroll_left < internal_x.get_untracked(); + directions.right = scroll_left > internal_x.get_untracked(); }); let left = scroll_left_abs <= offset.left; @@ -301,8 +301,8 @@ where let scroll_top_abs = scroll_top.abs(); directions.update(|directions| { - directions.top = scroll_top < internal_y.get(); - directions.bottom = scroll_top > internal_y.get(); + directions.top = scroll_top < internal_y.get_untracked(); + directions.bottom = scroll_top > internal_y.get_untracked(); }); let top = scroll_top_abs <= offset.top; @@ -343,16 +343,19 @@ where }); if throttle >= 0.0 { + let throttled_scroll_handler = use_throttle_fn_with_arg_and_options( + on_scroll_handler.clone(), + throttle, + ThrottleOptions { + trailing: true, + leading: false, + }, + ); + let handler = move |e: web_sys::Event| { - let _ = use_throttle_fn_with_arg_and_options( - on_scroll_handler.clone(), - throttle, - ThrottleOptions { - trailing: true, - leading: false, - }, - ); + throttled_scroll_handler.clone()(e); }; + let _ = use_event_listener_with_options::< _, Signal>, diff --git a/src/use_throttle_fn.rs b/src/use_throttle_fn.rs index 8f5ec20..f007877 100644 --- a/src/use_throttle_fn.rs +++ b/src/use_throttle_fn.rs @@ -67,7 +67,7 @@ pub use crate::utils::ThrottleOptions; pub fn use_throttle_fn( func: F, ms: impl Into>, -) -> impl Fn() -> Rc>> +) -> impl Fn() -> Rc>> + Clone where F: FnOnce() -> R + Clone + 'static, R: 'static, @@ -80,7 +80,7 @@ pub fn use_throttle_fn_with_options( func: F, ms: impl Into>, options: ThrottleOptions, -) -> impl Fn() -> Rc>> +) -> impl Fn() -> Rc>> + Clone where F: FnOnce() -> R + Clone + 'static, R: 'static, @@ -92,7 +92,7 @@ where pub fn use_throttle_fn_with_arg( func: F, ms: impl Into>, -) -> impl Fn(Arg) -> Rc>> +) -> impl Fn(Arg) -> Rc>> + Clone where F: FnOnce(Arg) -> R + Clone + 'static, Arg: Clone + 'static, @@ -106,7 +106,7 @@ pub fn use_throttle_fn_with_arg_and_options( func: F, ms: impl Into>, options: ThrottleOptions, -) -> impl Fn(Arg) -> Rc>> +) -> impl Fn(Arg) -> Rc>> + Clone where F: FnOnce(Arg) -> R + Clone + 'static, Arg: Clone + 'static, diff --git a/src/utils/mod.rs b/src/utils/mod.rs index aadd367..cce2996 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,7 +1,5 @@ mod clonable_fn; -mod demo; mod filters; pub use clonable_fn::*; -pub use demo::*; pub use filters::*;