use crate::{AttrMap, BasecoatProps, Children};
use std::borrow::Cow;
#[derive(Clone, Debug, Default)]
pub struct SelectOption {
pub value: Cow<'static, str>,
pub label: Cow<'static, str>,
pub disabled: bool,
}
impl SelectOption {
pub fn new(
value: impl Into<Cow<'static, str>>,
label: impl Into<Cow<'static, str>>,
) -> Self {
Self {
value: value.into(),
label: label.into(),
disabled: false,
}
}
pub fn disabled(mut self) -> Self {
self.disabled = true;
self
}
}
#[derive(BasecoatProps, Default, Clone, Debug)]
pub struct SelectProps {
#[prop(optional, into)]
pub id: Option<Cow<'static, str>>,
#[prop(optional, into)]
pub name: Option<Cow<'static, str>>,
#[prop(optional, into)]
pub label: Option<Cow<'static, str>>,
#[prop(optional, into)]
pub value: Option<Cow<'static, str>>,
#[prop(optional, into)]
pub placeholder: Option<Cow<'static, str>>,
#[prop(default = false)]
pub disabled: bool,
#[prop(default)]
pub options: Vec<SelectOption>,
#[prop(optional, into)]
pub class: Option<Cow<'static, str>>,
#[prop(extend)]
pub attrs: AttrMap,
pub children: Children,
}