doc: add documentation for the Upload component#981
Conversation
- docs/components/upload.md covering basics, picker behavior, validation and limits, auto upload and auto clear, mobile capture, native file system access, layout customization with presets and the default slot, themes, events, internationalization, and styling - UploadView: resume upload inside a job application form - UploadPickingFilesView: multi-file gallery uploader with filter switching - UploadAutoUploadView: ticket submission with background attachment uploads - UploadPresetsView: side-by-side comparison of the four chrome presets - UploadDefaultSlotView: HEADLESS preset with projected drop surface - UploadEventsView: progress bar and status line driven by onChange, onListProgress, and onComplete
| layout.add(upload); | ||
| ``` | ||
|
|
||
| The example below drops a resume `Upload` into a job application form, alongside a name field and submit button. |
There was a problem hiding this comment.
[Google.WordList] Use 'app' instead of 'application'.
| @@ -0,0 +1,337 @@ | |||
| --- | |||
There was a problem hiding this comment.
Please include a description at the top for llm.txt parsing:
description: This component...
| - **`ON_DROP`** uploads as soon as files are dropped onto the component. | ||
| - **`ALWAYS`** covers both paths. | ||
|
|
||
| Auto upload pairs well with the `BUTTON_ONLY` or `INLINE` presets, where there's no Upload button for the user to click anyway. For workflows where the user needs to review the selection before sending, leave auto upload off. |
There was a problem hiding this comment.
This likely belongs in a tip, but I'll leave that up to your judgement!
|
|
||
| When the user picks a new batch, auto clear decides what to do with the entries already in the list. Clearing happens at the moment of the next pick, not on upload completion, so finished uploads stay visible until the user picks again. | ||
|
|
||
| :::warning Auto clear has subtle triggers |
There was a problem hiding this comment.
I'd recommend moving this after the ENUM options, but up to you
| :::tip Capture and filters | ||
| Restrict selection to image extensions so the camera opens in still mode, or to video extensions so it opens in recording mode. Without a corresponding filter, a capture mode falls back to the standard picker on most platforms. Desktop browsers ignore the capture setting entirely. | ||
| ::: | ||
|
|
There was a problem hiding this comment.
Totally up to you here, but I could see benefit in linking to the PWA section of the docs here for more info on using webforJ for mobile web app development
| height='400px' | ||
| /> | ||
|
|
||
| ## Themes {#themes} |
There was a problem hiding this comment.
I'd move this section to right before the end/styling section
|
Thanks for the feedback @MatthewHawkins. I've applied the changes |
hyyan
left a comment
There was a problem hiding this comment.
@laurenic0l Looking great overall, just a few more requests!
| @@ -0,0 +1,345 @@ | |||
| --- | |||
| title: Upload | |||
| @@ -0,0 +1,345 @@ | |||
| --- | |||
| title: Upload | |||
| sidebar_position: 160 | |||
| submit); | ||
| } | ||
|
|
||
| private FlexLayout fieldGroup(String label, String helperText, Upload upload) { |
There was a problem hiding this comment.
The label is not aligned with the "full name" input's label horizontally
|
|
||
| @Route | ||
| @StyleSheet("ws://css/upload/upload.css") | ||
| @FrameTitle("Upload Basic") |
There was a problem hiding this comment.
All upload demos should automatically delete any uploaded files directly from the server, and file system access must be disabled, as iframes block this feature otherwise the upload will never be triggered.
resume.setFileSystemAccess(false);
resume.onUpload(e -> {
e.getFiles().forEach(file -> {
try {
file.delete();
} catch (Exception ex) {
// skip
}
});
});| @Route | ||
| @StyleSheet("ws://css/upload/upload.css") | ||
| @FrameTitle("Upload Basic") | ||
| public class UploadView extends Composite<FlexLayout> { |
There was a problem hiding this comment.
Simplify this demo to only include the uploa, nothing else. The form is not functional.
| upload.setAutoClear(Upload.AutoClear.ALL); | ||
| ``` | ||
|
|
||
| :::warning Auto clear has subtle triggers |
There was a problem hiding this comment.
It's not possible to select a file programmatically, so I'm not sure what that tip is referring to.
|
|
||
| ## Customizing the layout {#customizing-the-layout} | ||
|
|
||
| The component is built from five visible parts: the picker button, the drop label, the file list, the upload button, and the cancel button. By default all five are visible, but the layout can be reshaped with presets for common picker shapes, or with per-part visibility controls for finer adjustments. |
There was a problem hiding this comment.
By default all five are visible, -> cancel button is not visible by default
| @Route | ||
| @StyleSheet("ws://css/upload/upload.css") | ||
| @FrameTitle("Upload Default Slot") | ||
| public class UploadDefaultSlotView extends Composite<FlexLayout> { |
There was a problem hiding this comment.
This demo doesn't do anything useful, please use the table demo instead.
| ```java | ||
| upload.onProgress(e -> { | ||
| // Fires repeatedly during a single file's transfer. | ||
| int percent = (int) e.getProgress(); |
|
|
||
| @Route | ||
| @FrameTitle("Upload Themes") | ||
| public class UploadThemesView extends Composite<FlexLayout> { |
There was a problem hiding this comment.
Only display the primary theme and use the inline preset.
Adds the documentation article and demos for the new inline Upload component
Covers:
Basics + when to use vs. FileUploadDialog
Picking files: selection mode, picker source, filters, drop zone
Validation and limits + server-side validation note
Upload behavior: auto upload, auto clear, programmatic actions
Mobile capture
Native file system access
Customizing the layout: presets, part visibility, default slot
Themes
Events
Internationalization
Styling