Skip to main content

euv_ui/component/form_extra/
struct.rs

1use super::*;
2
3/// Accessible form control label.
4#[derive(Clone, Data, New, Props)]
5pub struct EuvLabel {
6    /// Label text.
7    pub(crate) text: String,
8    /// Displays a destructive required indicator when `true`.
9    #[get(type(copy))]
10    pub(crate) required: bool,
11    /// Active theme tokens.
12    #[get(type(copy))]
13    pub(crate) tokens: ThemeTokens,
14}
15
16/// Structured form wrapper stacking labeled fields with uniform vertical spacing.
17#[derive(Clone, Data, New, Props)]
18pub struct EuvForm {
19    /// Ordered form field nodes.
20    #[new(skip)]
21    pub(crate) fields: Vec<NodeId>,
22    /// Active theme tokens.
23    #[get(type(copy))]
24    pub(crate) tokens: ThemeTokens,
25}
26
27/// Multi-line text input surface bound to `Signal<String>`.
28#[derive(Clone, Data, New, Props)]
29pub struct EuvTextarea {
30    /// Bound string signal.
31    #[get(type(copy))]
32    pub(crate) value: Signal<String>,
33    /// Placeholder text.
34    pub(crate) placeholder: String,
35    /// Active theme tokens.
36    #[get(type(copy))]
37    pub(crate) tokens: ThemeTokens,
38    /// Optional style overrides controlling textarea dimensions and appearance (defaults to `height: Length::Px(96.0)`).
39    #[new(skip)]
40    #[get(type(copy))]
41    pub(crate) style: Option<Style>,
42}
43
44/// Numeric stepper input bound to `Signal<i64>` with optional min/max bounds and step size.
45#[derive(Clone, Data, New, Props)]
46pub struct EuvNumberInput {
47    /// Bound integer value signal.
48    #[get(type(copy))]
49    pub(crate) value: Signal<i64>,
50    /// Optional minimum allowed value (`None` defaults to `i64::MIN / 2`).
51    #[new(skip)]
52    #[get(skip)]
53    pub(crate) min: Option<i64>,
54    /// Optional maximum allowed value (`None` defaults to `i64::MAX / 2`).
55    #[new(skip)]
56    #[get(skip)]
57    pub(crate) max: Option<i64>,
58    /// Increment step size (`<= 0` defaults to `1`).
59    #[new(skip)]
60    #[get(type(copy))]
61    #[prop(custom)]
62    pub(crate) step: i64,
63    /// Active theme tokens.
64    #[get(type(copy))]
65    pub(crate) tokens: ThemeTokens,
66}
67
68/// Mutually exclusive radio button group bound to `Signal<usize>`.
69#[derive(Clone, Data, New, Props)]
70pub struct EuvRadioGroup {
71    /// Option labels.
72    pub(crate) options: Vec<String>,
73    /// Selected option index signal.
74    #[get(type(copy))]
75    pub(crate) selected: Signal<usize>,
76    /// Active theme tokens.
77    #[get(type(copy))]
78    pub(crate) tokens: ThemeTokens,
79}
80
81/// Continuous range slider bound to `Signal<f32>` in `[min, max]`.
82#[derive(Clone, Data, New, Props)]
83pub struct EuvSlider {
84    /// Reactive numeric value signal.
85    #[get(type(copy))]
86    pub(crate) value: Signal<f32>,
87    /// Minimum slider value.
88    #[get(type(copy))]
89    pub(crate) min: f32,
90    /// Maximum slider value.
91    #[get(type(copy))]
92    pub(crate) max: f32,
93    /// Active theme tokens.
94    #[get(type(copy))]
95    pub(crate) tokens: ThemeTokens,
96}
97
98/// Dropdown option selector bound to `Signal<usize>` with reactive menu toggle.
99#[derive(Clone, Data, New, Props)]
100pub struct EuvSelect {
101    /// Ordered selectable option labels.
102    pub(crate) options: Vec<String>,
103    /// Active selected option index.
104    #[get(type(copy))]
105    pub(crate) selected: Signal<usize>,
106    /// Reactive dropdown open flag.
107    #[get(type(copy))]
108    pub(crate) open: Signal<bool>,
109    /// Active theme tokens.
110    #[get(type(copy))]
111    pub(crate) tokens: ThemeTokens,
112}
113
114/// Interactive 1..=N star rating control bound to `Signal<usize>`.
115#[derive(Clone, Data, New, Props)]
116pub struct EuvRating {
117    /// Current rating value (`0..=max_stars`).
118    #[get(type(copy))]
119    pub(crate) value: Signal<usize>,
120    /// Maximum star count.
121    #[get(type(copy))]
122    pub(crate) max_stars: usize,
123    /// Active theme tokens.
124    #[get(type(copy))]
125    pub(crate) tokens: ThemeTokens,
126}
127
128/// Interactive swatch palette color selector bound to `Signal<Color>`.
129#[derive(Clone, Data, New, Props)]
130pub struct EuvColorPicker {
131    /// Bound reactive selected color signal.
132    #[get(type(copy))]
133    pub(crate) value: Signal<Color>,
134    /// Optional custom swatch presets (empty falls back to the built-in curated palette).
135    #[new(skip)]
136    #[prop(custom)]
137    pub(crate) presets: Vec<Color>,
138    /// Active theme tokens.
139    #[get(type(copy))]
140    pub(crate) tokens: ThemeTokens,
141}
142
143/// Interactive 24-hour `HH:MM` time picker with steppers and quick presets bound to `Signal<(u8, u8)>`.
144#[derive(Clone, Data, New, Props)]
145pub struct EuvTimePicker {
146    /// Bound reactive `(hour, minute)` tuple signal (`hour` in `0..=23`, `minute` in `0..=59`).
147    #[get(type(copy))]
148    pub(crate) value: Signal<(u8, u8)>,
149    /// Active theme tokens.
150    #[get(type(copy))]
151    pub(crate) tokens: ThemeTokens,
152}
153
154/// Interactive multi-tag chip input supporting live tag addition and removal bound to `Signal<Vec<String>>`.
155#[derive(Clone, Data, New, Props)]
156pub struct EuvTagInput {
157    /// Bound reactive list of active tag strings.
158    #[get(type(copy))]
159    pub(crate) tags: Signal<Vec<String>>,
160    /// Input field placeholder text.
161    #[new(skip)]
162    #[prop(custom)]
163    pub(crate) placeholder: String,
164    /// Active theme tokens.
165    #[get(type(copy))]
166    pub(crate) tokens: ThemeTokens,
167}