{
e?.preventDefault();
e?.stopPropagation();
this.handleBrowseFileClick();
}}"
>
${this.loading ? html`
` : nothing}
${this._labelTemplate()}
(f instanceof File ? f.name : f)).join(",")
: ""}
/>
${(this.noFileList || this.fileListTarget) ? nothing : html`
${this.inline ? html`
${filesList}
` : html`
0 || Object.values(this.value).length > 0}
strategy="fixed"
placement="bottom-start"
auto-size="vertical"
>${filesList}
`
}
`
}
${this._helpTextTemplate()}
`;
}
}
/**
* Check to see if the provided file's mimetype matches
*
* @param f File object
* @return boolean
*/
export function checkMime(f : File, accept = "")
{
if(!accept || accept == "*")
{
return true;
}
let mime : string | RegExp = '';
if(accept.indexOf("/") != 0)
{
// Lower case it now, if it's not a regex
mime = accept.toLowerCase();
}
else
{
// Convert into a js regex
var parts = accept.substr(1).match(/(.*)\/([igm]?)$/);
mime = new RegExp(parts[1], parts.length > 2 ? parts[2] : "");
}
// If missing, let the server handle it
if(!mime || !f.type)
{
return true;
}
var is_preg = (typeof mime == "object");
if(!is_preg && f.type.toLowerCase() == mime || is_preg && mime.test(f.type))
{
return true;
}
// Not right mime
return false;
}
export function hasValidFileSize(file, maxFileSize)
{
return !maxFileSize || file.size <= maxFileSize;
}