package.src.vaadin-upload-file-list-mixin.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of upload Show documentation
Show all versions of upload Show documentation
Web Component for uploading files with drag and drop support
/**
* @license
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { html, render } from 'lit';
/**
* @polymerMixin
*/
export const UploadFileListMixin = (superClass) =>
class UploadFileListMixin extends superClass {
static get properties() {
return {
/**
* The array of files being processed, or already uploaded.
*/
items: {
type: Array,
},
/**
* The object used to localize upload files.
*/
i18n: {
type: Object,
},
};
}
static get observers() {
return ['__updateItems(items, i18n)'];
}
/** @private */
__updateItems(items, i18n) {
if (items && i18n) {
this.requestContentUpdate();
}
}
/**
* Requests an update for the `vaadin-upload-file` elements.
*
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
*/
requestContentUpdate() {
const { items, i18n } = this;
render(
html`
${items.map(
(file) => html`
`,
)}
`,
this,
);
}
};