euv_ui/component/debug/view/struct.rs
1use super::*;
2
3/// Props for the `euv_debug` component.
4///
5/// Defines the strongly-typed interface for the dev-only Debug
6/// readout. The component renders a labeled `<pre data-euv-debug>`
7/// block whose body is the result of invoking `value` on every
8/// render, so users can inspect reactive state without breaking
9/// out of the component tree.
10///
11/// `value` is wrapped in `Option<DebugValueFormatter>` (rather
12/// than `DebugValueFormatter` directly) so the struct can
13/// derive `Default` — the upstream `#[derive(New)]` macro
14/// expects every props struct to also be `Default` (it generates
15/// `X::new(...)` AND `X::default()` from the same field list).
16/// A bare `Rc<dyn Fn() -> String>` has no `Default` impl (you
17/// cannot synthesise an arbitrary formatter), so wrapping in
18/// `Option` keeps the derive happy and gives us a sensible
19/// "no formatter configured" fallback.
20#[derive(Clone, CustomDebug, Data, Default, New)]
21pub struct EuvDebugProps {
22 /// Short label printed before the value (e.g. "count", "user").
23 /// Rendered as `<span data-euv-debug-label>{label}</span>` so
24 /// styling hooks (`[data-euv-debug-label]`) can target it
25 /// independently from the value.
26 #[get(type(copy))]
27 pub label: &'static str,
28 /// Optional closure that produces the displayable string.
29 /// Runs on every render — typically the body reads one or
30 /// more `Signal<T>::get()` values to subscribe the readout
31 /// to live state. `None` renders an empty placeholder so the
32 /// caller can still construct the component without a
33 /// formatter (handy in tests and stub components).
34 #[debug(skip)]
35 pub value: Option<DebugValueFormatter>,
36 /// When `true`, the value is rendered inside `<pre>` with
37 /// `white-space: pre-wrap` so multi-line strings (JSON,
38 /// stack traces) preserve formatting. When `false`, the
39 /// value is rendered inside a single-line `<code>`.
40 #[get(type(copy))]
41 pub expanded: bool,
42}