#![deny(unsafe_op_in_unsafe_fn)]
pub mod asset;
pub mod boundary;
#[cfg(target_os = "android")]
#[path = "boundary_jni.gen.rs"]
mod boundary_jni;
#[cfg(target_family = "wasm")]
#[path = "boundary_wasm.gen.rs"]
mod boundary_wasm;
pub mod brush;
#[cfg(target_family = "wasm")]
#[doc(hidden)]
pub use boundary_wasm::web_start as __web_start;
#[doc(hidden)]
pub mod codegen;
pub mod design;
pub mod drawing;
mod extensions;
pub mod message;
pub mod protocol;
pub mod renderer;
pub mod schema;
pub mod spans;
pub mod tokens;
mod widgets;
pub mod window;
pub use asset::asset;
pub use boundary::{
Host, LaunchBuilder, MutationBatch, RendererApi, demo_theme, demo_theme_for,
install_renderer_api, launch, request_frame_from_worker,
};
pub use dioxus_core::{Element, VirtualDom};
pub use brush::{Brush, Stop, brush};
pub use design::{design_system, use_design_system};
pub use dioxus_core_macro::{Props, component, rsx};
pub use drawing::{DrawCommand, DrawList, DrawListBuilder};
pub use elements::*;
pub use extensions::LinearProgressIndicator;
pub use message::{Message, show_message};
pub use schema::{
Alignment, Arrangement, AssetKind, ButtonVariant, Chrome, Color, ColorRole, ColorScheme,
DesignSystem, EventPayload, IconRole, Key, LoopMode, MaterialRole, MessageDuration, Modifier,
MotionRole, Paint, PropertyKind, SCHEMA_HASH, Selection, ShapeRole, SpaceRole, TextAlign,
TextOverflow, Theme, TileMode, TypeRole, WidgetKind, WindowHeightClass, WindowSizeClass,
};
pub use widgets::{
Badge, Button, Canvas, Card, Checkbox, Column, ComposeBox as Box, DatePicker, Dialog, Divider,
Dropdown, FileDrop, FileDropTarget, Icon, Image, KeyEvent, LazyColumn, LazyGrid, LazyRow, Menu,
Navigation, NavigationItem, ProgressIndicator, RadioButton, RangeRequest, Row, Scaffold,
ScrollColumn, SelectionContainer, Separator, Sheet, Slider, Spacer, Surface, Switch, Tabs,
Text, TextField, TimePicker, Tooltip, TopAppBar,
};
pub use window::{NodeSize, WindowSize, node_size, use_node_size, use_window_size, window_size};
#[macro_export]
macro_rules! android_main {
($app:path) => {
$crate::android_main!($crate::LaunchBuilder::new(), $app);
};
($builder:expr, $app:path) => {
#[unsafe(no_mangle)]
pub extern "C" fn dioxus_compose_android_main() {
$builder.with_mode($crate::LoopMode::Platform).launch($app);
}
};
}
#[macro_export]
macro_rules! ios_main {
($launch:path) => {
#[unsafe(no_mangle)]
pub extern "C" fn dioxus_compose_ios_main() -> i32 {
$launch();
0
}
};
}
#[macro_export]
macro_rules! web_main {
($app:path) => {
$crate::web_main!($crate::LaunchBuilder::new(), $app);
};
($builder:expr, $app:path) => {
#[cfg(target_family = "wasm")]
#[unsafe(no_mangle)]
pub extern "C" fn dioxus_compose_host_web_start() -> u32 {
$crate::__web_start($builder, $app)
}
#[cfg(not(target_family = "wasm"))]
#[unsafe(no_mangle)]
pub extern "C" fn dioxus_compose_host_web_start() -> u32 {
let _: fn() -> $crate::Element = $app;
let _ = $builder;
0
}
};
}
pub mod prelude {
pub use crate as dioxus_elements;
pub use crate::{
Alignment, Arrangement, AssetKind, Badge, Brush, Button, ButtonVariant, Canvas, Card,
Checkbox, Color, ColorRole, ColorScheme, Column, DatePicker, DesignSystem, Dialog, Divider,
DrawCommand, DrawList, Dropdown, Element, FileDrop, FileDropTarget, Icon, IconRole, Image,
Key, KeyEvent, LaunchBuilder, LazyColumn, LazyGrid, LazyRow, LinearProgressIndicator,
LoopMode, MaterialRole, Menu, Message, MessageDuration, Modifier, MotionRole, Navigation,
NavigationItem, Paint, ProgressIndicator, Props, RadioButton, RangeRequest, Row, Scaffold,
ScrollColumn, SelectionContainer, Separator, ShapeRole, Sheet, Slider, SpaceRole, Spacer,
Stop, Surface, Switch, Tabs, Text, TextAlign, TextField, TextOverflow, Theme, TileMode,
TimePicker, Tooltip, TopAppBar, TypeRole, WindowHeightClass, WindowSize, WindowSizeClass,
asset, brush, component, launch, rsx, show_message, use_design_system, use_node_size,
use_window_size,
};
pub use crate::schema::{Chrome, Window};
pub use dioxus_core;
pub use dioxus_signals;
pub use dioxus_core::{Callback, Event, EventHandler, Properties, VirtualDom, use_hook};
pub use dioxus_hooks::*;
pub use dioxus_signals::*;
}
pub mod elements {
#![allow(non_upper_case_globals)]
pub type AttributeDescription = (&'static str, Option<&'static str>, bool);
pub use crate::extensions::elements::*;
macro_rules! modifier_attributes {
() => {
pub const weight: AttributeDescription = ("weight", None, false);
pub const fill_max_width: AttributeDescription = ("fill_max_width", None, false);
pub const fill_max_height: AttributeDescription = ("fill_max_height", None, false);
pub const width: AttributeDescription = ("width", None, false);
pub const height: AttributeDescription = ("height", None, false);
pub const padding: AttributeDescription = ("padding", None, false);
pub const padding_role: AttributeDescription = ("padding_role", None, false);
pub const background: AttributeDescription = ("background", None, false);
pub const shape_role: AttributeDescription = ("shape_role", None, false);
pub const corner_radius: AttributeDescription = ("corner_radius", None, false);
pub const border_width: AttributeDescription = ("border_width", None, false);
pub const border_color: AttributeDescription = ("border_color", None, false);
pub const elevation: AttributeDescription = ("elevation", None, false);
pub const onclickable: AttributeDescription = ("onclickable", None, false);
pub const observe_size: AttributeDescription = ("observe_size", None, false);
pub const motion: AttributeDescription = ("motion", None, false);
pub const material: AttributeDescription = ("material", None, false);
pub const onfilesentered: AttributeDescription = ("onfilesentered", None, false);
pub const onfilesdropped: AttributeDescription = ("onfilesdropped", None, false);
};
}
macro_rules! element {
($module:ident, $tag:literal, []) => {
pub mod $module {
use super::AttributeDescription;
pub const TAG_NAME: &str = $tag;
pub const NAME_SPACE: Option<&str> = None;
modifier_attributes!();
}
};
($module:ident, $tag:literal, [$($attribute:ident),* $(,)?]) => {
pub mod $module {
use super::AttributeDescription;
pub const TAG_NAME: &str = $tag;
pub const NAME_SPACE: Option<&str> = None;
$(pub const $attribute: AttributeDescription = (stringify!($attribute), None, false);)*
modifier_attributes!();
}
};
}
element!(
column,
"Column",
[arrangement, spacing, space_role, alignment]
);
element!(row, "Row", [arrangement, spacing, space_role, alignment]);
element!(composebox, "Box", [item_key, alignment]);
element!(
text,
"Text",
[
text,
spans,
type_role,
font_size,
font_weight,
line_height,
letter_spacing,
color,
text_align,
max_lines,
overflow
]
);
element!(
textfield,
"TextField",
[placeholder, enabled, multiline, type_role]
);
element!(button, "Button", [text, icon, enabled, variant, color]);
element!(spacer, "Spacer", []);
element!(lazycolumn, "LazyColumn", [item_count]);
element!(image, "Image", [asset]);
element!(icon, "Icon", [asset, color]);
element!(checkbox, "Checkbox", [checked, enabled]);
element!(radiobutton, "RadioButton", [checked, enabled]);
element!(switch, "Switch", [checked, enabled]);
element!(slider, "Slider", [value, min, max, steps, enabled, color]);
element!(
progressindicator,
"ProgressIndicator",
[value, determinate, circular]
);
element!(divider, "Divider", [vertical]);
element!(card, "Card", []);
element!(surface, "Surface", []);
element!(dialog, "Dialog", [open]);
element!(menu, "Menu", [open]);
element!(tabs, "Tabs", [selected_index, color]);
element!(topappbar, "TopAppBar", [text]);
element!(lazyrow, "LazyRow", [item_count]);
element!(tooltip, "Tooltip", [text]);
element!(canvas, "Canvas", [commands]);
element!(datepicker, "DatePicker", [value, min, max, enabled]);
element!(timepicker, "TimePicker", [value, min, max, enabled]);
element!(dropdown, "Dropdown", [selected_index, enabled]);
element!(scrollcolumn, "ScrollColumn", []);
element!(navigation, "Navigation", [selected_index]);
element!(
navigationitem,
"NavigationItem",
[text, icon, color, enabled, section]
);
element!(sheet, "Sheet", [open]);
element!(scaffold, "Scaffold", []);
element!(scaffoldslot, "ScaffoldSlot", [slot]);
element!(
lazygrid,
"LazyGrid",
[item_count, columns, min_column_width]
);
element!(filedroptarget, "FileDropTarget", [alignment]);
element!(badge, "Badge", [count, text, color]);
element!(selectioncontainer, "SelectionContainer", []);
#[doc(hidden)]
pub mod completions {
#[allow(non_camel_case_types)]
pub enum CompleteWithBraces {
column {},
scaffold {},
lazygrid {},
scaffoldslot {},
row {},
composebox {},
text {},
textfield {},
button {},
spacer {},
lazycolumn {},
scrollcolumn {},
checkbox {},
radiobutton {},
switch {},
slider {},
progressindicator {},
divider {},
card {},
surface {},
dialog {},
menu {},
tabs {},
topappbar {},
lazyrow {},
tooltip {},
canvas {},
image {},
icon {},
datepicker {},
timepicker {},
dropdown {},
navigation {},
navigationitem {},
sheet {},
badge {},
selectioncontainer {},
}
}
}
pub mod events {
use dioxus_core::{Attribute, Event, ListenerCallback, SpawnIfAsync, SuperInto};
macro_rules! event {
($name:ident, $data:ty) => {
pub fn $name<Marker>(
handler: impl SuperInto<ListenerCallback<$data>, Marker>,
) -> Attribute {
Attribute::new(stringify!($name), handler.super_into(), None, false)
}
pub mod $name {
use super::*;
pub fn call_with_explicit_closure<Marker, Return>(
handler: impl FnMut(Event<$data>) -> Return + 'static,
) -> Attribute
where
Return: SpawnIfAsync<Marker> + 'static,
{
Attribute::new(
stringify!($name),
ListenerCallback::new(handler),
None,
false,
)
}
}
};
}
event!(onclick, ());
event!(onvaluechange, String);
event!(onsubmit, String);
event!(onfocuslost, ());
event!(onkeydown, crate::KeyEvent);
event!(onrangerequest, crate::RangeRequest);
event!(ondismiss, ());
event!(onfilesentered, ());
event!(onfilesdropped, crate::FileDrop);
event!(onchange, f64);
}