diff --git a/demo_markdown/docs/input_number/mod.md b/demo_markdown/docs/input_number/mod.md index 2bcf3fe..c077498 100644 --- a/demo_markdown/docs/input_number/mod.md +++ b/demo_markdown/docs/input_number/mod.md @@ -47,3 +47,10 @@ view! { #### T impl `T: Add + Sub + Default + Clone + FromStr + ToString + 'static` + +### InputNumber Ref + +| Name | Type | Description | +| ----- | ----------- | ------------------------ | +| focus | `Fn(&self)` | Focus the input element. | +| blur | `Fn(&self)` | Blur the input element. | \ No newline at end of file diff --git a/thaw/src/input_number/mod.rs b/thaw/src/input_number/mod.rs index ee993c7..82a3a06 100644 --- a/thaw/src/input_number/mod.rs +++ b/thaw/src/input_number/mod.rs @@ -1,5 +1,5 @@ use crate::utils::StoredMaybeSignal; -use crate::{AiIcon, Button, ButtonVariant, Icon, Input, InputSuffix}; +use crate::{AiIcon, Button, ButtonVariant, ComponentRef, Icon, Input, InputRef, InputSuffix}; use leptos::*; use std::ops::{Add, Sub}; use std::str::FromStr; @@ -12,6 +12,7 @@ pub fn InputNumber( #[prop(optional, into)] disabled: MaybeSignal, #[prop(optional, into)] invalid: MaybeSignal, #[prop(optional, into)] class: MaybeSignal, + #[prop(optional)] comp_ref: ComponentRef, #[prop(attrs)] attrs: Vec<(&'static str, Attribute)>, ) -> impl IntoView where @@ -47,8 +48,23 @@ where e.prevent_default(); value.set(value.get_untracked() - step.get_untracked()); }); + + let input_ref = ComponentRef::::new(); + input_ref.on_load(move |_| { + comp_ref.load(InputNumberRef { input_ref }); + }); + view! { - +