@using Microsoft.AspNetCore.Components.Forms
@CurrentActionText
@if (!string.IsNullOrWhiteSpace(DragDropHintText)) {
@DragDropHintText
}
@code { [Parameter] public bool Disabled { get; set; } [Parameter] public bool HasDocument { get; set; } [Parameter] public string Accept { get; set; } = ".pdf"; [Parameter] public string UploadText { get; set; } = "PDF hochladen"; [Parameter] public string ReplaceText { get; set; } = "PDF ersetzen"; [Parameter] public string DragDropHintText { get; set; } = "Datei hierhin ziehen oder klicken"; [Parameter] public EventCallback FileSelected { get; set; } private int _dragDepth; private bool _isDragActive; private string CurrentActionText => HasDocument ? ReplaceText : UploadText; private string DropZoneClass { get { if (Disabled) return "sender-pdf-dropzone--disabled"; return _isDragActive ? "sender-pdf-dropzone--drag-active" : string.Empty; } } private void OnDragEnter(DragEventArgs _) { if (Disabled) return; _dragDepth++; _isDragActive = true; } private void OnDragLeave(DragEventArgs _) { if (Disabled) return; _dragDepth = Math.Max(0, _dragDepth - 1); if (_dragDepth == 0) _isDragActive = false; } private void OnDragOver(DragEventArgs _) { if (Disabled) return; _isDragActive = true; } private void OnDrop(DragEventArgs _) { _dragDepth = 0; _isDragActive = false; } private async Task OnFileSelectedAsync(InputFileChangeEventArgs args) { _dragDepth = 0; _isDragActive = false; if (Disabled) return; if (FileSelected.HasDelegate) await FileSelected.InvokeAsync(args); } }