Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@jouni @marcus @platosha @admwx7 @haydenmcp @krumware
PTAL This is first attempt at making
vaadin-upload
more modular. All feedback is welcome.A lot of files that are showing changed right now from working off an older commit and don't want to mess with rebasing yet. Best to start from vaadin-upload-ajax-uploader
Global TODOs:
vaadin-upload
Creates a 100% backwards compatible version of the existing
vaadin-upload
component but built from new components. This is an optional component that allows users to migrate to the new breaking syntax without having to update all instances.TODO:
vaadin-upload-ajax-uploader
Allows user to upload files using XHR. Fallsback to any specified uploader if not supported.
Mixes:
UploaderMixin
Properties:
url
: Url to upload tomethod
: (Optional, defaults to'POST'
) Method to use for requestparams
: (Optional, defaults to{}
) Query params to send on requestheaders
: (Optional, defaults to{}
) Headers to apply to XHR on requesttimeout
: (Optional, defaults to0
) Timeout for XHR requestwithCredentials
: (Optional, defaults tofalse
) True if request should be made with credentialsformDataName
: (Optional, defaults to'file'
) Name of the form data itemEvents:
upload-preopen
: Cancelable, Fired beforexhr.open
is called. Allows canceling the upload before XHR is openedupload-preflight
: Cancelable, Fired beforexhr.send
is called. Allows canceling the upload before send or changing the send data.upload-start
: Fired after the XHR upload has started.upload-response
: Cancelable, Fired after XHR response comes back. Allows changing the response data.upload-error
: Fired after a failed XHR.upload-success
: Fired after a successful XHR.TODO:
vaadin-upload-dropzone
Allows creating a dropzone to handle file drag and drop.
Properties:
clickable
: (Optional, defaults to false) Allows the dropzone area to be clickable for triggering the file dialogdropTarget
: (Optional, defaults to self) Allows a user to specify different dropTargets:document
, element id, element reference, or self.disabled
: (Optional, defaults to false) Disables the dropzone from triggering any file additions.invalid
: True if the files being dragged do not meet the specified criteria of the upload elementactive
: True if the dropzone has files being dragged over itSlots:
upload
: Takes the upload element which handles validation and addition of filesTODO:
dragend
(Not firing)vaadin-upload-fetch-uploader
TODO:
vaadin-upload-file-list
Implements a virtual scroll list
NOTE: I'm not convinced we should implement this as it just wraps
iron-list
Properties:
files
: Files to displaySlots:
TODO:
vaadin-upload-file-uploader
TODO:
vaadin-upload-file
Implements the default file item visualization
Properties:
file
: File to displayTODO:
vaadin-upload-icons
Adds the font icon data
vaadin-upload-image-preview
Implements a preview for images. Doesn't render non-images
Properties:
file
: Image to renderalt
: (Optional, defaults tofile.name
) Alt that should be associated with the image previewTODO:
vaadin-upload-localstorage-uploader
"Uploads" files to LocalStorage. Will fallback to any fallback uploader if LocalStorage is not supported. (Shouldn't ever not be supported on any modernish browser)
NOTE: Limited to amount of LocalStorage the browser has allocated for the site.
Mixes:
UploaderMixin
Properties:
path
: (Optional, defaults to "files") Path to store the files at.TODO:
vaadin-upload-mixin
Implements an interface for different upload components
Mixes:
Properties:
files
: Notifies, List of files that have been addedaccept
: (Optional) List of MIME Types or file extensions to acceptcapture
: (Optional) Pass-through toinput
for capture typepreventReload
: (Optional, defaults tofalse
) Prevents navigating away when uploads are in progressdisabled
: (Optional, defaults tofalse
) Disables the input and buttonmaxFileSize
: (Optional, defaults toInfinity
) Maximum file size to allow. Specified inunit
of choice.unit
: (Optional, defaults tokB
) Unit to specify size in. (Useful formaxFileSize
)invalid
: Notify, Reflects, If true, the component is invalid.required
: (Optional, defaults to false) Determines if this component should be able to fail validation.Methods:
openFileDialog
: Allows user to trigger the open of the file dialog programmatically.remove
: Allows user to remove a fileaddFiles
: Allows user to add a file or multiple files that are not complete. Returns Array of Promisesvalidate
: Checks the validation state of the component. Component can override__getValidity(file)
to implement the validation logic.validateFile
: Checks the validation state of the file.TODO:
vaadin-upload-multiple
Implements logic for allowing >= 1 files to be uploaded disabling the input and button after reaching max files. Also, keeps a list of the files uploaded.
Mixes:
Properties:
minFiles
: (Optional, defaults to0
) Minimum number of files that must be added to be considered valid.maxFiles
: (Optional, defaults toInfinity
) Maximum number of files that can be added.maxFilesReached
: Notifies, ReadOnly, True ifmaxFiles
was reached.Slots:
uploader
: Uploader goes in herevaadin-upload-single
Implements logic allowing for a single file to be uploaded and not disabling the input after the single upload. Does not keep a list of files that have been uploaded. Only handles the latest file
Mixes:
Slots:
uploader
: Uploader goes in hereTODO:
vaadin-upload-uploader-mixin
Implements the base logic for all uploaders.
Properties:
fallback
: (Optional) ReadOnly, If provided and the uploader isn't supported by the browser it will use this method instead.files
: Notifies, The files to uploadauto
: (Optional, defaults tofalse
) Upload immediately after addingretryOnError
: (Optional, defaults tofalse
) Iftrue
it will automatically re-attempt a failed upload.maxRetries
: (Optional, defaults to5
) Limits number of retry attempts. Only applies ifretryOnError
istrue
.clearOnComplete
(Optional, defaults to false) Removes the file upon completion. NOTE: Not sure if this is useful or better to have a method that can be called to clear on demand?Methods:
retry
: Re-attempts to upload specified file. Returns a promise.abort
: Kills a in progress file upload. Returns a promise.uploadFiles
: Can take a single file or multiple to upload. Returns an Array of Promises.Events:
upload-before
: Triggered before an actual upload process starts on a file.upload-abort
: Triggered when abort is called on a file. NOTE: Not sure if this is necessaryupload-retry
: Triggered when retry is called on a file. NOTE: Not sure if this is necessaryTODO:
retryOnError
withmaxRetries
clearOnComplete
is useful enough to implementabort
andretry
events are useful enough to keepvaadin-upload-file-item-mixin
vaadin-upload-video-preview
Implements logic to render a image preview of a video. Doesn't render if required features are not supported or not a video file.
Properties:
file
: The video file to render a image for.alt
: (Optional, defaults tofile.name
) A string to use as the alt tag of the image preview.TODO: