(null);
return (
{
field.handleChange(Array.from(event.currentTarget.files ?? []));
// The queue owns the selection display, including resets and removal.
// Clear the native picker so choosing the same file fires another change.
event.currentTarget.value = "";
}}
/>
({
id: String(index),
name: file.name,
preview: { kind: "file" },
progress: 0,
progressLabel: `${String(file.size)} bytes`,
statusLabel: "Selected",
actions: disabled
? {}
: {
remove: {
label: "Remove",
accessibleLabel: `Remove ${file.name}`,
},
},
}))}
onRemove={(id) => {
field.handleChange(
selected.filter((_, index) => String(index) !== id),
);
}}
onCancel={() => undefined}
onRetry={() => undefined}
/>
);
}
/** One control, wired by the Field around it (Field clones these props in). */
function SpecControl({
spec,
field,
locked,
...control
}: ControlState & ControlProps): ReactNode {
const setText = (value: string) => {
field.handleChange(value);
};
const shared = {
...control,
name: spec.name,
disabled: locked,
onBlur: field.handleBlur,
};
switch (spec.kind) {
case "text":
case "email":
case "url":
case "tel":
return (
{
setText(event.currentTarget.value);
}}
/>
);
case "textarea":
return (