Enterprise-level component library based on Bootstrap and Blazor

star nuget license download repo commit master coverage

AutoComplete

The input box autocompletes the function

By setting Items data collection when the user types information that is automatically displayed

Demo

In this example, type 123 strings to display the viewing effect, automatically give the component initialization to the auto-prompt dataset, and the dataset does not change

By setting the IsLikeMatch value settings to turn on fuzzy matching of collections, you control whether case is ignored by setting the IgnoreCase

Demo

In this example, type the abc string to display the viewing effect and select all matches in the collection that contain abc and have the same case

By setting the NoDataTip value setting automatically completes the custom prompt message that appears when the data is not found

Demo

In this example, type 567 strings because the autocomplete information center does not display custom prompt information - the data you want is not found

By setting up ValueChanged callback method reorganizes the data collection based on the data entered by the user before prompting for information

Demo

In this example, type any string to display the viewing effect, and automatically complete the component's dynamic changes from the newly obtained prompt dataset based on the string you type

When a component binds in both directions, it automatically determines whether label text is displayed based on the conditions

Demo

The pre-label explicit rules are consistent with the BootstrapInput component of the [portal]

Bidirectional binding displays labels
Bidirectional bindings do not display labels
Customize DisplayText

Set Debounce value turn on debounce

Demo

In this example, please type any string to display the viewing effect. Within the anti shake time, the auto completion component will only send the results to the back end after the last entry, which will greatly improve the performance

Attributes

Loading...
@page "/autocompletes"
@inject IStringLocalizer<AutoCompletes>  Localizer

<h3>AutoComplete</h3>

<h4>The input box autocompletes the function</h4>

<DemoBlock Title="Basic usage" Introduction="By setting <code>Items</code> data collection when the user types information that is automatically displayed" Name="Normal">
    <p>In this example, type 123 strings to display the viewing effect, automatically give the component initialization to the auto-prompt dataset, and the dataset does not change</p>
    <div style="width: 200px;">
        <AutoComplete Items="@StaticItems" IsSelectAllTextOnFocus="true" />
    </div>
</DemoBlock>

<DemoBlock Title="Blur queries and ignore case" Introduction="By setting the <code>IsLikeMatch</code> value settings to turn on fuzzy matching of collections, you control whether case is ignored by setting the <code>IgnoreCase</code>" Name="LikeMatch">
    <p>In this example, type the abc string to display the viewing effect and select all matches in the collection that contain abc and have the same case</p>
    <div style="width: 200px;">
        <AutoComplete Items="@StaticItems" IsLikeMatch="true" IgnoreCase="false" />
    </div>
</DemoBlock>

<DemoBlock Title="Custom prompt message" Introduction="By setting the <code>NoDataTip</code> value setting automatically completes the custom prompt message that appears when the data is not found" Name="NoDataTip">
    <p>In this example, type 567 strings because the autocomplete information center does not display custom prompt information - <code>the data you want is not found</code></p>
    <div style="width: 200px;">
        <AutoComplete Items="@StaticItems" NoDataTip="There is nothing" />
    </div>
</DemoBlock>

<DemoBlock Title="Custom candidates" Introduction="By setting up <code>ValueChanged</code> callback method reorganizes the data collection based on the data entered by the user before prompting for information" Name="ValueChanged">
    <p>In this example, type any string to display the viewing effect, and automatically complete the component's dynamic changes from the newly obtained prompt dataset based on the string you type</p>
    <div style="width: 200px;">
        <AutoComplete Items="@Items" ValueChanged="@OnValueChanged" />
    </div>
</DemoBlock>

<DemoBlock Title="The label is displayed" Introduction="When a component binds in both directions, it automatically determines whether label text is displayed based on the conditions" Name="ShowLabel">
    <p>The pre-label explicit rules are consistent with the <code>BootstrapInput</code> component of the <a href='inputs'>[portal]</a></p>
    <Divider Text="Bidirectional binding displays labels" Alignment="Alignment.Left" style="margin: 2rem 0;"></Divider>
    <ValidateForm Model="@Model">
        <AutoComplete Items="@StaticItems" @bind-Value="@Model.Name" ShowLabel="true" />
    </ValidateForm>
    <Divider Text="Bidirectional bindings do not display labels" Alignment="Alignment.Left" style="margin: 2rem 0;" />
    <AutoComplete Items="@StaticItems" @bind-Value="@Model.Name" ShowLabel="false" />
    <Divider Text="Customize DisplayText" Alignment="Alignment.Left" style="margin: 2rem 0;"></Divider>
    <AutoComplete Items="@StaticItems" @bind-Value="@Model.Name" DisplayText="Custom city" ShowLabel="true" />
</DemoBlock>

<DemoBlock Title="Debounce" Introduction="Set <code>Debounce</code> value turn on debounce" Name="Debounce">
    <p>In this example, please type any string to display the viewing effect. Within the anti shake time, the auto completion component will only send the results to the back end after the last entry, which will greatly improve the performance</p>
    <div style="width: 200px;">
        <AutoComplete Items="@Items" ValueChanged="@OnValueChanged" Debounce="500" />
    </div>
</DemoBlock>

<AttributeTable Items="@GetAttributes()" />
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

using BootstrapBlazor.Shared.Common;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BootstrapBlazor.Shared.Samples;

/// <summary>
///
/// </summary>
public sealed partial class AutoCompletes
{
    private readonly List<string> _items = new();

    private IEnumerable<string> Items => _items;

    private Foo Model { get; set; } = new Foo() { Name = "" };

    private static List<string> StaticItems => new() { "1", "12", "123", "1234", "12345", "123456", "abc", "abcdef", "ABC", "aBcDeFg", "ABCDEFG" };

    private Task OnValueChanged(string val)
    {
        _items.Clear();
        _items.Add($"{val}@163.com");
        _items.Add($"{val}@126.com");
        _items.Add($"{val}@sina.com");
        _items.Add($"{val}@hotmail.com");
        return Task.CompletedTask;
    }

    /// <summary>
    /// 获得属性方法
    /// </summary>
    /// <returns></returns>
    private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
    {
            // TODO: 移动到数据库中
            new AttributeItem() {
                Name = "ShowLabel",
                Description = Localizer["Att1"],
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "true"
            },
            new AttributeItem() {
                Name = "ChildContent",
                Description = Localizer["Att2"],
                Type = "RenderFragment",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "Items",
                Description = Localizer["Att3"],
                Type = "IEnumerable<string>",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "NoDataTip",
                Description = Localizer["Att4"],
                Type = "string",
                ValueList = " — ",
                DefaultValue = Localizer["Att4DefaultValue"]!
            },
            new AttributeItem() {
                Name = "DisplayCount",
                Description = Localizer["Att5"],
                Type = "int?",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "ValueChanged",
                Description = Localizer["Att6"],
                Type = "Action<string>",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "IsLikeMatch",
                Description = Localizer["Att7"],
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "false"
            },
            new AttributeItem()
            {
                Name = "IgnoreCase",
                Description = Localizer["Att8"],
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "true"
            },
            new AttributeItem()
            {
                Name = "CustomFilter",
                Description = Localizer["Att9"],
                Type = "Func<Task<IEnumerable<string>>>",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem()
            {
                Name = "Debounce",
                Description = Localizer["Att10"],
                Type = "int",
                ValueList = " — ",
                DefaultValue = "0"
            }
    };
}

B 站相关视频链接

暂无

交流群

QQ Group:BootstrapAdmin & Blazor 795206915 675147445 Welcome to join the group discussion
Themes
Bootstrap
Motronic
Ant Design (完善中)
LayUI (完善中)
An error has occurred. This application may no longer respond until reloaded. Reload