files

fun RenderContext.files(styling: BasicParams.() -> Unit = {}, baseClass: StyleClass = StyleClass.None, id: String? = null, prefix: String = "file", build: FileSelectionBaseComponent.() -> Unit = {}): Flow<List<File>>

This factory generates a multiple file selection context.

In there you can create a button with a label, an icon, the position of the icon and access its events. For a detailed overview about the possible properties of the button component object itself, have a look at PushButtonComponent.

The File function then returns a Flow of a List of Files in order to combine the Flow directly to a fitting handler which accepts a List of Files:

val textFileStore = object : RootStore<List<String>>(emptyList()) {
val upload = handle<List<File>>{ _, files -> files.map { it.content } }
}
files {
accept("text/plain")
encoding("utf-8")
button(id = "myFiles") {
text("Select one or more files")
}
} handledBy textFileStore.upload

Return

a Flow that offers the selected File

See also

Parameters

styling

a lambda expression for declaring the styling as fritz2's styling DSL

baseClass

optional CSS class that should be applied to the element

id

the ID of the element

prefix

the prefix for the generated CSS class resulting in the form `$prefix-$hash`

build

a lambda expression for setting up the component itself. Details in FileSelectionBaseComponent