v0.1.0-alpha
官网Home
components/upload
输入与表单Inputs · 14 / 64

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.

examples/storybook/stories.zig:3069
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;
}
在 GitHub 查看源码View source on GitHubexamples/storybook/stories.zig:3069

这是 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.

zenit · 双授权Dual-licensed开源项目可按 GPL-3.0-only 免费使用;闭源或商业产品需要商业授权。Free for open-source projects under GPL-3.0-only; closed-source or commercial products need a commercial license.可联系作者:Contact the author: zongyi.xzy#gmail.com(# 换成 @) (replace # with @)zenit 5f9add5+wip 2026-09-30