FileInput.added# function · packages/mixins-ui/src/fileInput.ts:121
function added (
files: ReadonlyArray < File >,
picked: ReadonlyArray < File >,
options?: {
readonly multiple?: boolean | undefined
},
) : ReadonlyArray < File > The list after picked is chosen. A single field takes the newest pick; with
multiple the files join the list, and one the list already holds (the same
name, size, type and modification time, since a re-picked file is a new
File) is not added twice.
FileInput.cases# const · packages/mixins-ui/src/fileInput.ts:71
const cases = { CompletedSync, CompletedFocus } The Messages Sync and Focus answer with, to spread into the application's own:
defineMessageUnion({ ..., ...FileInput.cases }). Its update need do nothing for either.
const · packages/mixins-ui/src/fileInput.ts:52
const FileInputPattern: A11y . Pattern <{
readonly input: {
readonly capability: Capability . Capability <
'Interactive' ,
readonly [Capability . Capability < 'Base' , readonly []> ]
>
readonly events: readonly [Event . EventToken < 'change' > ]
readonly attributes: readonly [Attr . AttrToken < 'aria-invalid' > ]
readonly obligations: readonly [
A11y . Obligation < 'activation' >,
A11y . Obligation < 'focus-strategy' >,
A11y . Obligation < 'name' >,
]
}
readonly trigger: {
readonly capability: Capability . Capability <
'Container' ,
readonly [
Capability . Capability <
'Interactive' ,
readonly [Capability . Capability < 'Base' , readonly []> ]
>,
]
>
}
readonly remove: {
readonly capability: Capability . Capability <
'Interactive' ,
readonly [Capability . Capability < 'Base' , readonly []> ]
>
readonly events: readonly [Event . EventToken < 'click' > ]
readonly attributes: readonly [Attr . AttrToken < 'aria-label' > ]
}
}> Show all 34 lines The input is a native file input and the trigger its label; a removable row needs a named control.
const · packages/mixins-ui/src/fileInput.ts:32
const FileInputSlots: Slots . Contract <{ readonly root: Slot . UnnamedSlot < Capability . Capability < "Container" , readonly [Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]> ]>, readonly Slot . EventName [], readonly Slot . AttributeName [], readonly Slot . RequirementName [], boolean >; readonly input: Slot . UnnamedSlot < Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]>, readonly [Event . EventToken < "change" > ], readonly [Attr . AttrToken < "aria-invalid" >, Attr . AttrToken < "aria-describedby" >, Attr . AttrToken < "disabled" > ], readonly Slot . RequirementName [], boolean >; readonly trigger: Slot . UnnamedSlot < Capability . Capability < "Container" , readonly [Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]> ]>, readonly Slot . EventName [], readonly Slot . AttributeName [], readonly Slot . RequirementName [], boolean >; readonly description: Slot . UnnamedSlot < Capability . Capability < "Container" , readonly [Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]> ]>, readonly Slot . EventName [], readonly Slot . AttributeName [], readonly Slot . RequirementName [], boolean >; readonly list: Slot . UnnamedSlot < Capability . Capability < "Container" , readonly [Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]> ]>, readonly Slot . EventName [], readonly Slot . AttributeName [], readonly Slot . RequirementName [], boolean >; readonly item: Slot . UnnamedSlot < Capability . Capability < "Container" , …;A file picker: a native type="file" input, hidden but still the one
focusable control, and a trigger drawn as a button that is its label, so
the browser opens its dialog for a press on the button and for Enter or Space
on the input, with no script between. The chosen files are listed in a list
of items, each with a remove button.
The application owns the list. The input forgets what it was given (Foldkit
empties it after each pick, so the same file can be chosen again), which
would leave a surrounding form with no file; answer onChange and onRemove
with Sync , which writes the list back into the input, so a form submits
exactly what the list shows. A removed row takes its button and the focus it
held: answer onRemove with Focus as well, which puts focus on the input.
interface · packages/mixins-ui/src/fileInput.ts:144
interface FileInputView < Message > {
readonly id: string
readonly label: string
readonly files: ReadonlyArray < File >
readonly onChange : ( files: ReadonlyArray < File >) => NoInfer < Message >
readonly onRemove : ( file: File ) => NoInfer < Message >
readonly name?: string | undefined
readonly accept?: ReadonlyArray < string > | undefined
readonly multiple?: boolean | undefined
readonly disabled?: boolean | undefined
readonly required?: boolean | undefined
readonly invalid?: boolean | undefined
readonly description?: string | undefined
readonly words?: FileInputWords | undefined
readonly style?: NamedStyle < typeof FileInputSlots> | undefined
readonly mixins?: MixinList < Message > | undefined
} Show all 17 lines interface · packages/mixins-ui/src/fileInput.ts:139
interface FileInputWords {
readonly remove?: string | undefined
} FileInput.Focus# const · packages/mixins-ui/src/fileInput.ts:104
const Focus: Command . CommandDefinitionWithArgs <
'FileInput.Focus' ,
{ id: Schema . String },
Effect . Effect <{ readonly _tag: 'CompletedFocus' }, never , never >
> Focuses the input of the field with id; a missing input is not an error.
function · packages/mixins-ui/src/fileInput.ts:82
function inputId ( id: string ) : string The id of the field's file input, for id given to view.
FileInput.keyOf# function · packages/mixins-ui/src/fileInput.ts:112
function keyOf ( file: File ) : string What names a file when the browser hands the same one twice: a re-picked file is a new File.
FileInput.Message# const · packages/mixins-ui/src/fileInput.ts:78
const Message: MessageUnion <{ CompletedSync: {}; CompletedFocus: {} }> FileInput.Sync# const · packages/mixins-ui/src/fileInput.ts:90
const Sync: Command . CommandDefinitionWithArgs <
'FileInput.Sync' ,
{ id: Schema . String ; files: Schema . $Array < Schema . instanceOf < File , File >> },
Effect . Effect <{ readonly _tag: 'CompletedSync' }, never , never >
> Writes files into the input of the field with id, so a form submits the
list as the application keeps it, and an empty list resets the input, so a
removed file can be chosen again. Setting the files fires no change. A
missing input is not an error.
FileInput.view# function · packages/mixins-ui/src/fileInput.ts:174
function view < Message >(
options: FileInputView < Message >,
h: HtmlBuilder < Message >,
) : Html