= createRef();
/**
* Opens the hidden file input dialog.
*
* @internal
*/
private openFileInput = () => {
this.fileInputRef.value?.click();
};
/**
* Uploads the first selected file and resets the input.
*
* @internal
*/
private async handleBlobChange(files: FileList | null, input: HTMLInputElement) {
if (files && this.weavy) {
const file = files[0];
const fileProps = { file: file };
await this.uploadBlobMutation.trackMutation(getSimpleUploadBlobMutationOptions(this.weavy));
const blob = await this.uploadBlobMutation.mutate(fileProps);
if (input) {
input.value = "";
}
const event: BlobUploadedEventType = new (CustomEvent as NamedEvent)("blob-uploaded", { detail: { blob: blob } });
this.dispatchEvent(event);
}
}
override render() {
return html`
e.stopPropagation()}
@change=${(e: Event) =>
this.handleBlobChange((e.target as HTMLInputElement).files, e.target as HTMLInputElement)}
hidden
/>
${this.label
? html`${this.label}`
: nothing}
`;
}
}