• Stars
    star
    121
  • Rank 293,924 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created over 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Blazor Controls

Overview

The LoreSoft Blazor Controls project contains a collection of Blazor user controls.

Installing

The LoreSoft.Blazor.Controls library is available on nuget.org via package name LoreSoft.Blazor.Controls.

To install LoreSoft.Blazor.Controls, run the following command in the Package Manager Console

Install-Package LoreSoft.Blazor.Controls

Setup

To use, you need to include the following CSS and JS files in your index.html (Blazor WebAssembly) or _Host.cshtml (Blazor Server).

In the head tag add the following CSS.

<link rel="stylesheet" href="_content/LoreSoft.Blazor.Controls/BlazorControls.css" />

Typeahead Features

  • Searching data by supplying a search function
  • Template for search result, selected value, and footer
  • Debounce support for smoother search
  • Character limit before searching
  • Multiselect support
  • Built in form validation support

Typeahead Properties

Required

  • Value - Bind to Value in single selection mode. Mutually exclusive to Values property.
  • Values - Bind to Values in multiple selection mode. Mutually exclusive to Value property.
  • SearchMethod - The method used to return search result

Optional

  • AllowClear - Allow the selected value to be cleared
  • ConvertMethod - The method used to convert search result type to the value type
  • Debounce - Time to wait, in milliseconds, after last key press before starting a search
  • Items - The initial list of items to show when there isn't any search text
  • MinimumLength - Minimum number of characters before starting a search
  • Placeholder - The placeholder text to show when nothing is selected

Templates

  • ResultTemplate - User defined template for displaying a result in the results list
  • SelectedTemplate - User defined template for displaying the selected item(s)
  • NoRecordsTemplate - Template for when no items are found
  • FooterTemplate - Template displayed at the end of the results list
  • LoadingTemplate - Template displayed while searching

Typeahead Examples

Basic Example

State selection dropdown. Bind to Value property for single selection mode.

<Typeahead SearchMethod="@SearchState"
           Items="Data.StateList"
           @bind-Value="@SelectedState"
           Placeholder="State">
    <SelectedTemplate Context="state">
        @state.Name
    </SelectedTemplate>
    <ResultTemplate Context="state">
        @state.Name
    </ResultTemplate>
</Typeahead>
@code {
    public StateLocation SelectedState { get; set; }

    public Task<IEnumerable<StateLocation>> SearchState(string searchText)
    {
        var result = Data.StateList
            .Where(x => x.Name.ToLower().Contains(searchText.ToLower()))
            .ToList();

        return Task.FromResult<IEnumerable<StateLocation>>(result);
    }
}

Multiselect Example

When you want to be able to select multiple results. Bind to the Values property. The target property must be type IList<T>.

<Typeahead SearchMethod="@SearchPeople"
           Items="Data.PersonList"
           @bind-Values="@SelectedPeople"
           Placeholder="Owners">
    <SelectedTemplate Context="person">
        @person.FullName
    </SelectedTemplate>
    <ResultTemplate Context="person">
        @person.FullName
    </ResultTemplate>
</Typeahead>
@code {
    public IList<Person> SelectedPeople;

    public Task<IEnumerable<Person>> SearchPeople(string searchText)
    {
        var result = Data.PersonList
            .Where(x => x.FullName.ToLower().Contains(searchText.ToLower()))
            .ToList();

        return Task.FromResult<IEnumerable<Person>>(result);
    }
 }

GitHub Repository Search

Use Octokit to search for a GitHub repository.

<Typeahead SearchMethod="@SearchGithub"
           @bind-Value="@SelectedRepository"
           Placeholder="Repository"
           MinimumLength="3">
    <SelectedTemplate Context="repo">
        @repo.FullName
    </SelectedTemplate>
    <ResultTemplate Context="repo">
        <div class="github-repository clearfix">
            <div class="github-avatar"><img src="@repo.Owner.AvatarUrl"></div>
            <div class="github-meta">
                <div class="github-title">@repo.FullName</div>
                <div class="github-description">@repo.Description</div>
                <div class="github-statistics">
                    <div class="github-forks"><i class="fa fa-flash"></i> @repo.ForksCount Forks</div>
                    <div class="github-stargazers"><i class="fa fa-star"></i> @repo.StargazersCount Stars</div>
                    <div class="github-watchers"><i class="fa fa-eye"></i> @repo.SubscribersCount Watchers</div>
                </div>
            </div>
        </div>
    </ResultTemplate>
</Typeahead>
@inject IGitHubClient GitHubClient;

@code {
    public Repository SelectedRepository { get; set; }

    public async Task<IEnumerable<Repository>> SearchGithub(string searchText)
    {
        var request = new SearchRepositoriesRequest(searchText);
        var result = await GitHubClient.Search.SearchRepo(request);

        return result.Items;
    }
}

More Repositories

1

msbuildtasks

The MSBuild Community Tasks Project is an open source project for MSBuild tasks.
C#
947
star
2

EntityFrameworkCore.Generator

Generate Entity Framework Core model from an existing database
C#
376
star
3

Injectio

Source generator that helps register attribute marked services in the dependency injection ServiceCollection
C#
104
star
4

Calculator

Calculator.NET - Calculator that evaluates math expressions
C#
92
star
5

NLog.Mongo

MongoDB Target for NLog
C#
67
star
6

MongoDB.Messaging

MongoDB Messaging Library
C#
60
star
7

FluentRest

Lightweight fluent wrapper over HttpClient to make REST calls easier
C#
59
star
8

NetSpell

Spell Checker for .NET
C#
52
star
9

DataGenerator

Automatically generate data for an object
C#
51
star
10

KickStart

Application initialization helper
C#
42
star
11

EntityChange

Library to compare two object graphs detecting change
C#
36
star
12

Estimatorx

A simple project estimation application.
C#
27
star
13

MediatR.CommandQuery

CQRS framework based on MediatR
C#
23
star
14

FluentCommand

Fluent Wrapper for DbCommand
C#
17
star
15

DotNet.Property

.NET Core command-line (CLI) tool to update project properties and version numbers on build
C#
14
star
16

AutoPoco.Extensions

Additional conventions and data sources for AutoPoco.
C#
8
star
17

LoreSoft.Shared

Fast reflection library
C#
8
star
18

NLog.Xml

NLog xml layout and render
C#
7
star
19

PLINQO.EntityFramework.DbContext

Entity Framework DbContext templates for CodeSmith Generator
C#
7
star
20

MongoDB.Abstracts

MongoDB abstract repository pattern
C#
7
star
21

TypeScriptGenerator

CodeSmith Template to generate TypeScript interface for .NET a class
C#
6
star
22

NLog.Fluent

Fluent API for NLog
C#
6
star
23

InstructorIQ

Training calendar manangement
JavaScript
6
star
24

ShellTools

Windows Shell Tools
C#
4
star
25

ReflectionAccessor

Fast late bound reflection type access
C#
4
star
26

SvnTools

Backup Tool For Subversion Repositories
C#
4
star
27

PLINQO.EntityFrameworkCore

Entity Framework Core templates for CodeSmith Generator
C#
4
star
28

ServiceFramework

Processing service framework
C#
3
star
29

FluentLogger

Fluent logger abstraction as a NuGet source code package
C#
3
star
30

AspNetCore.SecurityKey

Security API Key Authentication Implementation for ASP.NET Core
C#
3
star
31

XmlFormatter

Format Xml Documents
C#
2
star
32

Cosmos.Abstracts

Cosmos DB Abstracts library defines abstract base classes for repository pattern.
C#
2
star
33

Cosmos.Identity

Cosmos DB provider for ASP.NET Core Identity framework
C#
1
star
34

mp4v2.net

Fork of MP4v2 Library for .net
1
star
35

AssemblyMetadata.Generators

Source generator to expose assembly attributes as string constants.
C#
1
star
36

FluentHtml

Fluent Html Helper for Asp.net MVC
C#
1
star
37

Blazone

Blazone is a simple authentication module for Blazor
C#
1
star
38

TableStorage.Abstracts

Azure Table Storage Abstracts library defines abstract base classes for repository pattern.
C#
1
star