Skip to main content

Module forms

Module forms 

Source
Expand description

表单控件(FormInput / FormSelect / AlertBox / …)与 INPUT class 常量。 表单控件组件

提供登录、注册、评论等页面共享的输入框、下拉、时间、数字、开关与提示条。 外观定义在 styles/components/ui.css(.field、.listbox、.switch、.alert)。

约定(Leptos):随状态变化的 props 一律是 Signal<T> / MaybeProp<T>,可直接传 常量、信号或 move || 闭包;受控值写作 value=信号 + oninput/onchange 回调 (回调里由调用方写回信号)。id 等可选字符串是 MaybeProp<String>,id="x" 即可。

Structs§

AlertBoxProps
Props for the AlertBox component.
FormInputProps
Props for the FormInput component.
FormLabelProps
Props for the FormLabel component.
FormSelectProps
Props for the FormSelect component.
FormTextareaProps
Props for the FormTextarea component.
NumberInputProps
Props for the NumberInput component.
SelectOptionProps 🔒
Props for the SelectOption component.
TimePickerProps
Props for the TimePicker component.
ToggleSwitchProps
Props for the ToggleSwitch component.

Constants§

FILTER_THRESHOLD 🔒
选项多于该数量时,下拉面板顶部出现筛选框。
FORM_SELECT_COMPACT_CLASS
FormSelect 紧凑触发器:工具栏内联小下拉(自动刷新、导出格式等)。
INPUT_CLASS
输入框基础类:浅底、发丝线环,聚焦陶土双环,aria-invalid 时红环。
TEXTAREA_CLASS
多行输入框基础类:随内容长高(.field-textarea)。

Statics§

FORM_SELECT_ID 🔒
FormSelect / TimePicker / NumberInput 实例序号计数器(跨泛型单例化全局唯一)。

Functions§

AlertBox
提示条,用于显示成功、错误等状态消息。
FormInput
表单输入框组件。
FormLabel
表单标签组件。
FormSelect
下拉选择框组件(自定义弹层,全主题化)。
FormTextarea
多行输入框:外观同 FormInput,.field-textarea 随内容长高, rows 是不支持 field-sizing 时的初始行数。
NumberInput
数字输入框:单位写在框内右侧,两侧 −/+ 步进;越界时边框与说明一起变红。
SelectOption 🔒
下拉面板中的一项。禁用项(reason 为 Some)变淡、写明原因,不响应点击。
TimePicker
时间选择器(24 小时制 “HH:MM”,浏览器本地时间)。
ToggleSwitch
开关(toggle switch)组件。
matches_query 🔒
筛选:忽略大小写的子串匹配,空查询匹配全部。
parse_hhmm 🔒
解析 “HH:MM” 为 (时, 分);任一段缺失或越界整体回退 (0, 0)。 纯防御性兜底:正常路径下 value 只来自服务端 normalize 或本组件输出,必然合法。
parse_in_range 🔒
解析草稿文本,在 [min, max] 内才返回。
should_flip 🔒
面板应向上展开的条件:视口下方空间不足,且上方空间比下方更宽余。
step_active 🔒
在可选项(已筛选、未禁用)之间移动高亮;当前项不在其中时落到首项或末项。
use_instance_prefix 🔒
分配实例序号,用于拼接未显式传 id 时的元素 id(form-select-N 等)。
wrap_index 🔒
键盘导航的循环索引:在 len 个选项中从 cur 移动 delta(±1),越界回绕。