From 10dedd913690858f05189a6b96d27a872848e99a Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sat, 10 Aug 2024 00:47:13 +0200 Subject: [PATCH 01/21] feat: Dioxus 0.6 support --- Cargo.toml | 32 ++++++------- crates/components/src/accordion.rs | 2 +- crates/components/src/body.rs | 2 +- crates/components/src/button.rs | 2 +- crates/components/src/canvas.rs | 2 +- crates/components/src/checkbox.rs | 20 ++++---- crates/components/src/cursor_area.rs | 2 +- crates/components/src/drag_drop.rs | 2 +- crates/components/src/dropdown.rs | 2 +- crates/components/src/gesture_area.rs | 2 +- crates/components/src/graph.rs | 2 +- crates/components/src/hooks/use_form.rs | 2 +- crates/components/src/icons/arrow.rs | 2 +- crates/components/src/icons/cross.rs | 2 +- crates/components/src/icons/tick.rs | 2 +- crates/components/src/input.rs | 2 +- crates/components/src/link.rs | 6 +-- crates/components/src/loader.rs | 2 +- crates/components/src/menu.rs | 6 +-- crates/components/src/native_container.rs | 2 +- crates/components/src/native_router.rs | 2 +- crates/components/src/network_image.rs | 4 +- crates/components/src/popup.rs | 2 +- crates/components/src/progress_bar.rs | 2 +- crates/components/src/radio.rs | 8 ++-- .../components/src/scroll_views/scroll_bar.rs | 2 +- .../src/scroll_views/scroll_thumb.rs | 5 +- .../src/scroll_views/scroll_view.rs | 2 +- .../src/scroll_views/virtual_scroll_view.rs | 2 +- crates/components/src/sidebar.rs | 2 +- crates/components/src/slider.rs | 2 +- crates/components/src/snackbar.rs | 2 +- crates/components/src/svg.rs | 2 +- crates/components/src/switch.rs | 2 +- crates/components/src/table.rs | 2 +- crates/components/src/tabs.rs | 6 +-- crates/components/src/tile.rs | 7 +-- crates/components/src/tooltip.rs | 2 +- crates/components/src/window_drag_area.rs | 2 +- crates/core/tests/compatible_elements.rs | 4 +- crates/devtools/src/lib.rs | 6 +-- crates/devtools/src/node.rs | 6 ++- crates/devtools/src/property.rs | 6 +-- crates/devtools/src/tabs/layout.rs | 6 ++- crates/devtools/src/tabs/style.rs | 4 +- crates/elements/src/definitions.rs | 47 +++++++++++++++++-- crates/elements/src/events.rs | 2 + crates/elements/src/lib.rs | 6 ++- crates/freya/src/launch.rs | 1 + crates/freya/src/lib.rs | 6 +-- crates/hooks/src/use_init_native_platform.rs | 2 +- crates/hooks/tests/use_editable.rs | 6 +-- crates/hooks/tests/use_focus.rs | 4 +- crates/native-core/src/dioxus.rs | 6 +-- crates/renderer/src/app.rs | 6 +-- crates/renderer/src/renderer.rs | 6 +-- crates/testing/Cargo.toml | 1 + crates/testing/src/launch.rs | 1 + examples/animated_sidebar.rs | 12 ++--- examples/animated_tabs.rs | 6 +-- examples/camera.rs | 2 +- examples/checkbox.rs | 6 +-- examples/file_explorer.rs | 2 +- examples/focus.rs | 8 ++-- examples/form.rs | 4 +- examples/hotreload.rs | 2 +- examples/input.rs | 4 +- examples/material_design_app.rs | 2 +- examples/menu.rs | 2 +- examples/mouse.rs | 4 +- examples/password.rs | 2 +- examples/radio.rs | 6 +-- examples/router.rs | 10 ++-- examples/scroll.rs | 4 +- examples/shader_editor.rs | 2 +- examples/tab.rs | 8 ++-- examples/ui.rs | 2 +- examples/window_title.rs | 2 +- 78 files changed, 210 insertions(+), 160 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3c4da6672..a7d4c8045 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,14 +14,14 @@ hot-reload = ["freya/hot-reload"] custom-tokio-rt = ["freya/custom-tokio-rt"] [patch.crates-io] -# dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev = "7beacdf9c76ae5412d3c2bcd55f7c5d87f486a0f" } -# dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev = "7beacdf9c76ae5412d3c2bcd55f7c5d87f486a0f" } -# dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev = "7beacdf9c76ae5412d3c2bcd55f7c5d87f486a0f" } -# dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev = "7beacdf9c76ae5412d3c2bcd55f7c5d87f486a0f" } -# dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", rev = "7beacdf9c76ae5412d3c2bcd55f7c5d87f486a0f" } -# dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev = "7beacdf9c76ae5412d3c2bcd55f7c5d87f486a0f" } -# dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev = "7beacdf9c76ae5412d3c2bcd55f7c5d87f486a0f" } -# dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev = "7beacdf9c76ae5412d3c2bcd55f7c5d87f486a0f" } +dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } +dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } +dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } +dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } +dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } +dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } +dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } +dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } [workspace.dependencies] freya = { path = "crates/freya", version = "0.2" } @@ -40,14 +40,14 @@ torin = { path = "crates/torin", version = "0.2" } freya-native-core-macro = { path = "crates/native-core-macro", version = "0.2" } freya-native-core = { path = "crates/native-core", version = "0.2" } -dioxus = { version = "0.5", default-features = false, features = ["macro", "signals", "hooks"]} -dioxus-rsx = { version = "0.5", features = ["hot_reload"] } -dioxus-core-macro = { version = "0.5" } -dioxus-hooks = { version = "0.5" } -dioxus-signals = { version = "0.5" } -dioxus-core = { version = "0.5" } -dioxus-hot-reload = { version = "0.5", features = ["file_watcher"], default-features = false } -dioxus-router = { version = "0.5", default-features = false } +dioxus = { version = "0.6.0-alpha.2" } +dioxus-rsx = { version = "0.6.0-alpha.2" } +dioxus-core-macro = { version = "0.6.0-alpha.2" } +dioxus-hooks = { version = "0.6.0-alpha.2" } +dioxus-signals = { version = "0.6.0-alpha.2" } +dioxus-core = { version = "0.6.0-alpha.2" } +dioxus-hot-reload = { version = "0.6.0-alpha.2" } +dioxus-router = { version = "0.6.0-alpha.2" } dioxus-sdk = { version = "0.5", features = ["clipboard"]} skia-safe = { version = "0.75.0", features = ["gl", "textlayout", "svg"] } diff --git a/crates/components/src/accordion.rs b/crates/components/src/accordion.rs index 362b537ad..43341bcf4 100644 --- a/crates/components/src/accordion.rs +++ b/crates/components/src/accordion.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::MouseEvent, }; use freya_hooks::{ diff --git a/crates/components/src/body.rs b/crates/components/src/body.rs index af10d28a4..12e631def 100644 --- a/crates/components/src/body.rs +++ b/crates/components/src/body.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, BodyTheme, diff --git a/crates/components/src/button.rs b/crates/components/src/button.rs index f2ab2083e..8b3f03ecb 100644 --- a/crates/components/src/button.rs +++ b/crates/components/src/button.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::{ KeyboardEvent, PointerEvent, diff --git a/crates/components/src/canvas.rs b/crates/components/src/canvas.rs index c6efdced0..e82821ec0 100644 --- a/crates/components/src/canvas.rs +++ b/crates/components/src/canvas.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, CanvasTheme, diff --git a/crates/components/src/checkbox.rs b/crates/components/src/checkbox.rs index 661637664..dafec70e6 100644 --- a/crates/components/src/checkbox.rs +++ b/crates/components/src/checkbox.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, CheckboxTheme, @@ -38,8 +38,8 @@ use crate::TickIcon; /// leading: rsx!( /// Checkbox { /// selected: selected.read().contains(&Choice::First), -/// }, -/// ), +/// } +/// ) /// label { "First choice" } /// } /// Tile { @@ -53,7 +53,7 @@ use crate::TickIcon; /// leading: rsx!( /// Checkbox { /// selected: selected.read().contains(&Choice::Second), -/// }, +/// } /// ), /// label { "Second choice" } /// } @@ -130,8 +130,8 @@ mod test { leading: rsx!( Checkbox { selected: selected.read().contains(&Choice::First), - }, - ), + } + ) label { "First choice" } } Tile { @@ -145,8 +145,8 @@ mod test { leading: rsx!( Checkbox { selected: selected.read().contains(&Choice::Second), - }, - ), + } + ) label { "Second choice" } } Tile { @@ -160,8 +160,8 @@ mod test { leading: rsx!( Checkbox { selected: selected.read().contains(&Choice::Third), - }, - ), + } + ) label { "Third choice" } } ) diff --git a/crates/components/src/cursor_area.rs b/crates/components/src/cursor_area.rs index 26470d2bd..c3bbf605f 100644 --- a/crates/components/src/cursor_area.rs +++ b/crates/components/src/cursor_area.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::use_platform; pub use winit::window::CursorIcon; diff --git a/crates/components/src/drag_drop.rs b/crates/components/src/drag_drop.rs index 1b7cd3f61..afd5de946 100644 --- a/crates/components/src/drag_drop.rs +++ b/crates/components/src/drag_drop.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::MouseEvent, }; use freya_hooks::use_node_signal; diff --git a/crates/components/src/dropdown.rs b/crates/components/src/dropdown.rs index ecbc58d17..433756bf4 100644 --- a/crates/components/src/dropdown.rs +++ b/crates/components/src/dropdown.rs @@ -2,7 +2,7 @@ use std::fmt::Display; use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::{ keyboard::Key, KeyboardEvent, diff --git a/crates/components/src/gesture_area.rs b/crates/components/src/gesture_area.rs index 7013039b2..7ce0295fb 100644 --- a/crates/components/src/gesture_area.rs +++ b/crates/components/src/gesture_area.rs @@ -5,7 +5,7 @@ use std::{ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::{ touch::TouchPhase, TouchEvent, diff --git a/crates/components/src/graph.rs b/crates/components/src/graph.rs index e73f4c2ac..7c0b3cdb3 100644 --- a/crates/components/src/graph.rs +++ b/crates/components/src/graph.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_engine::prelude::*; use freya_hooks::{ use_applied_theme, diff --git a/crates/components/src/hooks/use_form.rs b/crates/components/src/hooks/use_form.rs index c1e26070d..248fa81ed 100644 --- a/crates/components/src/hooks/use_form.rs +++ b/crates/components/src/hooks/use_form.rs @@ -52,7 +52,7 @@ impl UseForm { onpress: Some(EventHandler::new(move |_| { (submit.peek())(&data.read()); })), - children: None, + children: Ok(VNode::placeholder()), onclick: None, } } diff --git a/crates/components/src/icons/arrow.rs b/crates/components/src/icons/arrow.rs index 352c0456b..3d73862e9 100644 --- a/crates/components/src/icons/arrow.rs +++ b/crates/components/src/icons/arrow.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, IconTheme, diff --git a/crates/components/src/icons/cross.rs b/crates/components/src/icons/cross.rs index d638d9f0b..26680f144 100644 --- a/crates/components/src/icons/cross.rs +++ b/crates/components/src/icons/cross.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, IconTheme, diff --git a/crates/components/src/icons/tick.rs b/crates/components/src/icons/tick.rs index c60269687..2873a1cad 100644 --- a/crates/components/src/icons/tick.rs +++ b/crates/components/src/icons/tick.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, IconTheme, diff --git a/crates/components/src/input.rs b/crates/components/src/input.rs index 3679e4345..f06a819ba 100644 --- a/crates/components/src/input.rs +++ b/crates/components/src/input.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::{ keyboard::Key, KeyboardData, diff --git a/crates/components/src/link.rs b/crates/components/src/link.rs index 15ecb295b..f47982c44 100644 --- a/crates/components/src/link.rs +++ b/crates/components/src/link.rs @@ -6,7 +6,7 @@ use dioxus_router::prelude::{ IntoRoutable, }; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::MouseEvent, }; use freya_hooks::{ @@ -46,7 +46,7 @@ pub enum LinkTooltip { /// ```rust /// # use dioxus::prelude::*; /// # use dioxus_router::prelude::*; -/// # use freya_elements::elements as dioxus_elements; +/// # use freya_elements as dioxus_elements; /// # use freya_components::Link; /// # #[derive(Routable, Clone)] /// # #[rustfmt::skip] @@ -74,7 +74,7 @@ pub enum LinkTooltip { /// /// ```rust /// # use dioxus::prelude::*; -/// # use freya_elements::elements as dioxus_elements; +/// # use freya_elements as dioxus_elements; /// # use freya_components::Link; /// # fn link_example_good() -> Element { /// rsx! { diff --git a/crates/components/src/loader.rs b/crates/components/src/loader.rs index 19fdfddb8..9c2102294 100644 --- a/crates/components/src/loader.rs +++ b/crates/components/src/loader.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_animation, use_applied_theme, diff --git a/crates/components/src/menu.rs b/crates/components/src/menu.rs index b00457921..da16e2d35 100644 --- a/crates/components/src/menu.rs +++ b/crates/components/src/menu.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::MouseEvent, }; use freya_hooks::{ @@ -238,7 +238,7 @@ pub fn SubMenu( close_menus_until(&mut menus, parent_menu_id); push_menu(&mut menus, submenu_id); }, - {children}, + {children} if show_submenu { rect { position_top: "-12", @@ -276,7 +276,7 @@ pub fn MenuButton( if let Some(onclick) = &onclick { onclick.call(e) } - } + }, {children} } ) diff --git a/crates/components/src/native_container.rs b/crates/components/src/native_container.rs index d1a441c99..349177c66 100644 --- a/crates/components/src/native_container.rs +++ b/crates/components/src/native_container.rs @@ -1,7 +1,7 @@ use dioxus::prelude::*; use freya_common::EventMessage; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::KeyboardEvent, }; use freya_hooks::{ diff --git a/crates/components/src/native_router.rs b/crates/components/src/native_router.rs index ea518f2ee..8cb56d265 100644 --- a/crates/components/src/native_router.rs +++ b/crates/components/src/native_router.rs @@ -1,7 +1,7 @@ use dioxus::prelude::*; use dioxus_router::prelude::use_navigator; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::{ MouseButton, PointerEvent, diff --git a/crates/components/src/network_image.rs b/crates/components/src/network_image.rs index 4b39d6030..785f6f30e 100644 --- a/crates/components/src/network_image.rs +++ b/crates/components/src/network_image.rs @@ -1,6 +1,6 @@ use bytes::Bytes; use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, use_asset_cacher, @@ -124,7 +124,7 @@ pub fn NetworkImage(props: NetworkImageProps) -> Element { focus_id, image_data, role: "image", - alt + alt, }) } else if *status.read() == ImageState::Loading { if let Some(loading_element) = &props.loading { diff --git a/crates/components/src/popup.rs b/crates/components/src/popup.rs index 257e0478d..4ec39df6a 100644 --- a/crates/components/src/popup.rs +++ b/crates/components/src/popup.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::KeyboardEvent, }; use freya_hooks::{ diff --git a/crates/components/src/progress_bar.rs b/crates/components/src/progress_bar.rs index 0fac1e84e..cffacc583 100644 --- a/crates/components/src/progress_bar.rs +++ b/crates/components/src/progress_bar.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, ProgressBarTheme, diff --git a/crates/components/src/radio.rs b/crates/components/src/radio.rs index a661ac20e..115be2afa 100644 --- a/crates/components/src/radio.rs +++ b/crates/components/src/radio.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, RadioTheme, @@ -108,7 +108,7 @@ mod test { leading: rsx!( Radio { selected: *selected.read() == Choice::First, - }, + } ), label { "First choice" } } @@ -117,7 +117,7 @@ mod test { leading: rsx!( Radio { selected: *selected.read() == Choice::Second, - }, + } ), label { "Second choice" } } @@ -126,7 +126,7 @@ mod test { leading: rsx!( Radio { selected: *selected.read() == Choice::Third, - }, + } ), label { "Third choice" } } diff --git a/crates/components/src/scroll_views/scroll_bar.rs b/crates/components/src/scroll_views/scroll_bar.rs index 870a6b5c5..375378dca 100644 --- a/crates/components/src/scroll_views/scroll_bar.rs +++ b/crates/components/src/scroll_views/scroll_bar.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, ScrollBarTheme, diff --git a/crates/components/src/scroll_views/scroll_thumb.rs b/crates/components/src/scroll_views/scroll_thumb.rs index a76a5378e..acf63f637 100644 --- a/crates/components/src/scroll_views/scroll_thumb.rs +++ b/crates/components/src/scroll_views/scroll_thumb.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::MouseEvent, }; use freya_hooks::{ @@ -45,9 +45,10 @@ pub fn ScrollThumb( ScrollThumbState::Hovering => theme.hover_thumb_background, }; + rsx!( rect { - onmouseenter: move |_| { state.set(ScrollThumbState::Hovering) }, + onmouseenter: move |_: MouseEvent| { state.set(ScrollThumbState::Hovering) }, onmouseleave: move |_| { state.set(ScrollThumbState::Idle) }, onmousedown: move |e| { e.stop_propagation(); diff --git a/crates/components/src/scroll_views/scroll_view.rs b/crates/components/src/scroll_views/scroll_view.rs index 6e7243a0f..d1c05f51d 100644 --- a/crates/components/src/scroll_views/scroll_view.rs +++ b/crates/components/src/scroll_views/scroll_view.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::{ keyboard::Key, KeyboardEvent, diff --git a/crates/components/src/scroll_views/virtual_scroll_view.rs b/crates/components/src/scroll_views/virtual_scroll_view.rs index c3610def0..8aa6db90a 100644 --- a/crates/components/src/scroll_views/virtual_scroll_view.rs +++ b/crates/components/src/scroll_views/virtual_scroll_view.rs @@ -4,7 +4,7 @@ use std::ops::Range; use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::{ keyboard::Key, KeyboardEvent, diff --git a/crates/components/src/sidebar.rs b/crates/components/src/sidebar.rs index 4c606b9e9..eb09b7478 100644 --- a/crates/components/src/sidebar.rs +++ b/crates/components/src/sidebar.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ theme_with, use_activable_route, diff --git a/crates/components/src/slider.rs b/crates/components/src/slider.rs index 4c438136f..f9305891f 100644 --- a/crates/components/src/slider.rs +++ b/crates/components/src/slider.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::{ MouseEvent, WheelEvent, diff --git a/crates/components/src/snackbar.rs b/crates/components/src/snackbar.rs index dd3d0ec2f..bec20a32e 100644 --- a/crates/components/src/snackbar.rs +++ b/crates/components/src/snackbar.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_animation, use_applied_theme, diff --git a/crates/components/src/svg.rs b/crates/components/src/svg.rs index 08d201a0e..0c23600c5 100644 --- a/crates/components/src/svg.rs +++ b/crates/components/src/svg.rs @@ -35,7 +35,7 @@ macro_rules! import_svg { rsx!(svg { width, height, - svg_content + svg_content, }) } }; diff --git a/crates/components/src/switch.rs b/crates/components/src/switch.rs index e4eeb21e0..2bea3d42a 100644 --- a/crates/components/src/switch.rs +++ b/crates/components/src/switch.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::{ KeyboardEvent, MouseEvent, diff --git a/crates/components/src/table.rs b/crates/components/src/table.rs index 945561cb3..a8c530093 100644 --- a/crates/components/src/table.rs +++ b/crates/components/src/table.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::MouseEvent, }; use freya_hooks::{ diff --git a/crates/components/src/tabs.rs b/crates/components/src/tabs.rs index 5f3a8fae9..b796f861f 100644 --- a/crates/components/src/tabs.rs +++ b/crates/components/src/tabs.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_activable_route, use_applied_theme, @@ -141,7 +141,7 @@ pub fn Tab(children: Element, theme: Option) -> Element { padding: "{padding}", main_align: "center", cross_align: "center", - {children}, + {children} } rect { height: "2", @@ -253,7 +253,7 @@ pub fn BottomTab(children: Element, theme: Option) -> Elemen cross_align: "center", corner_radius: "99", margin: "2 4", - {children}, + {children} } ) } diff --git a/crates/components/src/tile.rs b/crates/components/src/tile.rs index 7a1a5ecb0..c78e6e42e 100644 --- a/crates/components/src/tile.rs +++ b/crates/components/src/tile.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, use_focus, @@ -75,11 +75,6 @@ pub fn Tile( onmouseleave, focus_id, direction: "horizontal", - onclick: move |_| { - if let Some(onclick) = &onclick { - onclick.call(()); - } - }, padding: "{padding}", cross_align: "center", if let Some(leading) = leading { diff --git a/crates/components/src/tooltip.rs b/crates/components/src/tooltip.rs index 6ec61d01a..344ec054b 100644 --- a/crates/components/src/tooltip.rs +++ b/crates/components/src/tooltip.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_applied_theme, TooltipTheme, diff --git a/crates/components/src/window_drag_area.rs b/crates/components/src/window_drag_area.rs index f09efe139..dd08878dc 100644 --- a/crates/components/src/window_drag_area.rs +++ b/crates/components/src/window_drag_area.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::MouseEvent, }; use freya_hooks::use_platform; diff --git a/crates/core/tests/compatible_elements.rs b/crates/core/tests/compatible_elements.rs index 55aa856a7..c8631b698 100644 --- a/crates/core/tests/compatible_elements.rs +++ b/crates/core/tests/compatible_elements.rs @@ -9,10 +9,10 @@ pub async fn compatible_elements() { height: "100%", width: "100%", padding: "10", - "test", + "test" label { rect { "test" } - }, + } paragraph { rect { } label { } diff --git a/crates/devtools/src/lib.rs b/crates/devtools/src/lib.rs index a75b07723..c63ad3815 100644 --- a/crates/devtools/src/lib.rs +++ b/crates/devtools/src/lib.rs @@ -9,7 +9,7 @@ use dioxus_router::prelude::{ Router, }; use freya_components::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_init_theme, use_platform, @@ -83,7 +83,7 @@ fn AppWithDevtools(props: AppWithDevtoolsProps) -> Element { overflow: "clip", height: "100%", width: "calc(100% - 350)", - Root { }, + Root { } } rect { background: "rgb(40, 40, 40)", @@ -285,7 +285,7 @@ fn LayoutForDOMInspector() -> Element { #[allow(non_snake_case)] #[component] fn DOMInspector() -> Element { - None + Ok(VNode::placeholder()) } pub trait NodeIdSerializer { diff --git a/crates/devtools/src/node.rs b/crates/devtools/src/node.rs index 4084c78f5..09d75ddd4 100644 --- a/crates/devtools/src/node.rs +++ b/crates/devtools/src/node.rs @@ -4,7 +4,7 @@ use freya_components::{ ButtonStatus, }; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::MouseEvent, }; use freya_native_core::prelude::NodeId; @@ -21,7 +21,9 @@ pub fn NodeElement( onarrow: EventHandler<()>, ) -> Element { let mut status = use_signal(ButtonStatus::default); - let node = use_node_info(node_id)?; + let Some(node) = use_node_info(node_id) else { + return Ok(VNode::placeholder()) + }; let onmousedown = move |_| onselected.call(()); diff --git a/crates/devtools/src/property.rs b/crates/devtools/src/property.rs index 38b9f5847..3ce1e25ce 100644 --- a/crates/devtools/src/property.rs +++ b/crates/devtools/src/property.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_engine::prelude::*; use freya_node_state::{ Border, @@ -60,7 +60,7 @@ pub fn GradientProperty(name: String, fill: Fill) -> Element { text { font_size: "15", color: "rgb(252,181,172)", - "{fill}", + "{fill}" } } } @@ -109,7 +109,7 @@ pub fn ColorProperty(name: String, fill: Fill) -> Element { label { font_size: "15", color: "rgb(252,181,172)", - "{fill}", + "{fill}" } } ) diff --git a/crates/devtools/src/tabs/layout.rs b/crates/devtools/src/tabs/layout.rs index 6e3cf108f..4a5c448fb 100644 --- a/crates/devtools/src/tabs/layout.rs +++ b/crates/devtools/src/tabs/layout.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use freya_components::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ theme_with, ScrollViewThemeWith, @@ -16,7 +16,9 @@ use crate::{ #[component] pub fn NodeInspectorLayout(node_id: String) -> Element { let node_id = NodeId::deserialize(&node_id); - let node = use_node_info(node_id)?; + let Some(node) = use_node_info(node_id) else { + return Ok(VNode::placeholder()) + }; let inner_area = format!( "{}x{}", diff --git a/crates/devtools/src/tabs/style.rs b/crates/devtools/src/tabs/style.rs index c90f288f4..5a19fd381 100644 --- a/crates/devtools/src/tabs/style.rs +++ b/crates/devtools/src/tabs/style.rs @@ -24,7 +24,9 @@ use crate::{ #[component] pub fn NodeInspectorStyle(node_id: String) -> Element { let node_id = NodeId::deserialize(&node_id); - let node = use_node_info(node_id)?; + let Some(node) = use_node_info(node_id) else { + return Ok(VNode::placeholder()) + }; rsx!( ScrollView { diff --git a/crates/elements/src/definitions.rs b/crates/elements/src/definitions.rs index fe1b21176..5e2c88bc4 100644 --- a/crates/elements/src/definitions.rs +++ b/crates/elements/src/definitions.rs @@ -116,6 +116,19 @@ macro_rules! builder_constructors { }; ); )* + + /// This module contains helpers for rust analyzer autocompletion + #[doc(hidden)] + pub mod completions { + /// This helper tells rust analyzer that it should autocomplete the element name with braces. + #[allow(non_camel_case_types)] + pub enum CompleteWithBraces { + $( + $(#[$attr])* + $name {} + ),* + } + } }; } @@ -558,18 +571,44 @@ pub mod events { $( $( #[$attr] )* #[inline] - pub fn $name, T>(mut _f: impl FnMut(::dioxus_core::Event<$data>) -> E + 'static) -> ::dioxus_core::Attribute { + pub fn $name<__Marker>(mut _f: impl ::dioxus_core::prelude::SuperInto<::dioxus_core::prelude::EventHandler<::dioxus_core::Event<$data>>, __Marker>) -> ::dioxus_core::Attribute { + let event_handler = _f.super_into(); ::dioxus_core::Attribute::new( - stringify!($name), - ::dioxus_core::AttributeValue::listener(move |e: ::dioxus_core::Event| { - _f(e.map(|e|e.into())).spawn(); + impl_event!(@name $name $($js_name)?), + ::dioxus_core::AttributeValue::listener(move |e: ::dioxus_core::Event| { + event_handler.call(e.map(|e| e.into())); }), None, false, ).into() } + + #[doc(hidden)] + $( #[$attr] )* + pub mod $name { + use super::*; + + // When expanding the macro, we use this version of the function if we see an inline closure to give better type inference + $( #[$attr] )* + pub fn call_with_explicit_closure< + __Marker, + Return: ::dioxus_core::SpawnIfAsync<__Marker> + 'static, + >( + event_handler: impl FnMut(::dioxus_core::Event<$data>) -> Return + 'static, + ) -> ::dioxus_core::Attribute { + #[allow(deprecated)] + super::$name(event_handler) + } + } )* }; + + (@name $name:ident $js_name:literal) => { + $js_name + }; + (@name $name:ident) => { + stringify!($name) + }; } impl_event! [ diff --git a/crates/elements/src/events.rs b/crates/elements/src/events.rs index dd422648f..a37462a8c 100644 --- a/crates/elements/src/events.rs +++ b/crates/elements/src/events.rs @@ -18,3 +18,5 @@ pub type MouseEvent = Event; pub type WheelEvent = Event; pub type TouchEvent = Event; pub type PointerEvent = Event; + +pub use crate::definitions::events::*; \ No newline at end of file diff --git a/crates/elements/src/lib.rs b/crates/elements/src/lib.rs index b1a3a6cd3..4784dc612 100644 --- a/crates/elements/src/lib.rs +++ b/crates/elements/src/lib.rs @@ -6,7 +6,11 @@ pub mod _docs; mod definitions; +pub mod events; + pub mod elements { pub use crate::definitions::*; + pub use crate::events::*; } -pub mod events; + +pub use crate::definitions::*; diff --git a/crates/freya/src/launch.rs b/crates/freya/src/launch.rs index 89bc14d1b..e0d90d041 100644 --- a/crates/freya/src/launch.rs +++ b/crates/freya/src/launch.rs @@ -1,4 +1,5 @@ use dioxus_core::Element; +use dioxus_signals::GlobalSignal; use freya_renderer::{ DesktopRenderer, LaunchConfig, diff --git a/crates/freya/src/lib.rs b/crates/freya/src/lib.rs index cf2aab0e5..1b4bd5c2a 100644 --- a/crates/freya/src/lib.rs +++ b/crates/freya/src/lib.rs @@ -103,14 +103,14 @@ pub mod prelude { pub use dioxus_hooks::*; pub use dioxus_hot_reload::{ self, - hot_reload_init, - Config, + // hot_reload_init, + // Config, }; pub use dioxus_signals::*; pub use freya_components::*; pub use freya_core::prelude::PreferredTheme; pub use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::*, }; pub use freya_hooks::*; diff --git a/crates/hooks/src/use_init_native_platform.rs b/crates/hooks/src/use_init_native_platform.rs index bcaac75ba..99851144a 100644 --- a/crates/hooks/src/use_init_native_platform.rs +++ b/crates/hooks/src/use_init_native_platform.rs @@ -121,7 +121,7 @@ mod test { rect { width: "100%", height: "100%", - OtherChild {}, + OtherChild {} OtherChild {} } ) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index 8e4489b90..872b1e034 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -230,7 +230,7 @@ pub async fn single_line_multiple_editors() { } } ) - })}, + })} label { color: "black", height: "50%", @@ -433,7 +433,7 @@ pub async fn highlights_single_line_multiple_editors() { } } ) - })}, + })} label { color: "black", height: "50%", @@ -965,7 +965,7 @@ pub async fn highlights_shift_click_single_line_multiple_editors() { } } ) - })}, + })} label { color: "black", height: "50%", diff --git a/crates/hooks/tests/use_focus.rs b/crates/hooks/tests/use_focus.rs index 9ad95714d..b502255c8 100644 --- a/crates/hooks/tests/use_focus.rs +++ b/crates/hooks/tests/use_focus.rs @@ -29,7 +29,7 @@ pub async fn track_focus() { rect { width: "100%", height: "100%", - OtherChild {}, + OtherChild {} OtherChild {} } ) @@ -121,7 +121,7 @@ pub async fn block_focus() { rect { width: "100%", height: "100%", - Child {}, + Child {} BlockingChild {} } ) diff --git a/crates/native-core/src/dioxus.rs b/crates/native-core/src/dioxus.rs index ade3949b7..aa2e1f49c 100644 --- a/crates/native-core/src/dioxus.rs +++ b/crates/native-core/src/dioxus.rs @@ -294,9 +294,9 @@ fn create_template_node( } TemplateNode::Text { text } => rdom.create_node(NodeType::Text(text.to_string())).id(), TemplateNode::Dynamic { .. } => rdom.create_node(NodeType::Placeholder).id(), - TemplateNode::DynamicText { .. } => { - rdom.create_node(NodeType::Text(String::default())).id() - } + // TemplateNode::DynamicText { .. } => { + // rdom.create_node(NodeType::Text(String::default())).id() + // } } } diff --git a/crates/renderer/src/app.rs b/crates/renderer/src/app.rs index 007034eb6..8744237eb 100644 --- a/crates/renderer/src/app.rs +++ b/crates/renderer/src/app.rs @@ -258,9 +258,9 @@ impl Application { } /// Replace a VirtualDOM Template - pub fn vdom_replace_template(&mut self, template: Template) { - self.vdom.replace_template(template); - } + // pub fn vdom_replace_template(&mut self, template: Template) { + // self.vdom.replace_template(template); + // } /// Render the App into the Window Canvas pub fn render(&mut self, hovered_node: &HoveredNode, canvas: &Canvas, window: &Window) { diff --git a/crates/renderer/src/renderer.rs b/crates/renderer/src/renderer.rs index 97462bdba..29c75caca 100644 --- a/crates/renderer/src/renderer.rs +++ b/crates/renderer/src/renderer.rs @@ -219,9 +219,9 @@ impl<'a, State: Clone> ApplicationHandler for DesktopRenderer<'a, } EventMessage::ExitApp => event_loop.exit(), ev => { - if let EventMessage::UpdateTemplate(template) = ev { - app.vdom_replace_template(template); - } + // if let EventMessage::UpdateTemplate(template) = ev { + // app.vdom_replace_template(template); + // } if matches!(ev, EventMessage::PollVDOM) || matches!(ev, EventMessage::UpdateTemplate(_)) diff --git a/crates/testing/Cargo.toml b/crates/testing/Cargo.toml index e5628e21e..ea3bf2cec 100644 --- a/crates/testing/Cargo.toml +++ b/crates/testing/Cargo.toml @@ -30,6 +30,7 @@ torin = { workspace = true } freya-native-core = { workspace = true } dioxus-core-macro = { workspace = true } dioxus-core = { workspace = true } +dioxus-signals = { workspace = true } dioxus = { workspace = true } tokio = { workspace = true } diff --git a/crates/testing/src/launch.rs b/crates/testing/src/launch.rs index 62d9bccd1..20132457d 100644 --- a/crates/testing/src/launch.rs +++ b/crates/testing/src/launch.rs @@ -13,6 +13,7 @@ use tokio::sync::{ mpsc::unbounded_channel, watch, }; +use dioxus_signals::GlobalSignal; use winit::window::CursorIcon; use crate::{ diff --git a/examples/animated_sidebar.rs b/examples/animated_sidebar.rs index e86e24f1b..11bf7b6fe 100644 --- a/examples/animated_sidebar.rs +++ b/examples/animated_sidebar.rs @@ -132,9 +132,9 @@ fn AppSidebar() -> Element { label { "Go to Hey ! 👋" } - }, + } } - }, + } Link { to: Route::Wow, ActivableRoute { @@ -143,9 +143,9 @@ fn AppSidebar() -> Element { label { "Go to Wow! 👈" } - }, + } } - }, + } Link { to: Route::Crab, ActivableRoute { @@ -154,9 +154,9 @@ fn AppSidebar() -> Element { label { "Go to Crab! 🦀" } - }, + } } - }, + } ), Body { AnimatedOutlet { } diff --git a/examples/animated_tabs.rs b/examples/animated_tabs.rs index 01a1b114a..43617affe 100644 --- a/examples/animated_tabs.rs +++ b/examples/animated_tabs.rs @@ -145,15 +145,15 @@ fn AppSidebar() -> Element { route: Route::Home, exact: true, "Go to Hey ! 👋" - }, + } BottomTab { route: Route::Wow, "Go to Wow! 👈" - }, + } BottomTab { route: Route::Crab, "Go to Crab! 🦀" - }, + } } } diff --git a/examples/camera.rs b/examples/camera.rs index 60d290552..e81584e99 100644 --- a/examples/camera.rs +++ b/examples/camera.rs @@ -33,7 +33,7 @@ fn app() -> Element { image { width: "100%", height: "100%", - image_reference + image_reference, } } } diff --git a/examples/checkbox.rs b/examples/checkbox.rs index c3215978b..1ea604f1a 100644 --- a/examples/checkbox.rs +++ b/examples/checkbox.rs @@ -33,7 +33,7 @@ fn app() -> Element { leading: rsx!( Checkbox { selected: selected.read().contains(&Choice::First), - }, + } ), label { "First choice" } } @@ -48,7 +48,7 @@ fn app() -> Element { leading: rsx!( Checkbox { selected: selected.read().contains(&Choice::Second), - }, + } ), label { "Second choice" } } @@ -63,7 +63,7 @@ fn app() -> Element { leading: rsx!( Checkbox { selected: selected.read().contains(&Choice::Third), - }, + } ), label { "Third choice" } } diff --git a/examples/file_explorer.rs b/examples/file_explorer.rs index f16f5c688..cb45b43fe 100644 --- a/examples/file_explorer.rs +++ b/examples/file_explorer.rs @@ -64,7 +64,7 @@ fn app() -> Element { // Flat the items let flat_items = { let tree = tree.read(); - let tree = tree.as_ref()?; + let tree = tree.as_ref().unwrap_or_default(); tree.iter() .flat_map(|tree| tree.flat(0, tree.id())) .collect::>() diff --git a/examples/focus.rs b/examples/focus.rs index 131c483c3..3cef7a985 100644 --- a/examples/focus.rs +++ b/examples/focus.rs @@ -36,10 +36,10 @@ fn app() -> Element { rect { width: "100%", height: "100%", - Child {}, - Child {}, - Child {}, - Child {}, + Child {} + Child {} + Child {} + Child {} Child {} } ) diff --git a/examples/form.rs b/examples/form.rs index 2b9e16398..24cdf5883 100644 --- a/examples/form.rs +++ b/examples/form.rs @@ -32,10 +32,10 @@ fn app() -> Element { rsx!( Input { ..form.input(FormEntry::Name) - }, + } Input { ..form.input(FormEntry::Description) - }, + } Button { children: rsx!( label { diff --git a/examples/hotreload.rs b/examples/hotreload.rs index d2320aa33..349d0ef00 100644 --- a/examples/hotreload.rs +++ b/examples/hotreload.rs @@ -9,7 +9,7 @@ use freya::{ }; fn main() { - dioxus_hot_reload::hot_reload_init!(Config::::default()); + //dioxus_hot_reload::hot_reload_init!(Config::::default()); launch(app); } diff --git a/examples/input.rs b/examples/input.rs index d1462554a..ccf8a9ded 100644 --- a/examples/input.rs +++ b/examples/input.rs @@ -27,7 +27,7 @@ fn app() -> Element { onchange: move |txt| { values.write().0 = txt; } - }, + } label { color: "black", "Your age:" @@ -37,7 +37,7 @@ fn app() -> Element { onchange: move |txt| { values.write().1 = txt; } - }, + } label { color: "black", "You are {values.read().0} and you are {values.read().1} years old." diff --git a/examples/material_design_app.rs b/examples/material_design_app.rs index d3886f889..422e46850 100644 --- a/examples/material_design_app.rs +++ b/examples/material_design_app.rs @@ -102,7 +102,7 @@ fn Scaffold(props: ScaffoldProps) -> Element { } } - {props.navbar}, + {props.navbar} ScrollView { theme: theme_with!(ScrollViewTheme { height: height.into(), diff --git a/examples/menu.rs b/examples/menu.rs index 3f1c14a26..3c575bfc0 100644 --- a/examples/menu.rs +++ b/examples/menu.rs @@ -21,7 +21,7 @@ fn app() -> Element { Button { onpress: move |_| show_menu.toggle(), label { "Open Menu" } - }, + } if *show_menu.read() { Menu { onclose: move |_| show_menu.set(false), diff --git a/examples/mouse.rs b/examples/mouse.rs index e091b8dcb..e826ca4e0 100644 --- a/examples/mouse.rs +++ b/examples/mouse.rs @@ -55,8 +55,8 @@ fn Area() -> Element { onmouseover: cursor_moved, onclick: cursor_clicked, label { - "Mouse is at [x: {cursor_pos_over.read().0}, y: {cursor_pos_over.read().1}] ", - }, + "Mouse is at [x: {cursor_pos_over.read().0}, y: {cursor_pos_over.read().1}] " + } label { "Mouse clicked at [x: {cursor_pos_click.read().0}, y: {cursor_pos_click.read().1}]" } diff --git a/examples/password.rs b/examples/password.rs index 71c27f833..b27028049 100644 --- a/examples/password.rs +++ b/examples/password.rs @@ -35,7 +35,7 @@ fn app() -> Element { onchange: move |e| { password.set(e) } - }, + } Button { onpress: move |_| is_hidden.toggle(), label { diff --git a/examples/radio.rs b/examples/radio.rs index 4e25e5125..b6817defd 100644 --- a/examples/radio.rs +++ b/examples/radio.rs @@ -25,7 +25,7 @@ fn app() -> Element { leading: rsx!( Radio { selected: *selected.read() == Choice::First, - }, + } ), label { "First choice" } } @@ -34,7 +34,7 @@ fn app() -> Element { leading: rsx!( Radio { selected: *selected.read() == Choice::Second, - }, + } ), label { "Second choice" } } @@ -43,7 +43,7 @@ fn app() -> Element { leading: rsx!( Radio { selected: *selected.read() == Choice::Third, - }, + } ), label { "Third choice" } } diff --git a/examples/router.rs b/examples/router.rs index bef87ce93..95c6782b2 100644 --- a/examples/router.rs +++ b/examples/router.rs @@ -46,9 +46,9 @@ fn AppSidebar() -> Element { label { "Go to Hey ! 👋" } - }, + } } - }, + } Link { to: Route::Wow, ActivableRoute { @@ -57,15 +57,15 @@ fn AppSidebar() -> Element { label { "Go to Wow! 👈" } - }, + } } - }, + } SidebarItem { onclick: |_| println!("Hello!"), label { "Print Hello! 👀" } - }, + } ), Body { rect { diff --git a/examples/scroll.rs b/examples/scroll.rs index 6676a3188..2ada4e35f 100644 --- a/examples/scroll.rs +++ b/examples/scroll.rs @@ -27,8 +27,8 @@ fn app() -> Element { theme: theme_with!(ScrollViewTheme { height: "50%".into(), }), - Card {}, - Card {}, + Card {} + Card {} Card {} } } diff --git a/examples/shader_editor.rs b/examples/shader_editor.rs index 9086311dd..c725c0809 100644 --- a/examples/shader_editor.rs +++ b/examples/shader_editor.rs @@ -58,7 +58,7 @@ fn app() -> Element { direction: "horizontal", ShaderEditor { editable - }, + } ShaderView { editable } diff --git a/examples/tab.rs b/examples/tab.rs index 32ad4445e..b67125cc2 100644 --- a/examples/tab.rs +++ b/examples/tab.rs @@ -49,7 +49,7 @@ fn AppSidebar() -> Element { } } } - }, + } Link { to: Route::Wow, ActivableRoute { @@ -60,7 +60,7 @@ fn AppSidebar() -> Element { } } } - }, + } Link { to: Route::Settings, ActivableRoute { @@ -69,9 +69,9 @@ fn AppSidebar() -> Element { label { "Go to Settings! 🧰" } - }, + } } - }, + } } Body { rect { diff --git a/examples/ui.rs b/examples/ui.rs index 120b6c92e..558939a2c 100644 --- a/examples/ui.rs +++ b/examples/ui.rs @@ -110,7 +110,7 @@ fn App(props: AppProps) -> Element { rect { width: "100%", height: "100%", - {props.navbar}, + {props.navbar} {props.body} } } diff --git a/examples/window_title.rs b/examples/window_title.rs index 079d32f6e..c1da9ad43 100644 --- a/examples/window_title.rs +++ b/examples/window_title.rs @@ -24,7 +24,7 @@ fn app() -> Element { onchange: move |txt| { text.set(txt); } - }, + } Button { onpress, label { From 78d755079670879dc6576fcd097bfcaa07999f2a Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sat, 10 Aug 2024 09:54:16 +0200 Subject: [PATCH 02/21] chore: Clean up the rest of rsx!() --- crates/components/src/checkbox.rs | 6 +-- crates/components/src/drag_drop.rs | 2 +- crates/components/src/input.rs | 2 +- crates/components/src/menu.rs | 2 +- crates/components/src/native_router.rs | 2 +- .../src/scroll_views/scroll_thumb.rs | 1 - .../src/scroll_views/scroll_view.rs | 8 +-- .../src/scroll_views/use_scroll_controller.rs | 4 +- crates/devtools/src/node.rs | 2 +- crates/devtools/src/tabs/layout.rs | 2 +- crates/devtools/src/tabs/style.rs | 2 +- crates/elements/src/events.rs | 2 +- crates/elements/src/lib.rs | 6 ++- crates/hooks/src/use_animation.rs | 14 ++--- crates/renderer/src/app.rs | 5 +- crates/testing/src/launch.rs | 2 +- examples/animated_tabs.rs | 2 +- examples/file_explorer.rs | 4 +- examples/hotreload.rs | 53 ------------------- examples/ui.rs | 4 +- 20 files changed, 36 insertions(+), 89 deletions(-) delete mode 100644 examples/hotreload.rs diff --git a/crates/components/src/checkbox.rs b/crates/components/src/checkbox.rs index dafec70e6..a9aeef83d 100644 --- a/crates/components/src/checkbox.rs +++ b/crates/components/src/checkbox.rs @@ -131,7 +131,7 @@ mod test { Checkbox { selected: selected.read().contains(&Choice::First), } - ) + ), label { "First choice" } } Tile { @@ -146,7 +146,7 @@ mod test { Checkbox { selected: selected.read().contains(&Choice::Second), } - ) + ), label { "Second choice" } } Tile { @@ -161,7 +161,7 @@ mod test { Checkbox { selected: selected.read().contains(&Choice::Third), } - ) + ), label { "Third choice" } } ) diff --git a/crates/components/src/drag_drop.rs b/crates/components/src/drag_drop.rs index afd5de946..711921884 100644 --- a/crates/components/src/drag_drop.rs +++ b/crates/components/src/drag_drop.rs @@ -159,7 +159,7 @@ mod test { "Move" } } - }, + } DropZone { ondrop: move |data: bool| { state.set(data); diff --git a/crates/components/src/input.rs b/crates/components/src/input.rs index f06a819ba..318761a29 100644 --- a/crates/components/src/input.rs +++ b/crates/components/src/input.rs @@ -251,7 +251,7 @@ mod test { onchange: move |new_value| { value.set(new_value); } - },) + }) } let mut utils = launch_test(input_app); diff --git a/crates/components/src/menu.rs b/crates/components/src/menu.rs index da16e2d35..e5dafc1f4 100644 --- a/crates/components/src/menu.rs +++ b/crates/components/src/menu.rs @@ -324,7 +324,7 @@ mod test { Button { onpress: move |_| show_menu.toggle(), label { "Open Menu" } - }, + } if *show_menu.read() { Menu { onclose: move |_| show_menu.set(false), diff --git a/crates/components/src/native_router.rs b/crates/components/src/native_router.rs index 8cb56d265..3294f3a2d 100644 --- a/crates/components/src/native_router.rs +++ b/crates/components/src/native_router.rs @@ -104,7 +104,7 @@ mod test { label { "Got to B" } - }, + } Outlet:: { } } ) diff --git a/crates/components/src/scroll_views/scroll_thumb.rs b/crates/components/src/scroll_views/scroll_thumb.rs index acf63f637..f78624974 100644 --- a/crates/components/src/scroll_views/scroll_thumb.rs +++ b/crates/components/src/scroll_views/scroll_thumb.rs @@ -45,7 +45,6 @@ pub fn ScrollThumb( ScrollThumbState::Hovering => theme.hover_thumb_background, }; - rsx!( rect { onmouseenter: move |_: MouseEvent| { state.set(ScrollThumbState::Hovering) }, diff --git a/crates/components/src/scroll_views/scroll_view.rs b/crates/components/src/scroll_views/scroll_view.rs index d1c05f51d..2a382f0fe 100644 --- a/crates/components/src/scroll_views/scroll_view.rs +++ b/crates/components/src/scroll_views/scroll_view.rs @@ -415,11 +415,11 @@ mod test { rect { height: "200", width: "200", - }, + } rect { height: "200", width: "200", - }, + } rect { height: "200", width: "200", @@ -468,11 +468,11 @@ mod test { rect { height: "200", width: "200", - }, + } rect { height: "200", width: "200", - }, + } rect { height: "200", width: "200", diff --git a/crates/components/src/scroll_views/use_scroll_controller.rs b/crates/components/src/scroll_views/use_scroll_controller.rs index ea3ccac66..dd711add5 100644 --- a/crates/components/src/scroll_views/use_scroll_controller.rs +++ b/crates/components/src/scroll_views/use_scroll_controller.rs @@ -210,11 +210,11 @@ mod test { rect { height: "200", width: "200", - }, + } rect { height: "200", width: "200", - }, + } rect { height: "200", width: "200", diff --git a/crates/devtools/src/node.rs b/crates/devtools/src/node.rs index 09d75ddd4..348e92a24 100644 --- a/crates/devtools/src/node.rs +++ b/crates/devtools/src/node.rs @@ -22,7 +22,7 @@ pub fn NodeElement( ) -> Element { let mut status = use_signal(ButtonStatus::default); let Some(node) = use_node_info(node_id) else { - return Ok(VNode::placeholder()) + return Ok(VNode::placeholder()); }; let onmousedown = move |_| onselected.call(()); diff --git a/crates/devtools/src/tabs/layout.rs b/crates/devtools/src/tabs/layout.rs index 4a5c448fb..2aef88614 100644 --- a/crates/devtools/src/tabs/layout.rs +++ b/crates/devtools/src/tabs/layout.rs @@ -17,7 +17,7 @@ use crate::{ pub fn NodeInspectorLayout(node_id: String) -> Element { let node_id = NodeId::deserialize(&node_id); let Some(node) = use_node_info(node_id) else { - return Ok(VNode::placeholder()) + return Ok(VNode::placeholder()); }; let inner_area = format!( diff --git a/crates/devtools/src/tabs/style.rs b/crates/devtools/src/tabs/style.rs index 5a19fd381..0f6afc28e 100644 --- a/crates/devtools/src/tabs/style.rs +++ b/crates/devtools/src/tabs/style.rs @@ -25,7 +25,7 @@ use crate::{ pub fn NodeInspectorStyle(node_id: String) -> Element { let node_id = NodeId::deserialize(&node_id); let Some(node) = use_node_info(node_id) else { - return Ok(VNode::placeholder()) + return Ok(VNode::placeholder()); }; rsx!( diff --git a/crates/elements/src/events.rs b/crates/elements/src/events.rs index a37462a8c..11bf01537 100644 --- a/crates/elements/src/events.rs +++ b/crates/elements/src/events.rs @@ -19,4 +19,4 @@ pub type WheelEvent = Event; pub type TouchEvent = Event; pub type PointerEvent = Event; -pub use crate::definitions::events::*; \ No newline at end of file +pub use crate::definitions::events::*; diff --git a/crates/elements/src/lib.rs b/crates/elements/src/lib.rs index 4784dc612..e9c66fcfa 100644 --- a/crates/elements/src/lib.rs +++ b/crates/elements/src/lib.rs @@ -9,8 +9,10 @@ mod definitions; pub mod events; pub mod elements { - pub use crate::definitions::*; - pub use crate::events::*; + pub use crate::{ + definitions::*, + events::*, + }; } pub use crate::definitions::*; diff --git a/crates/hooks/src/use_animation.rs b/crates/hooks/src/use_animation.rs index f0a132a6d..d8a2222db 100644 --- a/crates/hooks/src/use_animation.rs +++ b/crates/hooks/src/use_animation.rs @@ -375,13 +375,13 @@ pub trait AnimatedValue { pub type ReadAnimatedValue = ReadOnlySignal>; #[derive(Default, PartialEq, Clone)] -pub struct Context { +pub struct AnimationContext { animated_values: Vec>>, on_finish: OnFinish, auto_start: bool, } -impl Context { +impl AnimationContext { pub fn with(&mut self, animated_value: impl AnimatedValue + 'static) -> ReadAnimatedValue { let val: Box = Box::new(animated_value); let signal = Signal::new(val); @@ -428,7 +428,7 @@ pub enum OnFinish { /// Animate your elements. Use [`use_animation`] to use this. #[derive(PartialEq, Clone)] pub struct UseAnimator { - pub(crate) value_and_ctx: Memo<(Animated, Context)>, + pub(crate) value_and_ctx: Memo<(Animated, AnimationContext)>, pub(crate) platform: UsePlatform, pub(crate) is_running: Signal, pub(crate) has_run_yet: Signal, @@ -643,7 +643,7 @@ impl UseAnimator { /// } /// ``` pub fn use_animation( - run: impl Fn(&mut Context) -> Animated + Clone + 'static, + run: impl Fn(&mut AnimationContext) -> Animated + Clone + 'static, ) -> UseAnimator { let platform = use_platform(); let is_running = use_signal(|| false); @@ -651,7 +651,7 @@ pub fn use_animation( let task = use_signal(|| None); let value_and_ctx = use_memo(move || { - let mut ctx = Context::default(); + let mut ctx = AnimationContext::default(); (run(&mut ctx), ctx) }); @@ -674,7 +674,7 @@ pub fn use_animation( pub fn use_animation_with_dependencies( deps: D, - run: impl Fn(&mut Context, D::Out) -> Animated + 'static, + run: impl Fn(&mut AnimationContext, D::Out) -> Animated + 'static, ) -> UseAnimator where D::Out: 'static + Clone, @@ -685,7 +685,7 @@ where let task = use_signal(|| None); let value_and_ctx = use_memo(use_reactive(deps, move |vals| { - let mut ctx = Context::default(); + let mut ctx = AnimationContext::default(); (run(&mut ctx, vals), ctx) })); diff --git a/crates/renderer/src/app.rs b/crates/renderer/src/app.rs index 8744237eb..10d3424a0 100644 --- a/crates/renderer/src/app.rs +++ b/crates/renderer/src/app.rs @@ -1,9 +1,6 @@ use std::sync::Arc; -use dioxus_core::{ - Template, - VirtualDom, -}; +use dioxus_core::VirtualDom; use freya_common::{ EventMessage, TextGroupMeasurement, diff --git a/crates/testing/src/launch.rs b/crates/testing/src/launch.rs index 20132457d..fa915de2b 100644 --- a/crates/testing/src/launch.rs +++ b/crates/testing/src/launch.rs @@ -4,6 +4,7 @@ use dioxus_core::{ VirtualDom, }; use dioxus_core_macro::rsx; +use dioxus_signals::GlobalSignal; use freya_common::EventMessage; use freya_components::NativeContainer; use freya_core::prelude::*; @@ -13,7 +14,6 @@ use tokio::sync::{ mpsc::unbounded_channel, watch, }; -use dioxus_signals::GlobalSignal; use winit::window::CursorIcon; use crate::{ diff --git a/examples/animated_tabs.rs b/examples/animated_tabs.rs index 43617affe..b6040d250 100644 --- a/examples/animated_tabs.rs +++ b/examples/animated_tabs.rs @@ -188,7 +188,7 @@ fn BottomTab( main_align: "center", {children} } - }, + } } } ) diff --git a/examples/file_explorer.rs b/examples/file_explorer.rs index cb45b43fe..9877d2b4b 100644 --- a/examples/file_explorer.rs +++ b/examples/file_explorer.rs @@ -64,7 +64,9 @@ fn app() -> Element { // Flat the items let flat_items = { let tree = tree.read(); - let tree = tree.as_ref().unwrap_or_default(); + let Some(tree) = tree.as_ref() else { + return Ok(VNode::placeholder()); + }; tree.iter() .flat_map(|tree| tree.flat(0, tree.id())) .collect::>() diff --git a/examples/hotreload.rs b/examples/hotreload.rs deleted file mode 100644 index 349d0ef00..000000000 --- a/examples/hotreload.rs +++ /dev/null @@ -1,53 +0,0 @@ -#![cfg_attr( - all(not(debug_assertions), target_os = "windows"), - windows_subsystem = "windows" -)] - -use freya::{ - hotreload::FreyaCtx, - prelude::*, -}; - -fn main() { - //dioxus_hot_reload::hot_reload_init!(Config::::default()); - - launch(app); -} - -fn app() -> Element { - let mut count = use_signal(|| 0); - rsx!( - rect { - overflow: "clip", - background: "rgb(15, 15, 15)", - padding: "50", - direction: "horizontal", - width: "auto", - height: "100%", - onclick: move |_| { - count += 1; - }, - rect { - overflow: "clip", - padding: "50", - height: "100%", - width: "50%", - background: "red", - label { - font_size: "50", - "{count}" - } - } - Comp {} - } - ) -} - -#[allow(non_snake_case)] -fn Comp() -> Element { - rsx!(rect { - width: "50%", - height: "100%", - background: "yellow" - }) -} diff --git a/examples/ui.rs b/examples/ui.rs index 558939a2c..c05e7c226 100644 --- a/examples/ui.rs +++ b/examples/ui.rs @@ -186,8 +186,8 @@ fn Area() -> Element { onmouseover: cursor_moved, onclick: cursor_clicked, label { - "Mouse is at [x: {cursor_pos_over.read().0}, y: {cursor_pos_over.read().1}] ", - }, + "Mouse is at [x: {cursor_pos_over.read().0}, y: {cursor_pos_over.read().1}] " + } label { "Mouse clicked at [x: {cursor_pos_click.read().0}, y: {cursor_pos_click.read().1}]" } From bbedfe2612c5c992968144d25576e9031a40565b Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sat, 10 Aug 2024 10:14:36 +0200 Subject: [PATCH 03/21] chore: Update SDK and clean up --- Cargo.toml | 11 +++++++---- crates/components/src/native_container.rs | 6 +++++- crates/components/src/popup.rs | 5 ++++- crates/hooks/src/use_asset_cacher.rs | 3 +-- crates/hooks/tests/use_platform_information.rs | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a7d4c8045..cc12648c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,9 @@ dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } +dioxus-lib = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } +generational-box = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" } +dioxus-sdk = { git = "https://github.com/DioxusLabs/sdk", branch = "feat/dioxus-0.6" } [workspace.dependencies] freya = { path = "crates/freya", version = "0.2" } @@ -40,15 +43,15 @@ torin = { path = "crates/torin", version = "0.2" } freya-native-core-macro = { path = "crates/native-core-macro", version = "0.2" } freya-native-core = { path = "crates/native-core", version = "0.2" } -dioxus = { version = "0.6.0-alpha.2" } +dioxus = { version = "0.6.0-alpha.2" , default-features = false, features = ["macro", "signals", "hooks"] } dioxus-rsx = { version = "0.6.0-alpha.2" } dioxus-core-macro = { version = "0.6.0-alpha.2" } dioxus-hooks = { version = "0.6.0-alpha.2" } dioxus-signals = { version = "0.6.0-alpha.2" } dioxus-core = { version = "0.6.0-alpha.2" } dioxus-hot-reload = { version = "0.6.0-alpha.2" } -dioxus-router = { version = "0.6.0-alpha.2" } -dioxus-sdk = { version = "0.5", features = ["clipboard"]} +dioxus-router = { version = "0.6.0-alpha.2", default-features = false } +dioxus-sdk = { git = "https://github.com/DioxusLabs/sdk", branch = "feat/dioxus-0.6", features = ["clipboard"]} skia-safe = { version = "0.75.0", features = ["gl", "textlayout", "svg"] } @@ -80,7 +83,7 @@ freya-core = { workspace = true } freya-testing = { workspace = true } reqwest = { version = "0.12.0", features = ["json"] } serde = "1.0.189" -dioxus-sdk = { version = "0.5", features = ["i18n"] } +dioxus-sdk = { git = "https://github.com/DioxusLabs/sdk", branch = "feat/dioxus-0.6", features = ["i18n"] } rand = "0.8.5" dioxus-router = { workspace = true } itertools = "0.13.0" diff --git a/crates/components/src/native_container.rs b/crates/components/src/native_container.rs index 349177c66..1b78287e5 100644 --- a/crates/components/src/native_container.rs +++ b/crates/components/src/native_container.rs @@ -2,7 +2,11 @@ use dioxus::prelude::*; use freya_common::EventMessage; use freya_elements::{ self as dioxus_elements, - events::KeyboardEvent, + events::{ + Key, + KeyboardEvent, + Modifiers, + }, }; use freya_hooks::{ use_init_native_platform, diff --git a/crates/components/src/popup.rs b/crates/components/src/popup.rs index 4ec39df6a..8a81d8acf 100644 --- a/crates/components/src/popup.rs +++ b/crates/components/src/popup.rs @@ -1,7 +1,10 @@ use dioxus::prelude::*; use freya_elements::{ self as dioxus_elements, - events::KeyboardEvent, + events::{ + Key, + KeyboardEvent, + }, }; use freya_hooks::{ theme_with, diff --git a/crates/hooks/src/use_asset_cacher.rs b/crates/hooks/src/use_asset_cacher.rs index fef04028d..3d2213cf4 100644 --- a/crates/hooks/src/use_asset_cacher.rs +++ b/crates/hooks/src/use_asset_cacher.rs @@ -90,8 +90,7 @@ impl AssetCacher { } // Insert the asset into the cache - let value = ScopeId::ROOT.in_runtime(|| asset_bytes); - let asset_bytes = Signal::new_in_scope(value, ScopeId::ROOT); + let asset_bytes = Signal::new_in_scope(asset_bytes, ScopeId::ROOT); self.registry.write().insert( asset_config.clone(), diff --git a/crates/hooks/tests/use_platform_information.rs b/crates/hooks/tests/use_platform_information.rs index da26688bf..fac8d6b12 100644 --- a/crates/hooks/tests/use_platform_information.rs +++ b/crates/hooks/tests/use_platform_information.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya::prelude::use_platform_information; +use freya::prelude::*; use freya_testing::prelude::*; #[tokio::test] From 3230a5551530f1d15e022cdb21d0e54ffc049fee Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sat, 10 Aug 2024 10:23:00 +0200 Subject: [PATCH 04/21] fix: Update test --- crates/hooks/tests/use_platform_information.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/hooks/tests/use_platform_information.rs b/crates/hooks/tests/use_platform_information.rs index fac8d6b12..b2e51da51 100644 --- a/crates/hooks/tests/use_platform_information.rs +++ b/crates/hooks/tests/use_platform_information.rs @@ -1,4 +1,3 @@ -use dioxus::prelude::*; use freya::prelude::*; use freya_testing::prelude::*; From 61feeebf99f1a999617ff4ec850edbe53d8b1d3b Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 24 Nov 2024 16:01:32 +0100 Subject: [PATCH 05/21] chore: Fix image element usage --- crates/components/src/image.rs | 4 ++-- examples/image_viewer.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/components/src/image.rs b/crates/components/src/image.rs index bc4257e4d..e7a23e936 100644 --- a/crates/components/src/image.rs +++ b/crates/components/src/image.rs @@ -35,7 +35,7 @@ macro_rules! import_image { rsx!(image { width, height, - image_data + image_data, }) } }; @@ -50,7 +50,7 @@ macro_rules! import_image { rsx!(image { width, height, - image_data + image_data, }) } }; diff --git a/examples/image_viewer.rs b/examples/image_viewer.rs index a49d71324..b396b41ad 100644 --- a/examples/image_viewer.rs +++ b/examples/image_viewer.rs @@ -46,7 +46,7 @@ fn app() -> Element { image { width: "fill", height: "fill", - image_data + image_data, } } else { label { From adb2b242192996daa0d4af6e6054d599c52b34fe Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 24 Nov 2024 16:08:18 +0100 Subject: [PATCH 06/21] chore: clean up and fixes --- crates/components/src/svg.rs | 4 ++-- examples/focus.rs | 46 ------------------------------------ 2 files changed, 2 insertions(+), 48 deletions(-) delete mode 100644 examples/focus.rs diff --git a/crates/components/src/svg.rs b/crates/components/src/svg.rs index 70036bb60..950c37546 100644 --- a/crates/components/src/svg.rs +++ b/crates/components/src/svg.rs @@ -41,7 +41,7 @@ macro_rules! import_svg { stroke, width, height, - svg_data + svg_data, }) } }; @@ -65,7 +65,7 @@ macro_rules! import_svg { stroke, width, height, - svg_data + svg_data, }) } }; diff --git a/examples/focus.rs b/examples/focus.rs deleted file mode 100644 index 3cef7a985..000000000 --- a/examples/focus.rs +++ /dev/null @@ -1,46 +0,0 @@ -#![cfg_attr( - all(not(debug_assertions), target_os = "windows"), - windows_subsystem = "windows" -)] - -use freya::prelude::*; - -fn main() { - launch(app); -} - -#[allow(non_snake_case)] -fn Child() -> Element { - let mut focus_manager = use_focus(); - let is_focused = focus_manager.is_focused(); - rsx!( - rect { - width: "100%", - height: "60", - focus_id: focus_manager.attribute(), - background: "rgb(45, 45, 45)", - padding: "10", - color: "white", - onclick: move |_| { - focus_manager.focus(); - }, - label { - "Am I focused? {is_focused}" - } - } - ) -} - -fn app() -> Element { - rsx!( - rect { - width: "100%", - height: "100%", - Child {} - Child {} - Child {} - Child {} - Child {} - } - ) -} From 4fb6491cff28838f7466d1a7545d300ec04f67f4 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 24 Nov 2024 16:17:07 +0100 Subject: [PATCH 07/21] fix: Update the Text Editors example --- examples/text_editors.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/text_editors.rs b/examples/text_editors.rs index 58535b08e..40c52eb4e 100644 --- a/examples/text_editors.rs +++ b/examples/text_editors.rs @@ -53,7 +53,7 @@ fn app() -> Element { rect { spacing: "10", for (i, editable) in text_editors.into_iter().enumerate() { - TextEditor { + Editor { key: "{i}", editable } @@ -63,7 +63,7 @@ fn app() -> Element { } #[component] -fn TextEditor(mut editable: UseEditable) -> Element { +fn Editor(mut editable: UseEditable) -> Element { let mut focus = use_focus(); let cursor_reference = editable.cursor_attr(); let highlights = editable.highlights_attr(0); From 28aeef1944983fd309065f7058fbfcf4679c8d48 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 24 Nov 2024 16:24:58 +0100 Subject: [PATCH 08/21] chore: clean up --- crates/elements/src/definitions.rs | 8 ++++---- crates/hooks/tests/use_platform_information.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/elements/src/definitions.rs b/crates/elements/src/definitions.rs index 545922129..db508fd5c 100644 --- a/crates/elements/src/definitions.rs +++ b/crates/elements/src/definitions.rs @@ -914,7 +914,7 @@ pub mod events { $data:ty; $( $( #[$attr:meta] )* - $name:ident $(: $js_name:literal)? + $name:ident $(: $event:literal)? )* ) => { $( @@ -923,7 +923,7 @@ pub mod events { pub fn $name<__Marker>(mut _f: impl ::dioxus_core::prelude::SuperInto<::dioxus_core::prelude::EventHandler<::dioxus_core::Event<$data>>, __Marker>) -> ::dioxus_core::Attribute { let event_handler = _f.super_into(); ::dioxus_core::Attribute::new( - impl_event!(@name $name $($js_name)?), + impl_event!(@name $name $($event)?), ::dioxus_core::AttributeValue::listener(move |e: ::dioxus_core::Event| { event_handler.call(e.map(|e| e.into())); }), @@ -952,8 +952,8 @@ pub mod events { )* }; - (@name $name:ident $js_name:literal) => { - $js_name + (@name $name:ident $event:literal) => { + $event }; (@name $name:ident) => { stringify!($name) diff --git a/crates/hooks/tests/use_platform_information.rs b/crates/hooks/tests/use_platform_information.rs index c082c597b..330c856f6 100644 --- a/crates/hooks/tests/use_platform_information.rs +++ b/crates/hooks/tests/use_platform_information.rs @@ -2,7 +2,7 @@ use freya::prelude::{ use_platform_information, *, }; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_testing::prelude::*; #[tokio::test] From ef915d7739a59b67d7eae407092cb523b7a85f72 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 24 Nov 2024 16:42:30 +0100 Subject: [PATCH 09/21] chore: Remove hotreload --- crates/freya/src/_docs/hot_reload.rs | 26 -------------------------- crates/freya/src/_docs/mod.rs | 1 - 2 files changed, 27 deletions(-) delete mode 100644 crates/freya/src/_docs/hot_reload.rs diff --git a/crates/freya/src/_docs/hot_reload.rs b/crates/freya/src/_docs/hot_reload.rs deleted file mode 100644 index a38a24e41..000000000 --- a/crates/freya/src/_docs/hot_reload.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! # Hot reload -//! -//! Freya supports Dioxus hot reload, which means that you can update the `layout` and `styling` of your app on the fly, without having to recompile your project. -//! -//! ## Setup -//! -//! Before launching your app, you need to initialize the hot-reload context: -//! -//! ```rust, no_run -//! use freya::{ -//! hotreload::FreyaCtx, -//! prelude::*, -//! }; -//! -//! fn main() { -//! dioxus_hot_reload::hot_reload_init!(Config::::default()); -//! -//! launch(app); -//! } -//! -//! # fn app() -> Element { -//! # None -//! # } -//! ``` -//! -//! That is it! diff --git a/crates/freya/src/_docs/mod.rs b/crates/freya/src/_docs/mod.rs index dae281b3f..e6d5c95cb 100644 --- a/crates/freya/src/_docs/mod.rs +++ b/crates/freya/src/_docs/mod.rs @@ -1,3 +1,2 @@ pub mod devtools; -pub mod hot_reload; pub mod theming; From 6e7c957bf4deb1a244907206a0ec0075cc63f901 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 24 Nov 2024 16:51:17 +0100 Subject: [PATCH 10/21] fix: Return empty vnodes instead of None --- crates/components/src/tabs.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/components/src/tabs.rs b/crates/components/src/tabs.rs index e1f090ade..663ecb712 100644 --- a/crates/components/src/tabs.rs +++ b/crates/components/src/tabs.rs @@ -45,9 +45,9 @@ pub enum TabStatus { /// # use freya::prelude::*; /// # use dioxus_router::prelude::Routable; /// # #[allow(non_snake_case)] -/// # fn PageNotFound() -> Element { None } +/// # fn PageNotFound() -> Element { Ok(VNode::empty()) } /// # #[allow(non_snake_case)] -/// # fn Settings() -> Element { None } +/// # fn Settings() -> Element { Ok(VNode::empty()) } /// # #[derive(Routable, Clone, PartialEq)] /// # #[rustfmt::skip] /// # pub enum Route { @@ -174,9 +174,9 @@ pub fn Tab( /// # use freya::prelude::*; /// # use dioxus_router::prelude::Routable; /// # #[allow(non_snake_case)] -/// # fn PageNotFound() -> Element { None } +/// # fn PageNotFound() -> Element { Ok(VNode::empty()) } /// # #[allow(non_snake_case)] -/// # fn Settings() -> Element { None } +/// # fn Settings() -> Element { Ok(VNode::empty()) } /// # #[derive(Routable, Clone, PartialEq)] /// # #[rustfmt::skip] /// # pub enum Route { From 92b0144298612a1aa31b73ae8dcf22c78489992a Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 24 Nov 2024 17:00:55 +0100 Subject: [PATCH 11/21] fix:VNode::empty() --- crates/components/src/tabs.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/components/src/tabs.rs b/crates/components/src/tabs.rs index 663ecb712..6d5c1c324 100644 --- a/crates/components/src/tabs.rs +++ b/crates/components/src/tabs.rs @@ -45,9 +45,9 @@ pub enum TabStatus { /// # use freya::prelude::*; /// # use dioxus_router::prelude::Routable; /// # #[allow(non_snake_case)] -/// # fn PageNotFound() -> Element { Ok(VNode::empty()) } +/// # fn PageNotFound() -> Element { VNode::empty() } /// # #[allow(non_snake_case)] -/// # fn Settings() -> Element { Ok(VNode::empty()) } +/// # fn Settings() -> Element { VNode::empty() } /// # #[derive(Routable, Clone, PartialEq)] /// # #[rustfmt::skip] /// # pub enum Route { @@ -174,9 +174,9 @@ pub fn Tab( /// # use freya::prelude::*; /// # use dioxus_router::prelude::Routable; /// # #[allow(non_snake_case)] -/// # fn PageNotFound() -> Element { Ok(VNode::empty()) } +/// # fn PageNotFound() -> Element { VNode::empty() } /// # #[allow(non_snake_case)] -/// # fn Settings() -> Element { Ok(VNode::empty()) } +/// # fn Settings() -> Element { VNode::empty() } /// # #[derive(Routable, Clone, PartialEq)] /// # #[rustfmt::skip] /// # pub enum Route { From e7f52ad40fa1758318a6675e4905fbf50b4fcc77 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 24 Nov 2024 17:01:35 +0100 Subject: [PATCH 12/21] fix: comma --- crates/components/src/checkbox.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/components/src/checkbox.rs b/crates/components/src/checkbox.rs index dce0b8ca3..fc4706951 100644 --- a/crates/components/src/checkbox.rs +++ b/crates/components/src/checkbox.rs @@ -43,7 +43,7 @@ use crate::TickIcon; /// Checkbox { /// selected: selected.read().contains(&Choice::First), /// } -/// ) +/// ), /// label { "First choice" } /// } /// Tile { From 80efc25bb9b726bed00d0234f19cf21bee7681af Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 24 Nov 2024 17:06:57 +0100 Subject: [PATCH 13/21] fix: missing VNode::empty() --- crates/hooks/src/use_theme.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/hooks/src/use_theme.rs b/crates/hooks/src/use_theme.rs index 4f9d8db20..5f12e7635 100644 --- a/crates/hooks/src/use_theme.rs +++ b/crates/hooks/src/use_theme.rs @@ -60,7 +60,7 @@ pub fn use_get_theme() -> Theme { /// } = use_applied_theme!(&props.theme, button); /// // ... /// -/// # None +/// # VNode::empty() /// } /// ``` #[macro_export] From 585815d799c6908033cc9af1cf0a6ed2bf1fea1d Mon Sep 17 00:00:00 2001 From: marc2332 Date: Tue, 10 Dec 2024 12:26:13 +0100 Subject: [PATCH 14/21] feat: 0.6 support --- Cargo.toml | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 71a8539c7..004f01964 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,16 +15,16 @@ performance-overlay = ["freya/performance-overlay"] fade-cached-incremental-areas = ["freya/fade-cached-incremental-areas"] disable-zoom-shortcuts = ["freya/disable-zoom-shortcuts"] -[patch.crates-io] -dioxus = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" } -dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" } -dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" } -dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" } -dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" } -dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" } -dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" } -dioxus-lib = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" } -generational-box = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" } +# [patch.crates-io] +# dioxus = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } +# dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } +# dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } +# dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } +# dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } +# dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } +# dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } +# dioxus-lib = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } +# generational-box = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } [workspace.dependencies] freya = { path = "crates/freya", version = "0.2" } @@ -39,19 +39,18 @@ freya-components = { path = "crates/components", version = "0.2" } freya-testing = { path = "crates/testing", version = "0.2" } freya-engine = { path = "crates/engine", version = "0.2" } torin = { path = "crates/torin", version = "0.2" } -dioxus-clipboard = "0.2.0-alpha.1" +dioxus-clipboard = "0.2.0" freya-native-core-macro = { path = "crates/native-core-macro", version = "0.2" } freya-native-core = { path = "crates/native-core", version = "0.2" } -dioxus = { version = "0.6.0-alpha.5", default-features = false, features = ["macro", "signals", "hooks"] } -dioxus-rsx = { version = "0.6.0-alpha.5" } -dioxus-core-macro = { version = "0.6.0-alpha.5" } -dioxus-hooks = { version = "0.6.0-alpha.5" } -dioxus-signals = { version = "0.6.0-alpha.5" } -dioxus-core = { version = "0.6.0-alpha.5" } -dioxus-router = { version = "0.6.0-alpha.5", default-features = false } -dioxus-sdk = { git = "https://github.com/DioxusLabs/sdk/", branch = "feat/dioxus-0.6" } +dioxus = { version = "0.6.0", default-features = false, features = ["macro", "signals", "hooks"] } +dioxus-rsx = { version = "0.6.0" } +dioxus-core-macro = { version = "0.6.0" } +dioxus-hooks = { version = "0.6.0" } +dioxus-signals = { version = "0.6.0" } +dioxus-core = { version = "0.6.0" } +dioxus-router = { version = "0.6.0", default-features = false } skia-safe = { version = "0.80.0", features = ["gl", "textlayout", "svg"] } @@ -84,12 +83,12 @@ freya-core = { workspace = true } freya-testing = { workspace = true } reqwest = { version = "0.12.0", features = ["json"] } serde = "1.0.189" -dioxus-i18n = "0.2" +dioxus-i18n = "0.3" rand = "0.8.5" dioxus-router = { workspace = true } itertools = "0.13.0" home = "0.5.9" -dioxus-query = "0.5.1" +dioxus-query = "0.6.0" gilrs = "0.10.8" gl = { workspace = true } tree-sitter-highlight = "0.23.0" From 83d41f65e6048a20f5b16c0bc7a7f74084d995e5 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 15 Dec 2024 12:13:12 +0100 Subject: [PATCH 15/21] update definitions --- crates/elements/src/definitions.rs | 1032 ++++++++++++++-------------- 1 file changed, 516 insertions(+), 516 deletions(-) diff --git a/crates/elements/src/definitions.rs b/crates/elements/src/definitions.rs index db508fd5c..181167b25 100644 --- a/crates/elements/src/definitions.rs +++ b/crates/elements/src/definitions.rs @@ -10,7 +10,7 @@ macro_rules! builder_constructors { $name:ident { $( $(#[$attr_method:meta])* - $fil:ident: $vil:ident, + $fil:ident, )* }; )* @@ -21,7 +21,7 @@ macro_rules! builder_constructors { $name { $( $(#[$attr_method])* - $fil: $vil, + $fil, )* }; ); @@ -49,7 +49,7 @@ macro_rules! impl_element { $name:ident { $( $(#[$attr_method:meta])* - $fil:ident: $vil:ident, + $fil:ident, )* }; )* @@ -97,168 +97,168 @@ builder_constructors! { rect { // Layout #[doc = include_str!("_docs/attributes/width_height.md")] - height: String, - width: String, + height, + width, #[doc = include_str!("_docs/attributes/min_width_min_height.md")] - min_height: String, - min_width: String, + min_height, + min_width, #[doc = include_str!("_docs/attributes/max_width_max_height.md")] - max_height: String, - max_width: String, + max_height, + max_width, #[doc = include_str!("_docs/attributes/margin.md")] - margin: String, + margin, #[doc = include_str!("_docs/attributes/padding.md")] - padding: String, + padding, #[doc = include_str!("_docs/attributes/position.md")] - position: String, - position_top: String, - position_right: String, - position_bottom: String, - position_left: String, - layer: String, + position, + position_top, + position_right, + position_bottom, + position_left, + layer, // Children layout #[doc = include_str!("_docs/attributes/direction.md")] - direction: String, + direction, #[doc = include_str!("_docs/attributes/content.md")] - content: String, + content, #[doc = include_str!("_docs/attributes/main_align_cross_align.md")] - main_align: String, - cross_align: String, + main_align, + cross_align, #[doc = include_str!("_docs/attributes/spacing.md")] - spacing: String, + spacing, #[doc = include_str!("_docs/attributes/overflow.md")] - overflow: String, - offset_x: String, - offset_y: String, + overflow, + offset_x, + offset_y, // Style #[doc = include_str!("_docs/attributes/background.md")] - background: String, + background, #[doc = include_str!("_docs/attributes/border.md")] - border: String, + border, #[doc = include_str!("_docs/attributes/shadow.md")] - shadow: String, + shadow, #[doc = include_str!("_docs/attributes/corner.md")] - corner_radius: String, - corner_smoothing: String, + corner_radius, + corner_smoothing, // Font style #[doc = include_str!("_docs/attributes/color.md")] - color: String, + color, #[doc = include_str!("_docs/attributes/font_size.md")] - font_size: String, + font_size, #[doc = include_str!("_docs/attributes/font_family.md")] - font_family: String, + font_family, #[doc = include_str!("_docs/attributes/font_style.md")] - font_style: String, + font_style, #[doc = include_str!("_docs/attributes/font_weight.md")] - font_weight: String, + font_weight, #[doc = include_str!("_docs/attributes/font_width.md")] - font_width: String, + font_width, #[doc = include_str!("_docs/attributes/text_align.md")] - text_align: String, + text_align, #[doc = include_str!("_docs/attributes/line_height.md")] - line_height: String, + line_height, #[doc = include_str!("_docs/attributes/text_shadow.md")] - text_shadow: String, + text_shadow, #[doc = include_str!("_docs/attributes/max_lines.md")] - max_lines: String, + max_lines, #[doc = include_str!("_docs/attributes/decoration.md")] - decoration: String, + decoration, #[doc = include_str!("_docs/attributes/decoration_style.md")] - decoration_style: String, + decoration_style, #[doc = include_str!("_docs/attributes/decoration_color.md")] - decoration_color: String, + decoration_color, #[doc = include_str!("_docs/attributes/text_overflow.md")] - text_overflow: String, + text_overflow, #[doc = include_str!("_docs/attributes/letter_spacing.md")] - letter_spacing: String, + letter_spacing, #[doc = include_str!("_docs/attributes/word_spacing.md")] - word_spacing: String, + word_spacing, #[doc = include_str!("_docs/attributes/text_height.md")] - text_height: String, + text_height, // Transform #[doc = include_str!("_docs/attributes/rotate.md")] - rotate: String, + rotate, #[doc = include_str!("_docs/attributes/opacity.md")] - opacity: String, + opacity, // Reference - canvas_reference: String, - reference: Reference, - cursor_reference: CursorReference, + canvas_reference, + reference, + cursor_reference, // Accessibility - a11y_id: String, - a11y_focusable: String, - a11y_auto_focus: String, - a11y_name: String, - a11y_description: String, - a11y_value: String, - a11y_access_key: String, - a11y_author_id: String, - a11y_keyboard_shortcut: String, - a11y_language: String, - a11y_placeholder: String, - a11y_role_description: String, - a11y_state_description: String, - a11y_tooltip: String, - a11y_url: String, - a11y_row_index_text: String, - a11y_column_index_text: String, - a11y_scroll_x: String, - a11y_scroll_x_min: String, - a11y_scroll_x_max: String, - a11y_scroll_y: String, - a11y_scroll_y_min: String, - a11y_scroll_y_max: String, - a11y_numeric_value: String, - a11y_min_numeric_value: String, - a11y_max_numeric_value: String, - a11y_numeric_value_step: String, - a11y_numeric_value_jump: String, - a11y_row_count: String, - a11y_column_count: String, - a11y_row_index: String, - a11y_column_index: String, - a11y_row_span: String, - a11y_column_span: String, - a11y_level: String, - a11y_size_of_set: String, - a11y_position_in_set: String, - a11y_color_value: String, - a11y_expanded: String, - a11y_selected: String, - a11y_hovered: String, - a11y_hidden: String, - a11y_linked: String, - a11y_multiselectable: String, - a11y_required: String, - a11y_visited: String, - a11y_busy: String, - a11y_live_atomic: String, - a11y_modal: String, - a11y_touch_transparent: String, - a11y_read_only: String, - a11y_disabled: String, - a11y_is_spelling_error: String, - a11y_is_grammar_error: String, - a11y_is_search_match: String, - a11y_is_suggestion: String, - a11y_role: String, - a11y_invalid: String, - a11y_toggled: String, - a11y_live: String, - a11y_default_action_verb: String, - a11y_orientation: String, - a11y_sort_direction: String, - a11y_current: String, - a11y_auto_complete: String, - a11y_has_popup: String, - a11y_list_style: String, - a11y_vertical_offset: String, + a11y_id, + a11y_focusable, + a11y_auto_focus, + a11y_name, + a11y_description, + a11y_value, + a11y_access_key, + a11y_author_id, + a11y_keyboard_shortcut, + a11y_language, + a11y_placeholder, + a11y_role_description, + a11y_state_description, + a11y_tooltip, + a11y_url, + a11y_row_index_text, + a11y_column_index_text, + a11y_scroll_x, + a11y_scroll_x_min, + a11y_scroll_x_max, + a11y_scroll_y, + a11y_scroll_y_min, + a11y_scroll_y_max, + a11y_numeric_value, + a11y_min_numeric_value, + a11y_max_numeric_value, + a11y_numeric_value_step, + a11y_numeric_value_jump, + a11y_row_count, + a11y_column_count, + a11y_row_index, + a11y_column_index, + a11y_row_span, + a11y_column_span, + a11y_level, + a11y_size_of_set, + a11y_position_in_set, + a11y_color_value, + a11y_expanded, + a11y_selected, + a11y_hovered, + a11y_hidden, + a11y_linked, + a11y_multiselectable, + a11y_required, + a11y_visited, + a11y_busy, + a11y_live_atomic, + a11y_modal, + a11y_touch_transparent, + a11y_read_only, + a11y_disabled, + a11y_is_spelling_error, + a11y_is_grammar_error, + a11y_is_search_match, + a11y_is_suggestion, + a11y_role, + a11y_invalid, + a11y_toggled, + a11y_live, + a11y_default_action_verb, + a11y_orientation, + a11y_sort_direction, + a11y_current, + a11y_auto_complete, + a11y_has_popup, + a11y_list_style, + a11y_vertical_offset, }; /// `label` simply let's you display some text. /// @@ -277,139 +277,139 @@ builder_constructors! { label { // Layout #[doc = include_str!("_docs/attributes/width_height.md")] - height: String, - width: String, + height, + width, #[doc = include_str!("_docs/attributes/min_width_min_height.md")] - min_height: String, - min_width: String, + min_height, + min_width, #[doc = include_str!("_docs/attributes/max_width_max_height.md")] - max_height: String, - max_width: String, + max_height, + max_width, #[doc = include_str!("_docs/attributes/margin.md")] - margin: String, + margin, #[doc = include_str!("_docs/attributes/position.md")] - position: String, - position_top: String, - position_right: String, - position_bottom: String, - position_left: String, - layer: String, + position, + position_top, + position_right, + position_bottom, + position_left, + layer, // Children layout #[doc = include_str!("_docs/attributes/main_align_cross_align.md")] - main_align: String, + main_align, // Font style #[doc = include_str!("_docs/attributes/color.md")] - color: String, + color, #[doc = include_str!("_docs/attributes/font_size.md")] - font_size: String, + font_size, #[doc = include_str!("_docs/attributes/font_family.md")] - font_family: String, + font_family, #[doc = include_str!("_docs/attributes/font_style.md")] - font_style: String, + font_style, #[doc = include_str!("_docs/attributes/font_weight.md")] - font_weight: String, + font_weight, #[doc = include_str!("_docs/attributes/font_width.md")] - font_width: String, + font_width, #[doc = include_str!("_docs/attributes/text_align.md")] - text_align: String, + text_align, #[doc = include_str!("_docs/attributes/line_height.md")] - line_height: String, + line_height, #[doc = include_str!("_docs/attributes/text_shadow.md")] - text_shadow: String, + text_shadow, #[doc = include_str!("_docs/attributes/max_lines.md")] - max_lines: String, + max_lines, #[doc = include_str!("_docs/attributes/decoration.md")] - decoration: String, + decoration, #[doc = include_str!("_docs/attributes/decoration_style.md")] - decoration_style: String, + decoration_style, #[doc = include_str!("_docs/attributes/decoration_color.md")] - decoration_color: String, + decoration_color, #[doc = include_str!("_docs/attributes/text_overflow.md")] - text_overflow: String, + text_overflow, #[doc = include_str!("_docs/attributes/letter_spacing.md")] - letter_spacing: String, + letter_spacing, #[doc = include_str!("_docs/attributes/word_spacing.md")] - word_spacing: String, + word_spacing, #[doc = include_str!("_docs/attributes/text_height.md")] - text_height: String, + text_height, // Transform #[doc = include_str!("_docs/attributes/rotate.md")] - rotate: String, + rotate, #[doc = include_str!("_docs/attributes/opacity.md")] - opacity: String, + opacity, // Accessibility - a11y_id: String, - a11y_auto_focus: String, - a11y_focusable: String, - a11y_name: String, - a11y_description: String, - a11y_value: String, - a11y_access_key: String, - a11y_author_id: String, - a11y_keyboard_shortcut: String, - a11y_language: String, - a11y_placeholder: String, - a11y_role_description: String, - a11y_state_description: String, - a11y_tooltip: String, - a11y_url: String, - a11y_row_index_text: String, - a11y_column_index_text: String, - a11y_scroll_x: String, - a11y_scroll_x_min: String, - a11y_scroll_x_max: String, - a11y_scroll_y: String, - a11y_scroll_y_min: String, - a11y_scroll_y_max: String, - a11y_numeric_value: String, - a11y_min_numeric_value: String, - a11y_max_numeric_value: String, - a11y_numeric_value_step: String, - a11y_numeric_value_jump: String, - a11y_row_count: String, - a11y_column_count: String, - a11y_row_index: String, - a11y_column_index: String, - a11y_row_span: String, - a11y_column_span: String, - a11y_level: String, - a11y_size_of_set: String, - a11y_position_in_set: String, - a11y_color_value: String, - a11y_expanded: String, - a11y_selected: String, - a11y_hovered: String, - a11y_hidden: String, - a11y_linked: String, - a11y_multiselectable: String, - a11y_required: String, - a11y_visited: String, - a11y_busy: String, - a11y_live_atomic: String, - a11y_modal: String, - a11y_touch_transparent: String, - a11y_read_only: String, - a11y_disabled: String, - a11y_is_spelling_error: String, - a11y_is_grammar_error: String, - a11y_is_search_match: String, - a11y_is_suggestion: String, - a11y_role: String, - a11y_invalid: String, - a11y_toggled: String, - a11y_live: String, - a11y_default_action_verb: String, - a11y_orientation: String, - a11y_sort_direction: String, - a11y_current: String, - a11y_auto_complete: String, - a11y_has_popup: String, - a11y_list_style: String, - a11y_vertical_offset: String, + a11y_id, + a11y_auto_focus, + a11y_focusable, + a11y_name, + a11y_description, + a11y_value, + a11y_access_key, + a11y_author_id, + a11y_keyboard_shortcut, + a11y_language, + a11y_placeholder, + a11y_role_description, + a11y_state_description, + a11y_tooltip, + a11y_url, + a11y_row_index_text, + a11y_column_index_text, + a11y_scroll_x, + a11y_scroll_x_min, + a11y_scroll_x_max, + a11y_scroll_y, + a11y_scroll_y_min, + a11y_scroll_y_max, + a11y_numeric_value, + a11y_min_numeric_value, + a11y_max_numeric_value, + a11y_numeric_value_step, + a11y_numeric_value_jump, + a11y_row_count, + a11y_column_count, + a11y_row_index, + a11y_column_index, + a11y_row_span, + a11y_column_span, + a11y_level, + a11y_size_of_set, + a11y_position_in_set, + a11y_color_value, + a11y_expanded, + a11y_selected, + a11y_hovered, + a11y_hidden, + a11y_linked, + a11y_multiselectable, + a11y_required, + a11y_visited, + a11y_busy, + a11y_live_atomic, + a11y_modal, + a11y_touch_transparent, + a11y_read_only, + a11y_disabled, + a11y_is_spelling_error, + a11y_is_grammar_error, + a11y_is_search_match, + a11y_is_suggestion, + a11y_role, + a11y_invalid, + a11y_toggled, + a11y_live, + a11y_default_action_verb, + a11y_orientation, + a11y_sort_direction, + a11y_current, + a11y_auto_complete, + a11y_has_popup, + a11y_list_style, + a11y_vertical_offset, }; /// `paragraph` element let's you build texts with different styles. /// @@ -435,180 +435,180 @@ builder_constructors! { paragraph { // Layout #[doc = include_str!("_docs/attributes/width_height.md")] - height: String, - width: String, + height, + width, #[doc = include_str!("_docs/attributes/min_width_min_height.md")] - min_height: String, - min_width: String, + min_height, + min_width, #[doc = include_str!("_docs/attributes/max_width_max_height.md")] - max_height: String, - max_width: String, + max_height, + max_width, #[doc = include_str!("_docs/attributes/margin.md")] - margin: String, + margin, #[doc = include_str!("_docs/attributes/position.md")] - position: String, - position_top: String, - position_right: String, - position_bottom: String, - position_left: String, - layer: String, + position, + position_top, + position_right, + position_bottom, + position_left, + layer, // Children layout #[doc = include_str!("_docs/attributes/main_align_cross_align.md")] - main_align: String, + main_align, // Font style #[doc = include_str!("_docs/attributes/color.md")] - color: String, + color, #[doc = include_str!("_docs/attributes/font_size.md")] - font_size: String, + font_size, #[doc = include_str!("_docs/attributes/font_family.md")] - font_family: String, + font_family, #[doc = include_str!("_docs/attributes/font_style.md")] - font_style: String, + font_style, #[doc = include_str!("_docs/attributes/font_weight.md")] - font_weight: String, + font_weight, #[doc = include_str!("_docs/attributes/font_width.md")] - font_width: String, + font_width, #[doc = include_str!("_docs/attributes/text_align.md")] - text_align: String, + text_align, #[doc = include_str!("_docs/attributes/line_height.md")] - line_height: String, + line_height, #[doc = include_str!("_docs/attributes/text_shadow.md")] - text_shadow: String, + text_shadow, #[doc = include_str!("_docs/attributes/max_lines.md")] - max_lines: String, + max_lines, #[doc = include_str!("_docs/attributes/decoration.md")] - decoration: String, + decoration, #[doc = include_str!("_docs/attributes/decoration_style.md")] - decoration_style: String, + decoration_style, #[doc = include_str!("_docs/attributes/decoration_color.md")] - decoration_color: String, + decoration_color, #[doc = include_str!("_docs/attributes/text_overflow.md")] - text_overflow: String, + text_overflow, #[doc = include_str!("_docs/attributes/letter_spacing.md")] - letter_spacing: String, + letter_spacing, #[doc = include_str!("_docs/attributes/word_spacing.md")] - word_spacing: String, + word_spacing, #[doc = include_str!("_docs/attributes/text_height.md")] - text_height: String, + text_height, // Transform #[doc = include_str!("_docs/attributes/rotate.md")] - rotate: String, + rotate, #[doc = include_str!("_docs/attributes/opacity.md")] - opacity: String, + opacity, // Text Editing - cursor_index: String, - cursor_color: String, - cursor_mode: String, - cursor_id: String, - highlights: String, - highlight_color: String, - highlight_mode: String, + cursor_index, + cursor_color, + cursor_mode, + cursor_id, + highlights, + highlight_color, + highlight_mode, // Accessibility - a11y_id: String, - a11y_focusable: String, - a11y_auto_focus: String, - a11y_name: String, - a11y_description: String, - a11y_value: String, - a11y_access_key: String, - a11y_author_id: String, - a11y_keyboard_shortcut: String, - a11y_language: String, - a11y_placeholder: String, - a11y_role_description: String, - a11y_state_description: String, - a11y_tooltip: String, - a11y_url: String, - a11y_row_index_text: String, - a11y_column_index_text: String, - a11y_scroll_x: String, - a11y_scroll_x_min: String, - a11y_scroll_x_max: String, - a11y_scroll_y: String, - a11y_scroll_y_min: String, - a11y_scroll_y_max: String, - a11y_numeric_value: String, - a11y_min_numeric_value: String, - a11y_max_numeric_value: String, - a11y_numeric_value_step: String, - a11y_numeric_value_jump: String, - a11y_row_count: String, - a11y_column_count: String, - a11y_row_index: String, - a11y_column_index: String, - a11y_row_span: String, - a11y_column_span: String, - a11y_level: String, - a11y_size_of_set: String, - a11y_position_in_set: String, - a11y_color_value: String, - a11y_expanded: String, - a11y_selected: String, - a11y_hovered: String, - a11y_hidden: String, - a11y_linked: String, - a11y_multiselectable: String, - a11y_required: String, - a11y_visited: String, - a11y_busy: String, - a11y_live_atomic: String, - a11y_modal: String, - a11y_touch_transparent: String, - a11y_read_only: String, - a11y_disabled: String, - a11y_is_spelling_error: String, - a11y_is_grammar_error: String, - a11y_is_search_match: String, - a11y_is_suggestion: String, - a11y_role: String, - a11y_invalid: String, - a11y_toggled: String, - a11y_live: String, - a11y_default_action_verb: String, - a11y_orientation: String, - a11y_sort_direction: String, - a11y_current: String, - a11y_auto_complete: String, - a11y_has_popup: String, - a11y_list_style: String, - a11y_vertical_offset: String, + a11y_id, + a11y_focusable, + a11y_auto_focus, + a11y_name, + a11y_description, + a11y_value, + a11y_access_key, + a11y_author_id, + a11y_keyboard_shortcut, + a11y_language, + a11y_placeholder, + a11y_role_description, + a11y_state_description, + a11y_tooltip, + a11y_url, + a11y_row_index_text, + a11y_column_index_text, + a11y_scroll_x, + a11y_scroll_x_min, + a11y_scroll_x_max, + a11y_scroll_y, + a11y_scroll_y_min, + a11y_scroll_y_max, + a11y_numeric_value, + a11y_min_numeric_value, + a11y_max_numeric_value, + a11y_numeric_value_step, + a11y_numeric_value_jump, + a11y_row_count, + a11y_column_count, + a11y_row_index, + a11y_column_index, + a11y_row_span, + a11y_column_span, + a11y_level, + a11y_size_of_set, + a11y_position_in_set, + a11y_color_value, + a11y_expanded, + a11y_selected, + a11y_hovered, + a11y_hidden, + a11y_linked, + a11y_multiselectable, + a11y_required, + a11y_visited, + a11y_busy, + a11y_live_atomic, + a11y_modal, + a11y_touch_transparent, + a11y_read_only, + a11y_disabled, + a11y_is_spelling_error, + a11y_is_grammar_error, + a11y_is_search_match, + a11y_is_suggestion, + a11y_role, + a11y_invalid, + a11y_toggled, + a11y_live, + a11y_default_action_verb, + a11y_orientation, + a11y_sort_direction, + a11y_current, + a11y_auto_complete, + a11y_has_popup, + a11y_list_style, + a11y_vertical_offset, }; /// `text` element is simply a text span used for the `paragraph` element. text { // Font style #[doc = include_str!("_docs/attributes/color.md")] - color: String, + color, #[doc = include_str!("_docs/attributes/font_size.md")] - font_size: String, + font_size, #[doc = include_str!("_docs/attributes/font_family.md")] - font_family: String, + font_family, #[doc = include_str!("_docs/attributes/font_style.md")] - font_style: String, + font_style, #[doc = include_str!("_docs/attributes/font_weight.md")] - font_weight: String, + font_weight, #[doc = include_str!("_docs/attributes/font_width.md")] - font_width: String, + font_width, #[doc = include_str!("_docs/attributes/text_align.md")] - text_align: String, + text_align, #[doc = include_str!("_docs/attributes/line_height.md")] - line_height: String, + line_height, #[doc = include_str!("_docs/attributes/text_shadow.md")] - text_shadow: String, + text_shadow, #[doc = include_str!("_docs/attributes/decoration.md")] - decoration: String, + decoration, #[doc = include_str!("_docs/attributes/decoration_style.md")] - decoration_style: String, + decoration_style, #[doc = include_str!("_docs/attributes/decoration_color.md")] - decoration_color: String, + decoration_color, #[doc = include_str!("_docs/attributes/letter_spacing.md")] - letter_spacing: String, + letter_spacing, #[doc = include_str!("_docs/attributes/word_spacing.md")] - word_spacing: String, + word_spacing, }; /// `image` element let's you show an image. /// @@ -634,103 +634,103 @@ builder_constructors! { image { // Layout #[doc = include_str!("_docs/attributes/width_height.md")] - height: String, - width: String, + height, + width, #[doc = include_str!("_docs/attributes/min_width_min_height.md")] - min_height: String, - min_width: String, + min_height, + min_width, #[doc = include_str!("_docs/attributes/max_width_max_height.md")] - max_height: String, - max_width: String, + max_height, + max_width, #[doc = include_str!("_docs/attributes/margin.md")] - margin: String, + margin, #[doc = include_str!("_docs/attributes/position.md")] - position: String, - position_top: String, - position_right: String, - position_bottom: String, - position_left: String, - layer: String, + position, + position_top, + position_right, + position_bottom, + position_left, + layer, // Transform #[doc = include_str!("_docs/attributes/rotate.md")] - rotate: String, + rotate, #[doc = include_str!("_docs/attributes/opacity.md")] - opacity: String, + opacity, // Image - image_data: String, - image_reference: String, + image_data, + image_reference, // Accessibility - a11y_id: String, - a11y_focusable: String, - a11y_auto_focus: String, - a11y_name: String, - a11y_description: String, - a11y_value: String, - a11y_access_key: String, - a11y_author_id: String, - a11y_keyboard_shortcut: String, - a11y_language: String, - a11y_placeholder: String, - a11y_role_description: String, - a11y_state_description: String, - a11y_tooltip: String, - a11y_url: String, - a11y_row_index_text: String, - a11y_column_index_text: String, - a11y_scroll_x: String, - a11y_scroll_x_min: String, - a11y_scroll_x_max: String, - a11y_scroll_y: String, - a11y_scroll_y_min: String, - a11y_scroll_y_max: String, - a11y_numeric_value: String, - a11y_min_numeric_value: String, - a11y_max_numeric_value: String, - a11y_numeric_value_step: String, - a11y_numeric_value_jump: String, - a11y_row_count: String, - a11y_column_count: String, - a11y_row_index: String, - a11y_column_index: String, - a11y_row_span: String, - a11y_column_span: String, - a11y_level: String, - a11y_size_of_set: String, - a11y_position_in_set: String, - a11y_color_value: String, - a11y_expanded: String, - a11y_selected: String, - a11y_hovered: String, - a11y_hidden: String, - a11y_linked: String, - a11y_multiselectable: String, - a11y_required: String, - a11y_visited: String, - a11y_busy: String, - a11y_live_atomic: String, - a11y_modal: String, - a11y_touch_transparent: String, - a11y_read_only: String, - a11y_disabled: String, - a11y_is_spelling_error: String, - a11y_is_grammar_error: String, - a11y_is_search_match: String, - a11y_is_suggestion: String, - a11y_role: String, - a11y_invalid: String, - a11y_toggled: String, - a11y_live: String, - a11y_default_action_verb: String, - a11y_orientation: String, - a11y_sort_direction: String, - a11y_current: String, - a11y_auto_complete: String, - a11y_has_popup: String, - a11y_list_style: String, - a11y_vertical_offset: String, + a11y_id, + a11y_focusable, + a11y_auto_focus, + a11y_name, + a11y_description, + a11y_value, + a11y_access_key, + a11y_author_id, + a11y_keyboard_shortcut, + a11y_language, + a11y_placeholder, + a11y_role_description, + a11y_state_description, + a11y_tooltip, + a11y_url, + a11y_row_index_text, + a11y_column_index_text, + a11y_scroll_x, + a11y_scroll_x_min, + a11y_scroll_x_max, + a11y_scroll_y, + a11y_scroll_y_min, + a11y_scroll_y_max, + a11y_numeric_value, + a11y_min_numeric_value, + a11y_max_numeric_value, + a11y_numeric_value_step, + a11y_numeric_value_jump, + a11y_row_count, + a11y_column_count, + a11y_row_index, + a11y_column_index, + a11y_row_span, + a11y_column_span, + a11y_level, + a11y_size_of_set, + a11y_position_in_set, + a11y_color_value, + a11y_expanded, + a11y_selected, + a11y_hovered, + a11y_hidden, + a11y_linked, + a11y_multiselectable, + a11y_required, + a11y_visited, + a11y_busy, + a11y_live_atomic, + a11y_modal, + a11y_touch_transparent, + a11y_read_only, + a11y_disabled, + a11y_is_spelling_error, + a11y_is_grammar_error, + a11y_is_search_match, + a11y_is_suggestion, + a11y_role, + a11y_invalid, + a11y_toggled, + a11y_live, + a11y_default_action_verb, + a11y_orientation, + a11y_sort_direction, + a11y_current, + a11y_auto_complete, + a11y_has_popup, + a11y_list_style, + a11y_vertical_offset, }; /// `svg` element let's you display SVG code. /// @@ -756,108 +756,108 @@ builder_constructors! { svg { // Layout #[doc = include_str!("_docs/attributes/width_height.md")] - height: String, - width: String, + height, + width, #[doc = include_str!("_docs/attributes/min_width_min_height.md")] - min_height: String, - min_width: String, + min_height, + min_width, #[doc = include_str!("_docs/attributes/max_width_max_height.md")] - max_height: String, - max_width: String, + max_height, + max_width, #[doc = include_str!("_docs/attributes/margin.md")] - margin: String, + margin, #[doc = include_str!("_docs/attributes/position.md")] - position: String, - position_top: String, - position_right: String, - position_bottom: String, - position_left: String, - layer: String, + position, + position_top, + position_right, + position_bottom, + position_left, + layer, // Transform #[doc = include_str!("_docs/attributes/rotate.md")] - rotate: String, + rotate, #[doc = include_str!("_docs/attributes/opacity.md")] - opacity: String, + opacity, // Svg #[doc = include_str!("_docs/attributes/color.md")] - color: String, - svg_data: String, - svg_content: String, + color, + svg_data, + svg_content, #[doc = include_str!("_docs/attributes/fill_stroke.md")] - fill: String, - stroke: String, + fill, + stroke, // Accessibility - a11y_id: String, - a11y_focusable: String, - a11y_auto_focus: String, - a11y_name: String, - a11y_description: String, - a11y_value: String, - a11y_access_key: String, - a11y_author_id: String, - a11y_keyboard_shortcut: String, - a11y_language: String, - a11y_placeholder: String, - a11y_role_description: String, - a11y_state_description: String, - a11y_tooltip: String, - a11y_url: String, - a11y_row_index_text: String, - a11y_column_index_text: String, - a11y_scroll_x: String, - a11y_scroll_x_min: String, - a11y_scroll_x_max: String, - a11y_scroll_y: String, - a11y_scroll_y_min: String, - a11y_scroll_y_max: String, - a11y_numeric_value: String, - a11y_min_numeric_value: String, - a11y_max_numeric_value: String, - a11y_numeric_value_step: String, - a11y_numeric_value_jump: String, - a11y_row_count: String, - a11y_column_count: String, - a11y_row_index: String, - a11y_column_index: String, - a11y_row_span: String, - a11y_column_span: String, - a11y_level: String, - a11y_size_of_set: String, - a11y_position_in_set: String, - a11y_color_value: String, - a11y_expanded: String, - a11y_selected: String, - a11y_hovered: String, - a11y_hidden: String, - a11y_linked: String, - a11y_multiselectable: String, - a11y_required: String, - a11y_visited: String, - a11y_busy: String, - a11y_live_atomic: String, - a11y_modal: String, - a11y_touch_transparent: String, - a11y_read_only: String, - a11y_disabled: String, - a11y_is_spelling_error: String, - a11y_is_grammar_error: String, - a11y_is_search_match: String, - a11y_is_suggestion: String, - a11y_role: String, - a11y_invalid: String, - a11y_toggled: String, - a11y_live: String, - a11y_default_action_verb: String, - a11y_orientation: String, - a11y_sort_direction: String, - a11y_current: String, - a11y_auto_complete: String, - a11y_has_popup: String, - a11y_list_style: String, - a11y_vertical_offset: String, + a11y_id, + a11y_focusable, + a11y_auto_focus, + a11y_name, + a11y_description, + a11y_value, + a11y_access_key, + a11y_author_id, + a11y_keyboard_shortcut, + a11y_language, + a11y_placeholder, + a11y_role_description, + a11y_state_description, + a11y_tooltip, + a11y_url, + a11y_row_index_text, + a11y_column_index_text, + a11y_scroll_x, + a11y_scroll_x_min, + a11y_scroll_x_max, + a11y_scroll_y, + a11y_scroll_y_min, + a11y_scroll_y_max, + a11y_numeric_value, + a11y_min_numeric_value, + a11y_max_numeric_value, + a11y_numeric_value_step, + a11y_numeric_value_jump, + a11y_row_count, + a11y_column_count, + a11y_row_index, + a11y_column_index, + a11y_row_span, + a11y_column_span, + a11y_level, + a11y_size_of_set, + a11y_position_in_set, + a11y_color_value, + a11y_expanded, + a11y_selected, + a11y_hovered, + a11y_hidden, + a11y_linked, + a11y_multiselectable, + a11y_required, + a11y_visited, + a11y_busy, + a11y_live_atomic, + a11y_modal, + a11y_touch_transparent, + a11y_read_only, + a11y_disabled, + a11y_is_spelling_error, + a11y_is_grammar_error, + a11y_is_search_match, + a11y_is_suggestion, + a11y_role, + a11y_invalid, + a11y_toggled, + a11y_live, + a11y_default_action_verb, + a11y_orientation, + a11y_sort_direction, + a11y_current, + a11y_auto_complete, + a11y_has_popup, + a11y_list_style, + a11y_vertical_offset, }; } From 6efc0adad0aeed6c00f8985b1e697baafbaacab0 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 15 Dec 2024 18:34:24 +0100 Subject: [PATCH 16/21] chore: Fix autocompletion --- crates/elements/src/definitions.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/elements/src/definitions.rs b/crates/elements/src/definitions.rs index 181167b25..9051cc8e2 100644 --- a/crates/elements/src/definitions.rs +++ b/crates/elements/src/definitions.rs @@ -57,9 +57,9 @@ macro_rules! impl_element { $( #[allow(non_camel_case_types)] $(#[$attr])* - pub struct $name; - - impl $name { + pub mod $name { + #[allow(unused)] + use super::*; #[doc(hidden)] pub const TAG_NAME: &'static str = stringify!($name); #[doc(hidden)] From c64c6ad4177efd97e2cbf06debe882148cd2c707 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sat, 21 Dec 2024 11:22:28 +0100 Subject: [PATCH 17/21] resolve conflicts --- crates/components/src/animated_position.rs | 2 +- crates/components/src/overflowed_content.rs | 2 +- crates/components/src/resizable_container.rs | 2 +- crates/elements/src/definitions.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/components/src/animated_position.rs b/crates/components/src/animated_position.rs index ab92316bd..91e06a947 100644 --- a/crates/components/src/animated_position.rs +++ b/crates/components/src/animated_position.rs @@ -1,7 +1,7 @@ use std::time::Duration; use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_animation_with_dependencies, use_node_signal_with_prev, diff --git a/crates/components/src/overflowed_content.rs b/crates/components/src/overflowed_content.rs index b411d1167..d4e586d25 100644 --- a/crates/components/src/overflowed_content.rs +++ b/crates/components/src/overflowed_content.rs @@ -1,7 +1,7 @@ use std::time::Duration; use dioxus::prelude::*; -use freya_elements::elements as dioxus_elements; +use freya_elements as dioxus_elements; use freya_hooks::{ use_animation, use_node_signal, diff --git a/crates/components/src/resizable_container.rs b/crates/components/src/resizable_container.rs index 204a1d2fb..7ebbc131d 100644 --- a/crates/components/src/resizable_container.rs +++ b/crates/components/src/resizable_container.rs @@ -1,7 +1,7 @@ use dioxus::prelude::*; use freya_common::NodeReferenceLayout; use freya_elements::{ - elements as dioxus_elements, + self as dioxus_elements, events::MouseEvent, }; use freya_hooks::{ diff --git a/crates/elements/src/definitions.rs b/crates/elements/src/definitions.rs index 432849c0f..86ba83987 100644 --- a/crates/elements/src/definitions.rs +++ b/crates/elements/src/definitions.rs @@ -342,7 +342,7 @@ builder_constructors! { opacity, // Reference - reference: Reference, + reference, // Accessibility a11y_id, From 36f9cae33b07836b4284c61883dbec4b9563a143 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Wed, 8 Jan 2025 14:35:28 +0100 Subject: [PATCH 18/21] chore: Fix memory leak of event handlers in the dioxus event macro definition as provided by @ealmloff --- Cargo.toml | 36 ++++++++++++++++-------------- crates/elements/Cargo.toml | 1 + crates/elements/src/definitions.rs | 12 +++++++--- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1bed72749..40f457e1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,15 +18,15 @@ disable-zoom-shortcuts = ["freya/disable-zoom-shortcuts"] docs = ["freya/docs"] # [patch.crates-io] -# dioxus = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } -# dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } -# dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } -# dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } -# dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } -# dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } -# dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } -# dioxus-lib = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } -# generational-box = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0" } +# dioxus = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" } +# dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" } +# dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" } +# dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" } +# dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" } +# dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" } +# dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" } +# dioxus-lib = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" } +# generational-box = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" } [workspace.dependencies] freya = { path = "crates/freya", version = "0.3.0-rc.0" } @@ -42,17 +42,19 @@ freya-testing = { path = "crates/testing", version = "0.3.0-rc.0" } freya-engine = { path = "crates/engine", version = "0.3.0-rc.0" } torin = { path = "crates/torin", version = "0.3.0-rc.0" } dioxus-clipboard = "0.2.0" +dioxus-i18n = "0.3" freya-native-core-macro = { path = "crates/native-core-macro", version = "0.3.0-rc.0" } freya-native-core = { path = "crates/native-core", version = "0.3.0-rc.0" } -dioxus = { version = "0.6.0", default-features = false, features = ["macro", "signals", "hooks"] } -dioxus-rsx = { version = "0.6.0" } -dioxus-core-macro = { version = "0.6.0" } -dioxus-hooks = { version = "0.6.0" } -dioxus-signals = { version = "0.6.0" } -dioxus-core = { version = "0.6.0" } -dioxus-router = { version = "0.6.0", default-features = false } +dioxus = { version = "0.6.1", default-features = false, features = ["macro", "signals", "hooks"] } +dioxus-rsx = { version = "0.6.1" } +dioxus-core-macro = { version = "0.6.1" } +dioxus-hooks = { version = "0.6.1" } +dioxus-signals = { version = "0.6.1" } +dioxus-core = { version = "0.6.1" } +generational-box = { version = "0.6.1" } +dioxus-router = { version = "0.6.1", default-features = false } skia-safe = { version = "0.80.0", features = ["gl", "textlayout", "svg"] } @@ -85,7 +87,7 @@ freya-core = { workspace = true } freya-testing = { workspace = true } reqwest = { version = "0.12.0", features = ["json"] } serde = "1.0.189" -dioxus-i18n = "0.3" +dioxus-i18n = { workspace = true } rand = "0.8.5" dioxus-router = { workspace = true } itertools = "0.13.0" diff --git a/crates/elements/Cargo.toml b/crates/elements/Cargo.toml index 8e8e97856..ee0f47997 100644 --- a/crates/elements/Cargo.toml +++ b/crates/elements/Cargo.toml @@ -14,6 +14,7 @@ categories = ["gui", "asynchronous"] [dependencies] torin = { workspace = true } +generational-box ={ workspace = true } dioxus-rsx = { workspace = true } dioxus-core = { workspace = true } diff --git a/crates/elements/src/definitions.rs b/crates/elements/src/definitions.rs index 86ba83987..d96be07b6 100644 --- a/crates/elements/src/definitions.rs +++ b/crates/elements/src/definitions.rs @@ -924,22 +924,28 @@ pub mod events { $( #[$attr] )* #[inline] pub fn $name<__Marker>(mut _f: impl ::dioxus_core::prelude::SuperInto<::dioxus_core::prelude::EventHandler<::dioxus_core::Event<$data>>, __Marker>) -> ::dioxus_core::Attribute { - let event_handler = _f.super_into(); + // super into will make a closure that is owned by the current owner (either the child component or the parent component). + // We can't change that behavior in a minor version because it would cause issues with Components that accept event handlers. + // Instead we run super into with an owner that is moved into the listener closure so it will be dropped when the closure is dropped. + let owner = <::generational_box::UnsyncStorage as ::generational_box::AnyStorage>::owner(); + let event_handler = ::dioxus_core::prelude::with_owner(owner.clone(), || _f.super_into()); ::dioxus_core::Attribute::new( impl_event!(@name $name $($event)?), ::dioxus_core::AttributeValue::listener(move |e: ::dioxus_core::Event| { + // Force the owner to be moved into the event handler + _ = &owner; event_handler.call(e.map(|e| e.into())); }), None, false, ).into() } - + #[doc(hidden)] $( #[$attr] )* pub mod $name { use super::*; - + // When expanding the macro, we use this version of the function if we see an inline closure to give better type inference $( #[$attr] )* pub fn call_with_explicit_closure< From 89e09173e85d6af2b1867e5db1b53a51634c3240 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Wed, 8 Jan 2025 14:44:54 +0100 Subject: [PATCH 19/21] chore: Hide elements events autocompletion modules in doc --- crates/elements/Cargo.toml | 3 +++ crates/elements/src/definitions.rs | 8 +++----- crates/freya/Cargo.toml | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/elements/Cargo.toml b/crates/elements/Cargo.toml index ee0f47997..be142b843 100644 --- a/crates/elements/Cargo.toml +++ b/crates/elements/Cargo.toml @@ -11,6 +11,9 @@ repository = "https://github.com/marc2332/freya" keywords = ["gui", "ui", "desktop", "skia", "dioxus"] categories = ["gui", "asynchronous"] +[features] +docs = [] + [dependencies] torin = { workspace = true } diff --git a/crates/elements/src/definitions.rs b/crates/elements/src/definitions.rs index d96be07b6..39ea1eb1a 100644 --- a/crates/elements/src/definitions.rs +++ b/crates/elements/src/definitions.rs @@ -940,12 +940,13 @@ pub mod events { false, ).into() } - + + #[cfg(not(feature = "docs"))] #[doc(hidden)] $( #[$attr] )* pub mod $name { use super::*; - + // When expanding the macro, we use this version of the function if we see an inline closure to give better type inference $( #[$attr] )* pub fn call_with_explicit_closure< @@ -961,9 +962,6 @@ pub mod events { )* }; - (@name $name:ident $event:literal) => { - $event - }; (@name $name:ident) => { stringify!($name) }; diff --git a/crates/freya/Cargo.toml b/crates/freya/Cargo.toml index 8d1de04f2..8d574e9d1 100644 --- a/crates/freya/Cargo.toml +++ b/crates/freya/Cargo.toml @@ -26,7 +26,7 @@ default = ["skia"] performance-overlay = [] fade-cached-incremental-areas = ["freya-core/fade-cached-incremental-areas"] disable-zoom-shortcuts = ["freya-renderer/disable-zoom-shortcuts"] -docs = ["dep:freya-testing", "dep:dioxus-i18n", "dep:dioxus-router"] +docs = ["dep:freya-testing", "dep:dioxus-i18n", "dep:dioxus-router", "freya-elements/docs"] [dependencies] freya-devtools = { workspace = true, optional = true } From d3f6090d89d87a96258490dd4d64b60ffd563496 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Wed, 8 Jan 2025 14:57:23 +0100 Subject: [PATCH 20/21] docs: Fix links --- crates/components/src/link.rs | 4 ++-- crates/components/src/resizable_container.rs | 10 +++++----- crates/components/src/tile.rs | 6 ++---- crates/elements/Cargo.toml | 5 +---- .../src/_docs/events/globalfilehovercancelled.md | 2 +- crates/elements/src/_docs/events/mousemove.md | 2 +- crates/elements/src/_docs/events/pointermove.md | 2 +- crates/elements/src/_docs/events/touchcancel.md | 2 +- crates/elements/src/definitions.rs | 1 - crates/freya/Cargo.toml | 2 +- crates/hooks/src/use_animation.rs | 2 +- 11 files changed, 16 insertions(+), 22 deletions(-) diff --git a/crates/components/src/link.rs b/crates/components/src/link.rs index 973b3cacd..7e88c5535 100644 --- a/crates/components/src/link.rs +++ b/crates/components/src/link.rs @@ -20,7 +20,7 @@ use crate::{ TooltipContainer, }; -/// Tooltip configuration for the [`Link`] component. +/// Tooltip configuration for the [`Link()`] component. #[derive(Clone, PartialEq)] pub enum LinkTooltip { /// No tooltip at all. @@ -34,7 +34,7 @@ pub enum LinkTooltip { Custom(String), } -/// Similar to [`Link`](dioxus_router::components::Link), but you can use it in Freya. +/// Similar to [`Link`](dioxus_router::components::Link()), but you can use it in Freya. /// Both internal routes (dioxus-router) and external links are supported. When using internal routes /// make sure the Link is descendant of a [`Router`](dioxus_router::components::Router) component. /// diff --git a/crates/components/src/resizable_container.rs b/crates/components/src/resizable_container.rs index 7ebbc131d..2840fc981 100644 --- a/crates/components/src/resizable_container.rs +++ b/crates/components/src/resizable_container.rs @@ -47,7 +47,7 @@ struct ResizableContext { pub direction: String, } -/// Resizable container, used in combination with [ResizablePanel] and [ResizableHandle]. +/// Resizable container, used in combination with [ResizablePanel()] and [ResizableHandle()]. /// /// Example: /// @@ -81,7 +81,7 @@ pub fn ResizableContainer( /// Default to `vertical`. #[props(default = "vertical".to_string())] direction: String, - /// Inner children for the [ResizableContainer]. + /// Inner children for the [ResizableContainer()]. children: Element, ) -> Element { let (node_reference, size) = use_node_signal(); @@ -106,7 +106,7 @@ pub fn ResizableContainer( ) } -/// Resizable panel to be used in combination with [ResizableContainer] and [ResizableHandle]. +/// Resizable panel to be used in combination with [ResizableContainer()] and [ResizableHandle()]. #[component] pub fn ResizablePanel( /// Initial size in % for this panel. Default to `10`. @@ -115,7 +115,7 @@ pub fn ResizablePanel( /// Minimum size in % for this panel. Default to `4`. #[props(default = 4.)] min_size: f32, - /// Inner children for the [ResizablePanel]. + /// Inner children for the [ResizablePanel()]. children: Element, ) -> Element { let mut registry = use_context::>(); @@ -157,7 +157,7 @@ pub enum HandleStatus { Hovering, } -/// Resizable panel to be used in combination with [ResizableContainer] and [ResizablePanel]. +/// Resizable panel to be used in combination with [ResizableContainer()] and [ResizablePanel()]. #[component] pub fn ResizableHandle( /// Theme override. diff --git a/crates/components/src/tile.rs b/crates/components/src/tile.rs index a02f90a55..3e12fbf5b 100644 --- a/crates/components/src/tile.rs +++ b/crates/components/src/tile.rs @@ -25,19 +25,17 @@ pub enum TileStatus { Hovering, } -/// Tile component to be used with [`Radio`] and [`Checkbox`]. +/// Tile component to be used with [`Radio`](crate::Radio()) and [`Checkbox`](crate::Checkbox()). /// # Styling /// Inherits the [`TileTheme`](freya_hooks::TileTheme) theme. /// /// # Example -/// -/// Tile is meant to be used with other components, take a look at [`Radio`](crate::Radio) for instance. #[allow(non_snake_case)] #[component] pub fn Tile( /// Inner children for the Tile. children: Element, - /// Optional element to be placed before the inner children of the Tile. Such as a [`Radio`](crate::Radio) + /// Optional element to be placed before the inner children of the Tile. Such as a [`Radio`](crate::Radio()) leading: Option, /// Event handler for when the Tile is selected, e.g when clicking on it. onselect: Option>, diff --git a/crates/elements/Cargo.toml b/crates/elements/Cargo.toml index be142b843..95493201f 100644 --- a/crates/elements/Cargo.toml +++ b/crates/elements/Cargo.toml @@ -11,13 +11,10 @@ repository = "https://github.com/marc2332/freya" keywords = ["gui", "ui", "desktop", "skia", "dioxus"] categories = ["gui", "asynchronous"] -[features] -docs = [] - [dependencies] torin = { workspace = true } -generational-box ={ workspace = true } +generational-box = { workspace = true } dioxus-rsx = { workspace = true } dioxus-core = { workspace = true } diff --git a/crates/elements/src/_docs/events/globalfilehovercancelled.md b/crates/elements/src/_docs/events/globalfilehovercancelled.md index ab6a91bc2..93442bddd 100644 --- a/crates/elements/src/_docs/events/globalfilehovercancelled.md +++ b/crates/elements/src/_docs/events/globalfilehovercancelled.md @@ -1,4 +1,4 @@ -The `onglobalfilehovercancelled` event fires when the user cancels the hovering of a file over the window. It's the opposite of [`onglobalfilehover`](crate::elements::onglobalfilehover). +The `onglobalfilehovercancelled` event fires when the user cancels the hovering of a file over the window. It's the opposite of [`onglobalfilehover`](crate::elements::onglobalfilehover()). Event Data: [`FileData`](crate::events::FileData) diff --git a/crates/elements/src/_docs/events/mousemove.md b/crates/elements/src/_docs/events/mousemove.md index 0eacd6b38..86b354d47 100644 --- a/crates/elements/src/_docs/events/mousemove.md +++ b/crates/elements/src/_docs/events/mousemove.md @@ -1,5 +1,5 @@ The `mousemove` event fires when the user moves the mouse over an element. -Unlike [`onmouseenter`](crate::elements::onmouseenter), this fires even if the user was already hovering over +Unlike [`onmouseenter`](crate::elements::onmouseenter()), this fires even if the user was already hovering over the element. For that reason, it's less efficient. Event Data: [`MouseData`](crate::events::MouseData) diff --git a/crates/elements/src/_docs/events/pointermove.md b/crates/elements/src/_docs/events/pointermove.md index b6f1afd6d..7c03b2066 100644 --- a/crates/elements/src/_docs/events/pointermove.md +++ b/crates/elements/src/_docs/events/pointermove.md @@ -1,5 +1,5 @@ The `pointermove` event fires when the user moves the cursor or touches over an element. -Unlike [`onpointerenter`](crate::elements::onpointerenter), this fires even if the user was already hovering over +Unlike [`onpointerenter`](crate::elements::onpointerenter()), this fires even if the user was already hovering over the element. Event Data: [`PointerData`](crate::events::PointerData) diff --git a/crates/elements/src/_docs/events/touchcancel.md b/crates/elements/src/_docs/events/touchcancel.md index a6ee9a133..59c94e838 100644 --- a/crates/elements/src/_docs/events/touchcancel.md +++ b/crates/elements/src/_docs/events/touchcancel.md @@ -1,5 +1,5 @@ The `touchcancel` event fires when the user cancels the touching, this is usually caused by the hardware or the OS. -Also see [`ontouchend`](crate::elements::ontouchend). +Also see [`ontouchend`](crate::elements::ontouchend()). Event Data: [`TouchData`](crate::events::TouchData) diff --git a/crates/elements/src/definitions.rs b/crates/elements/src/definitions.rs index 39ea1eb1a..c6e5d767b 100644 --- a/crates/elements/src/definitions.rs +++ b/crates/elements/src/definitions.rs @@ -941,7 +941,6 @@ pub mod events { ).into() } - #[cfg(not(feature = "docs"))] #[doc(hidden)] $( #[$attr] )* pub mod $name { diff --git a/crates/freya/Cargo.toml b/crates/freya/Cargo.toml index 8d574e9d1..8d1de04f2 100644 --- a/crates/freya/Cargo.toml +++ b/crates/freya/Cargo.toml @@ -26,7 +26,7 @@ default = ["skia"] performance-overlay = [] fade-cached-incremental-areas = ["freya-core/fade-cached-incremental-areas"] disable-zoom-shortcuts = ["freya-renderer/disable-zoom-shortcuts"] -docs = ["dep:freya-testing", "dep:dioxus-i18n", "dep:dioxus-router", "freya-elements/docs"] +docs = ["dep:freya-testing", "dep:dioxus-i18n", "dep:dioxus-router"] [dependencies] freya-devtools = { workspace = true, optional = true } diff --git a/crates/hooks/src/use_animation.rs b/crates/hooks/src/use_animation.rs index d3eef721e..064b3e3af 100644 --- a/crates/hooks/src/use_animation.rs +++ b/crates/hooks/src/use_animation.rs @@ -661,7 +661,7 @@ impl UseAnimator { /// } /// ``` /// -/// You can also tweak what to do once the animation has finished with [`Context::on_finish`]. +/// You can also tweak what to do once the animation has finished with [`AnimationContext::on_finish`]. /// /// ```rust,no_run /// # use freya::prelude::*; From 79983415f122542b34318811fcd9b175bdfc263d Mon Sep 17 00:00:00 2001 From: marc2332 Date: Wed, 8 Jan 2025 15:06:32 +0100 Subject: [PATCH 21/21] docs: Replace Option::None with Ok(VNode::placeholder()) --- crates/freya/src/_docs/hooks.rs | 8 ++++---- crates/freya/src/_docs/state_management/context.rs | 2 +- crates/freya/src/_docs/state_management/lifecycle.rs | 8 ++++---- crates/freya/src/_docs/ui.rs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/freya/src/_docs/hooks.rs b/crates/freya/src/_docs/hooks.rs index 113b2c660..8c9f0b566 100644 --- a/crates/freya/src/_docs/hooks.rs +++ b/crates/freya/src/_docs/hooks.rs @@ -24,7 +24,7 @@ //! true //! }; //! -//! None +//! Ok(VNode::placeholder()) //! } //! ``` //! @@ -35,7 +35,7 @@ //! fn MyComponent(initial_value: bool) -> Element { //! let is_enabled = use_signal(move || initial_value); //! -//! None +//! Ok(VNode::placeholder()) //! } //! ``` //! @@ -94,7 +94,7 @@ //! let state = use_signal(|| i); //! } //! -//! None +//! Ok(VNode::placeholder()) //! } //! ``` //! @@ -105,6 +105,6 @@ //! fn MyComponent() -> Element { //! let state = use_signal(|| (0..5).into_iter().collect::>()); //! -//! None +//! Ok(VNode::placeholder()) //! } //! ``` diff --git a/crates/freya/src/_docs/state_management/context.rs b/crates/freya/src/_docs/state_management/context.rs index f407aed62..d10a92f2e 100644 --- a/crates/freya/src/_docs/state_management/context.rs +++ b/crates/freya/src/_docs/state_management/context.rs @@ -117,7 +117,7 @@ //! //! # #[component] //! # fn CompB() -> Element { -//! # None +//! # Ok(VNode::placeholder()) //! # } //! ``` //! diff --git a/crates/freya/src/_docs/state_management/lifecycle.rs b/crates/freya/src/_docs/state_management/lifecycle.rs index 54163e164..99f7d8359 100644 --- a/crates/freya/src/_docs/state_management/lifecycle.rs +++ b/crates/freya/src/_docs/state_management/lifecycle.rs @@ -12,7 +12,7 @@ //! println!("Component running for the first time!"); //! }); //! -//! None +//! Ok(VNode::placeholder()) //! } //! ``` //! @@ -27,7 +27,7 @@ //! println!("Component is being dropped."); //! }); //! -//! None +//! Ok(VNode::placeholder()) //! } //! ``` //! @@ -47,7 +47,7 @@ //! println!("Value of signal is {value}"); //! }); //! -//! None +//! Ok(VNode::placeholder()) //! } //! ``` //! @@ -74,6 +74,6 @@ //! }, //! )); //! -//! None +//! Ok(VNode::placeholder()) //! } //! ``` diff --git a/crates/freya/src/_docs/ui.rs b/crates/freya/src/_docs/ui.rs index 59a52d763..08497f10b 100644 --- a/crates/freya/src/_docs/ui.rs +++ b/crates/freya/src/_docs/ui.rs @@ -54,7 +54,7 @@ //! # )}; //! //! # #[component] -//! # fn CoolComp(prop: i32) -> Element { None } +//! # fn CoolComp(prop: i32) -> Element { Ok(VNode::placeholder()) } //! ``` //! //! You can reference variables inside the RSX as well: