add remove button
This commit is contained in:
@@ -66,6 +66,16 @@ export class UmbInputImageCropperElement extends UmbLitElement {
|
||||
this._dropzone.browse();
|
||||
}
|
||||
|
||||
#onRemove = () => {
|
||||
this.value = { ...this.value, src: '' };
|
||||
if (!this.fileUnique) return;
|
||||
this.#manager?.removeOne(this.fileUnique);
|
||||
this.fileUnique = undefined;
|
||||
this.file = undefined;
|
||||
|
||||
this.dispatchEvent(new UmbChangeEvent());
|
||||
};
|
||||
|
||||
render() {
|
||||
if (this.value.src || this.file) {
|
||||
return this.#renderImageCropper();
|
||||
@@ -89,10 +99,11 @@ export class UmbInputImageCropperElement extends UmbLitElement {
|
||||
}
|
||||
|
||||
#renderImageCropper() {
|
||||
return html`<umb-image-cropper-field
|
||||
.value=${this.value}
|
||||
.file=${this.file as File}
|
||||
@change=${this.#onChange}></umb-image-cropper-field>`;
|
||||
return html`<umb-image-cropper-field .value=${this.value} .file=${this.file as File} @change=${this.#onChange}>
|
||||
<uui-button slot="actions" @click=${this.#onRemove} label="Remove files">
|
||||
<uui-icon name="icon-trash"></uui-icon> Remove file(s)
|
||||
</uui-button>
|
||||
</umb-image-cropper-field> `;
|
||||
}
|
||||
|
||||
static styles = css``;
|
||||
|
||||
Reference in New Issue
Block a user