FileUpload
ui.widgets.FileUploadDateiauswahl und Ablagebereich.
BEHAVIOR CONTRACT
Browse, Ablagezone, Dateiliste und App-Callback bilden einen testbaren Zustand.
RECORDED INTERACTION
Der Harness klickt Browse…; die Story trägt einen deterministischen Dateipfad ein.
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;
}Der unveränderte Quellcode der Story aus dem Storybook (zenit 5f9add5+wip 2026-09-30). W steht für ui.widgets; col / row / label sind kleine Layout-Helfer des Storybooks.
FileUploadProps
ui.widgets.FileUploadfn mountFileUpload(props: FileUploadProps, scope: *Scope, cx: *Cx) !FileUploadMountFeld
Typ
Standard
Beschreibung
widthf32360—
max_filesusize8—
hint[]const u8"Click Browse to add files"—
on_browse?core.HandlerRefnullBrowse 按钮回调(宿主调起对话框后用 state.addFile 回填)。 null = 默认原生 NSOpenPanel(cx.openFilePanel)。
on_change?core.HandlerRefnull文件列表变化回调
FileUploadMount
ui.widgets.FileUploadFeld
Typ
Standard
Beschreibung
wrapper*Node—
—
state*FileUploadState—
—