Skip to main content

dioxus_dnd/core/components/
mod.rs

1#![doc = include_str!("../../../docs/api/drag-and-drop.md")]
2
3use dioxus::prelude::*;
4
5mod delivery;
6mod draggable;
7mod drop_zone;
8mod overlay;
9mod pointer;
10mod provider;
11
12pub use draggable::Draggable;
13pub use drop_zone::{BridgeDropZone, DropZone, ParentZone};
14pub use overlay::{DragOverlay, SettleSlot};
15pub use provider::DndProvider;
16
17pub(crate) use delivery::{deliver_drop, DropCompletion, SettleRoute, RELEASE_RECOVERY_MOVES};
18pub(crate) use overlay::overlay_style;
19pub(crate) use pointer::{primary_press, touch_style, HoldTimer};
20
21/// Pull a user-provided `style` out of forwarded attributes and append it to
22/// a functional inline style. Spread attributes land after static ones and
23/// replace them wholesale, so without this a caller passing any `style`
24/// would silently delete functional CSS (`touch-action`, overlay
25/// positioning). The user's declarations come last, so they still win on a
26/// per-property basis.
27pub(crate) fn merge_style(attributes: &mut Vec<Attribute>, functional: &str) -> String {
28    let user = attributes
29        .iter()
30        .position(|a| a.name == "style")
31        .map(|i| attributes.remove(i));
32    match user.map(|a| a.value) {
33        Some(dioxus::core::AttributeValue::Text(s)) => format!("{functional} {s}"),
34        _ => functional.to_string(),
35    }
36}