| Crates.io | hyperchad_transformer_models |
| lib.rs | hyperchad_transformer_models |
| version | 0.1.4 |
| created_at | 2025-05-07 13:28:06.104951+00 |
| updated_at | 2025-07-21 20:02:56.143403+00 |
| description | HyperChad transformer models package |
| homepage | |
| repository | https://github.com/MoosicBox/MoosicBox |
| max_upload_size | |
| id | 1663849 |
| size | 35,949 |
Core data models and types for HyperChad UI transformations and layout.
The HyperChad Transformer Models package provides:
layout feature)Add this to your Cargo.toml:
[dependencies]
hyperchad_transformer_models = { path = "../hyperchad/transformer/models" }
# Enable additional features
hyperchad_transformer_models = {
path = "../hyperchad/transformer/models",
features = ["serde", "layout", "arb"]
}
use hyperchad_transformer_models::{
LayoutDirection, LayoutOverflow, JustifyContent, AlignItems
};
// Configure layout
let direction = LayoutDirection::Row;
let overflow = LayoutOverflow::Wrap { grid: true };
let justify = JustifyContent::SpaceBetween;
let align = AlignItems::Center;
println!("Layout: {} {} {} {}", direction, overflow, justify, align);
// Output: "Layout: row wrap-grid space-between center"
use hyperchad_transformer_models::{
TextAlign, TextDecorationLine, TextDecorationStyle
};
// Text configuration
let align = TextAlign::Center;
let decoration = TextDecorationLine::Underline;
let style = TextDecorationStyle::Dashed;
println!("Text: {} {} {}", align, decoration, style);
// Output: "Text: center underline dashed"
use hyperchad_transformer_models::{Visibility, Position, Cursor};
// Visual configuration
let visibility = Visibility::Visible;
let position = Position::Relative;
let cursor = Cursor::Pointer;
println!("Visual: {} {} {}", visibility, position, cursor);
// Output: "Visual: visible relative pointer"
use hyperchad_transformer_models::{ImageLoading, ImageFit};
// Image settings
let loading = ImageLoading::Lazy;
let fit = ImageFit::Cover;
println!("Image: {} {}", loading, fit);
// Output: "Image: lazy cover"
use hyperchad_transformer_models::{Route, SwapTarget};
// Define routes
let get_route = Route::Get {
route: "/api/data".to_string(),
trigger: Some("click".to_string()),
swap: SwapTarget::This,
};
let post_route = Route::Post {
route: "/api/submit".to_string(),
trigger: Some("submit".to_string()),
swap: SwapTarget::Id("result".to_string()),
};
use hyperchad_transformer_models::LinkTarget;
// Link target configurations
let self_target = LinkTarget::SelfTarget;
let blank_target = LinkTarget::Blank;
let custom_target = LinkTarget::Custom("custom-frame".to_string());
println!("Targets: {} {} {}", self_target, blank_target, custom_target);
// Output: "Targets: _self _blank custom-frame"
layout feature)#[cfg(feature = "layout")]
use hyperchad_transformer_models::LayoutPosition;
#[cfg(feature = "layout")]
{
// Grid positioning
let position = LayoutPosition::Wrap { row: 2, col: 3 };
println!("Row: {:?}", position.row()); // Some(2)
println!("Column: {:?}", position.column()); // Some(3)
}
All models implement Display for CSS-compatible string output:
use hyperchad_transformer_models::*;
// All models convert to CSS-compatible strings
assert_eq!(LayoutDirection::Row.to_string(), "row");
assert_eq!(JustifyContent::SpaceBetween.to_string(), "space-between");
assert_eq!(TextAlign::Center.to_string(), "center");
assert_eq!(Cursor::Pointer.to_string(), "pointer");
serde: Enable serialization/deserializationlayout: Enable layout positioning modelsarb: Enable arbitrary data generation for testingThis package is designed for: