#![allow(unreachable_pub, dead_code)]
use leptos::prelude::*;
use canonrs_core::primitives::{InputOtpPrimitive, InputOtpSlotPrimitive, InputOtpContainerPrimitive, InputOtpSlotsPrimitive};
use canonrs_core::meta::{ActivityState, DisabledState};
#[component]
pub fn InputOtp(#[prop(into, default = String::new())] class: String, #[prop(into, default = String::new())] name: String, #[prop(into, default = String::new())] value: String, #[prop(default = DisabledState::Enabled)] disabled: DisabledState, #[prop(default = 6u32)] length: u32) -> impl IntoView {
let is_disabled = disabled == DisabledState::Disabled;
let slots: Vec<AnyView> = (0..length).map(|i| {
let ch = value.chars().nth(i as usize).map(|c| c.to_string()).unwrap_or_default();
let state = if !is_disabled && i == value.len() as u32 { ActivityState::Active } else { ActivityState::Inactive };
view! { <InputOtpSlotPrimitive state=state>{ch}</InputOtpSlotPrimitive> }.into_any()
}).collect();
view! {
<InputOtpContainerPrimitive disabled=disabled.disabled() class=class>
<InputOtpPrimitive name=name value=value.clone() disabled=disabled maxlength=length inputmode="numeric".to_string() autocomplete="one-time-code".to_string() />
<InputOtpSlotsPrimitive>{slots}</InputOtpSlotsPrimitive>
</InputOtpContainerPrimitive>
}
}