drualcman / BlazorBasics.InputFileExtended

Extend a bit the tradition InputFile with a small basics tools like copay and pase, drag and drop and upload button.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nuget Nuget

Description

Extend the traditional component InputFile with more options like drag and drop, copy and paste. Less coding for all. Oficial web documentation and examples.

How to use simple way

Import the name space adding to _Imports.razor this line:

@using BlazorBasics.InputFileExtended

Add into your component:

<InputFileComponent OnChange=LoadFiles />

@code {
    private void LoadFiles(FilesUploadEventArgs e)
    {
        ...
    }
}

How to use with drag and drop

@using BlazorBasics.InputFileExtended

<InputFileComponent Parameters="Parameters" OnChange=LoadFiles />

@code{
    BlazorBasics.InputFileExtended.ValueObjects.InputFileParameters Parameters = new BlazorBasics.InputFileExtended.ValueObjects.InputFileParameters()
    {
        DragAndDropOptions = new BlazorBasics.InputFileExtended.ValueObjects.DragAndDropOptions
        {
            CanDropFiles = true
        }
    };

    private void LoadFiles(FilesUploadEventArgs e)
    {
        // ...
    }
}

How to use with copy and paste

@using BlazorBasics.InputFileExtended

<InputFileComponent Parameters="Parameters" OnChange=LoadFiles />

@code{
    BlazorBasics.InputFileExtended.ValueObjects.InputFileParameters Parameters = new BlazorBasics.InputFileExtended.ValueObjects.InputFileParameters()
    {
        AllowPasteFiles = true
    };

    private void LoadFiles(FilesUploadEventArgs e)
    {
        // ...
    }
}

How to use with upload button

@using BlazorBasics.InputFileExtended

<InputFileComponent Parameters="Parameters" />

@code {
    BlazorBasics.InputFileExtended.ValueObjects.InputFileParameters Parameters;

    Task<bool> UploadFles(IReadOnlyList<BlazorBasics.InputFileExtended.Models.FileUploadContent> files)
    {
        // process your upload
        // ...
        await Task.Delay(1);
        return true;
    }

    protected override void OnInitialized()
    {
        Parameters = new BlazorBasics.InputFileExtended.ValueObjects.InputFileParameters()
        {
            ButtonOptions = new BlazorBasics.InputFileExtended.ValueObjects.ButtonOptions
            {
                ButtonShow = true,
                CleanOnSuccessUpload = true            
            }
        };
        Parameters.ButtonOptions.OnSubmit = UploadFles;
    }
}

About

Extend a bit the tradition InputFile with a small basics tools like copay and pase, drag and drop and upload button.

License:Other


Languages

Language:C# 87.0%Language:HTML 5.8%Language:JavaScript 3.9%Language:CSS 3.4%