euv_ui/hook/use_id/struct.rs
1use super::*;
2
3/// A stable, unique identifier for one mounted component.
4///
5/// The identifier is generated once, on the first render, and never
6/// changes afterwards: every re-render at the same hook index returns
7/// the same [`UseId`], and the value it carries is the same string.
8///
9/// The value is shaped `<prefix>-<counter>`, where `counter` is a
10/// process-wide monotonically increasing number. The prefix lets a
11/// caller keep the identifiers of different kinds apart in the DOM
12/// (`field-1`, `field-2`, `panel-1`), which is what makes them
13/// readable in devtools and in accessibility audits.
14///
15/// # Arguments
16///
17/// - `&'static str` - The prefix put in front of the counter.
18#[derive(Clone, Data, Debug, New)]
19pub struct UseId {
20 /// The generated identifier.
21 ///
22 /// Defaults to `Signal::create(String::default())` via
23 /// `#[new(skip)]`; the hook fills it with the generated value
24 /// immediately afterwards.
25 #[new(skip)]
26 #[get(type(copy))]
27 pub value: Signal<String>,
28}