DatePicker
ui.widgets.DatePicker输入单个日期并使用日历选择。
BEHAVIOR CONTRACT
触发器、calendar overlay、月份导航、选中值与 dismiss 行为成套提供。
RECORDED INTERACTION
Harness 点击 Pick a date,日历面板展开。
// ── DatePicker ──
pub fn buildDatePicker(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
const dp = try W.DatePicker(.{ .placeholder = "Pick a date", .initial_year = 2026, .initial_month = 5 }).mount(scope, cx);
return dp.wrapper;
}这是 Storybook 中该 story 的原样代码(zenit 5f9add5+wip 2026-09-30)。其中 W 即 ui.widgets,col / row / label 是 Storybook 内的布局小工具。
DatePickerProps
ui.widgets.DatePickerfn DatePicker(props: DatePickerProps) DatePickerBuilder字段
类型
默认值
说明
placeholder[]const u8"Select date..."—
selected_date?SimpleDatenull—
initial_yearu162025—
initial_monthu81—
widthf32220—
sizetheme.ControlSize.md控件尺寸(与 Button / Input / Select 同一 ControlSize,默认 md)
disabledboolfalse—
on_change?core.HandlerRefnull—
calendar_icon_asset?svg_assets.Assetnull—
prev_icon_asset?svg_assets.Assetnull—
next_icon_asset?svg_assets.Assetnull—
test_id?[]const u8null—
DatePickerResult
ui.widgets.DatePicker字段
类型
默认值
说明
wrapper*Node—
—
state*DatePickerState—
—