Skip to main content

NumericEditor

Function NumericEditor 

Source
pub fn NumericEditor(props: NumericEditorProps) -> Element
Expand description

Renders an exact, localized controlled numeric editor.

Focus retains the originating locale and equivalent spelling. Blur restores the latest effective value without submitting. Blur clears discarded lexical/range errors, but retains unresolved locale, support, and event-source failures. Replacing id or kind retires the old instance; use a different key when replacing the underlying model.

Native capture supports selected/collapsed composition spans and expansions exposed by synchronous beforeinput selection. A native mutation outside that span without authoritative range metadata reports InputError::EventSource without guessing a write (range generalization: issue #280). Native composition terminal echoes use composition input metadata, not text equality alone.

  • Complexity: O(value + draft + locale bytes) per transition.

ยงExamples

use adam_web_ui::{components::NumericEditor, input::NumberKind};
use dioxus::prelude::*;
fn app() -> Element {
    let mut value = use_signal(|| Some("12".to_string()));
    let range = use_signal(|| None);
    let flags = use_signal(|| false);
    rsx! { NumericEditor {
        id: "amount", label: "Amount", value, range, kind: NumberKind::Signed(32),
        step: "1", disabled: flags, readonly: flags, invalid: flags,
        locale: None, optional: false,
        on_value: move |v| value.set(v), on_error: |_| {},
    } }
}