FileUpload
ui.widgets.FileUpload文件选择与拖放入口。File picking and a drop target.
BEHAVIOR CONTRACT
Browse、drop-zone、文件列表和应用回调统一成可测试状态。Browse, the drop zone, the file list and the app callback form one testable state.
RECORDED INTERACTION
Harness 点击 Browse…,Story 回填一个确定性文件路径。The harness clicks Browse…; the story fills in a deterministic file path.
pub fn buildFileUpload(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
const a = cx.allocator;
const c = try col(cx, 12);
const story = try cx.bindState(FileUploadStory, .{ .state = undefined });
const fu = try ui.widgets.FileUpload(.{
.width = 380,
.on_browse = cx.on(FileUploadStory, story, FileUploadStory.browse),
}, scope, cx);
story.state = fu.state;
fu.wrapper.meta.ownership.meta.test_id = "story.upload.wrapper";
// 拖放 drop zone:e2e 用 dragAt 往这块矩形里注入 entered/dropped
fu.state.drop_zone.meta.ownership.meta.test_id = "story.upload.dropzone";
try c.appendChild(a, fu.wrapper);
return c;
}这是 Storybook 中该 story 的原样代码(zenit 5f9add5+wip 2026-09-30)。其中 W 即 ui.widgets,col / row / label 是 Storybook 内的布局小工具。The story's verbatim source from the Storybook (zenit 5f9add5+wip 2026-09-30). W is ui.widgets; col / row / label are small Storybook layout helpers.