Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>10.0.1</Version>
<Version>10.0.2</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,35 @@
namespace BootstrapBlazor.Components;

/// <summary>
/// SelectCity 组件
/// <para lang="zh">SelectCity 组件</para>
/// <para lang="en">SelectCity component</para>
/// </summary>
public partial class SelectCity
{
/// <summary>
/// 获得/设置 是否可多选 默认 false 单选
/// <para lang="zh">获得/设置 是否可多选,默认 false 单选</para>
/// <para lang="en">Gets or sets whether multiple selection is enabled. Default is false (single selection)</para>
/// </summary>
[Parameter]
public bool IsMultiple { get; set; }

/// <summary>
/// 获得/设置 是否开启搜索功能 默认 true 开启
/// <para lang="zh">获得/设置 是否开启搜索功能,默认 true 开启</para>
/// <para lang="en">Gets or sets whether search is enabled. Default is true</para>
/// </summary>
[Parameter]
public bool ShowSearch { get; set; } = true;

/// <summary>
/// Gets or sets the search icon.
/// <para lang="zh">获得/设置 搜索图标</para>
/// <para lang="en">Gets or sets the search icon</para>
/// </summary>
[Parameter]
public string? SearchIcon { get; set; }

/// <summary>
/// 获得/设置 单选时选择后是否自动关闭 默认 true
/// <para><see cref="IsMultiple"/> 值为 true 时,这个参数不生效</para>
/// <para lang="zh">获得/设置 单选时选择后是否自动关闭默认 true <see cref="IsMultiple"/> 值为 true 时,这个参数不生效</para>
/// <para lang="en">Gets or sets whether to automatically close after selection when single selection is enabled. Default is true. This parameter does not take effect when <see cref="IsMultiple"/> is true</para>
/// </summary>
[Parameter]
public bool AutoClose { get; set; } = true;
Expand Down Expand Up @@ -87,7 +91,6 @@ protected override void OnParametersSet()
/// <inheritdoc/>
/// </summary>
/// <param name="firstRender"></param>
/// <returns></returns>
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
Expand All @@ -107,17 +110,16 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <returns></returns>
protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, new
{
TriggerSearch = nameof(TriggerSearch)
});

/// <summary>
/// 触发过滤方法 由 JavaScript 触发
/// <para lang="zh">触发过滤方法,由 JavaScript 触发</para>
/// <para lang="en">Trigger filter method, invoked by JavaScript</para>
/// </summary>
/// <param name="v"></param>
/// <returns></returns>
[JSInvokable]
public void TriggerSearch(string v)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). 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/

namespace BootstrapBlazor.Components;

/// <summary>
/// SelectProvince 组件
/// <para lang="zh">SelectProvince 组件</para>
/// <para lang="en">SelectProvince component</para>
/// </summary>
public partial class SelectProvince
{
/// <summary>
/// 获得/设置 是否可多选 默认 false 单选
/// <para lang="zh">获得/设置 是否可多选,默认 false 单选</para>
/// <para lang="en">Gets or sets whether multiple selection is enabled. Default is false (single selection)</para>
/// </summary>
[Parameter]
public bool IsMultiple { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). 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/

namespace BootstrapBlazor.Components;

/// <summary>
/// SelectRegion 组件
/// <para lang="zh">SelectRegion 组件</para>
/// <para lang="en">SelectRegion component</para>
/// </summary>
public partial class SelectRegion
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,71 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). 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/

namespace BootstrapBlazor.Components;

/// <summary>
/// SelectRegion 组件基类
/// <para lang="zh">SelectRegion 组件基类</para>
/// <para lang="en">SelectRegion component base class</para>
/// </summary>
public abstract class SelectRegionBase : PopoverSelectBase<string>
{
/// <summary>
/// Gets or sets the placeholder text.
/// <para lang="zh">获得/设置 占位符文本</para>
/// <para lang="en">Gets or sets the placeholder text</para>
/// </summary>
[Parameter]
public string? PlaceHolder { get; set; }

/// <summary>
/// Gets or sets the color. The default is <see cref="Color.None"/> (no color).
/// <para lang="zh">获得/设置 颜色,默认为 <see cref="Color.None"/>(无颜色)</para>
/// <para lang="en">Gets or sets the color. The default is <see cref="Color.None"/> (no color)</para>
/// </summary>
[Parameter]
public Color Color { get; set; }

/// <summary>
/// Gets or sets the dropdown icon. The default is "fa-solid fa-angle-up".
/// <para lang="zh">获得/设置 下拉图标,默认为 fa-solid fa-angle-up</para>
/// <para lang="en">Gets or sets the dropdown icon. The default is "fa-solid fa-angle-up"</para>
/// </summary>
[Parameter]
[NotNull]
public string? DropdownIcon { get; set; }
Comment on lines 27 to 33
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML docs claim the default DropdownIcon is the literal CSS class "fa-solid fa-angle-up", but the actual default is resolved at runtime via IconTheme.GetIconByKey(ComponentIcons.SelectDropdownIcon). Please update the docs to reflect the real default behavior (theme key-based), otherwise the documentation will be misleading when icon themes change.

Copilot uses AI. Check for mistakes.

/// <summary>
/// Gets or sets the callback method when the clear button is clicked. Default is null.
/// <para lang="zh">获得/设置 点击清空按钮时的回调方法,默认为 null</para>
/// <para lang="en">Gets or sets the callback method when the clear button is clicked. Default is null</para>
/// </summary>
[Parameter]
public Func<Task>? OnClearAsync { get; set; }

/// <summary>
/// Gets or sets the right-side clear icon. Default is fa-solid fa-angle-up.
/// <para lang="zh">获得/设置 右侧清空图标,默认为 fa-solid fa-angle-up</para>
/// <para lang="en">Gets or sets the right-side clear icon. Default is fa-solid fa-angle-up</para>
/// </summary>
[Parameter]
[NotNull]
public string? ClearIcon { get; set; }
Comment on lines 42 to 48
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML docs claim the default ClearIcon is "fa-solid fa-angle-up", but the actual default is pulled from IconTheme using ComponentIcons.SelectClearIcon. Please align the docs with the implementation (theme key-based default), so consumers don’t hardcode the wrong icon class.

Copilot uses AI. Check for mistakes.

/// <summary>
/// Gets or sets the <see cref="IIconTheme"/> service instance.
/// <para lang="zh">获得/设置 <see cref="IIconTheme"/> 服务实例</para>
/// <para lang="en">Gets or sets the <see cref="IIconTheme"/> service instance</para>
/// </summary>
[Inject]
[NotNull]
protected IIconTheme? IconTheme { get; set; }

/// <summary>
/// <see cref="IRegionService"/> service instance
/// <para lang="zh">获得/设置 <see cref="IRegionService"/> 服务实例</para>
/// <para lang="en">Gets or sets the <see cref="IRegionService"/> service instance</para>
/// </summary>
[Inject]
[NotNull]
protected IRegionService? RegionService { get; set; }

/// <summary>
/// 文本框样式
/// <para lang="zh">获得 文本框样式</para>
/// <para lang="en">Gets the input box style</para>
/// </summary>
protected string? InputClassString => CssBuilder.Default("form-select form-control")
.AddClass($"border-{Color.ToDescriptionString()}", Color != Color.None && !IsDisabled && !IsValid.HasValue)
Expand All @@ -66,7 +75,8 @@ public abstract class SelectRegionBase : PopoverSelectBase<string>
.Build();

/// <summary>
/// 下拉框按钮样式
/// <para lang="zh">获得 下拉框按钮样式</para>
/// <para lang="en">Gets the dropdown button style</para>
/// </summary>
protected string? AppendClassString => CssBuilder.Default("form-select-append")
.AddClass($"text-{Color.ToDescriptionString()}", Color != Color.None && !IsDisabled && !IsValid.HasValue)
Expand All @@ -75,7 +85,8 @@ public abstract class SelectRegionBase : PopoverSelectBase<string>
.Build();

/// <summary>
/// 清空按钮样式
/// <para lang="zh">获得 清空按钮样式</para>
/// <para lang="en">Gets the clear button style</para>
/// </summary>
protected string? ClearClassString => CssBuilder.Default("clear-icon")
.AddClass($"text-{Color.ToDescriptionString()}", Color != Color.None)
Expand All @@ -84,7 +95,8 @@ public abstract class SelectRegionBase : PopoverSelectBase<string>
.Build();

/// <summary>
/// 获得 选择框组件 Id
/// <para lang="zh">获得 选择框组件 Id</para>
/// <para lang="en">Gets the select component Id</para>
/// </summary>
protected string InputId => $"{Id}_input";

Expand Down
14 changes: 13 additions & 1 deletion src/components/BootstrapBlazor.Region/Data/CityItem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). 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/

namespace BootstrapBlazor.Components;

/// <summary>
/// <para lang="zh">城市项</para>
/// <para lang="en">City item</para>
/// </summary>
readonly record struct CityItem
{
/// <summary>
/// <para lang="zh">获得 名称</para>
/// <para lang="en">Gets the name</para>
/// </summary>
public string Name { get; init; }

/// <summary>
/// <para lang="zh">获得 拼音集合</para>
/// <para lang="en">Gets the pinyin collection</para>
/// </summary>
public HashSet<string> PinYin { get; init; }
}
11 changes: 7 additions & 4 deletions src/components/BootstrapBlazor.Region/Data/CountyItem.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). 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/

namespace BootstrapBlazor.Components;

/// <summary>
/// Region 类
/// <para lang="zh">区县项</para>
/// <para lang="en">County item</para>
/// </summary>
public readonly record struct CountyItem
{
/// <summary>
/// 城市编码
/// <para lang="zh">获得 城市编码</para>
/// <para lang="en">Gets the city code</para>
/// </summary>
public string Code { get; init; }

/// <summary>
/// 城市名称
/// <para lang="zh">获得 城市名称</para>
/// <para lang="en">Gets the city name</para>
/// </summary>
public string Name { get; init; }
}
18 changes: 17 additions & 1 deletion src/components/BootstrapBlazor.Region/Data/ProvinceItem.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). 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/

namespace BootstrapBlazor.Components;

/// <summary>
/// <para lang="zh">省份项</para>
/// <para lang="en">Province item</para>
/// </summary>
readonly record struct ProvinceItem
{
/// <summary>
/// <para lang="zh">获得 名称</para>
/// <para lang="en">Gets the name</para>
/// </summary>
public string Name { get; init; }

/// <summary>
/// <para lang="zh">获得 拼音集合</para>
/// <para lang="en">Gets the pinyin collection</para>
/// </summary>
public HashSet<string> PinYin { get; init; }

/// <summary>
/// <para lang="zh">获得 城市集合</para>
/// <para lang="en">Gets the cities collection</para>
/// </summary>
public HashSet<CityItem> Cities { get; init; }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). 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/

Expand All @@ -7,15 +7,16 @@
namespace BootstrapBlazor.Components;

/// <summary>
/// BootstrapBlazor service extensions
/// <para lang="zh">BootstrapBlazor 服务扩展</para>
/// <para lang="en">BootstrapBlazor service extensions</para>
/// </summary>
public static class ServiceCollectionExtension
{
/// <summary>
/// Inject <see cref="IRegionService"/> service extension method.
/// <para lang="zh">注入 <see cref="IRegionService"/> 服务扩展方法</para>
/// <para lang="en">Injects <see cref="IRegionService"/> service extension method</para>
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddBootstrapBlazorRegionService(this IServiceCollection services)
{
services.AddSingleton<IRegionService, DefaultRegionService>();
Expand Down
21 changes: 11 additions & 10 deletions src/components/BootstrapBlazor.Region/Services/IRegionService.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). 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/

namespace BootstrapBlazor.Components;

/// <summary>
/// IRegion 获得行政区域数据接口
/// <para lang="zh">获得行政区域数据接口</para>
/// <para lang="en">Region data service interface</para>
/// </summary>
public interface IRegionService
{
/// <summary>
/// 获得所有省份数据
/// <para lang="zh">获得所有省份数据</para>
/// <para lang="en">Gets all province data</para>
/// </summary>
/// <returns></returns>
HashSet<string> GetProvinces();

/// <summary>
/// 获得指定省份的城市数据
/// <para lang="zh">获得指定省份的城市数据</para>
/// <para lang="en">Gets cities for the specified province</para>
/// </summary>
/// <param name="province"></param>
/// <returns></returns>
HashSet<string> GetCities(string province);

/// <summary>
/// 获得指定城市的区县数据
/// <para lang="zh">获得指定城市的区县数据</para>
/// <para lang="en">Gets counties for the specified city</para>
/// </summary>
/// <param name="city"></param>
/// <returns></returns>
HashSet<CountyItem> GetCounties(string city);

/// <summary>
/// 获得指定区县的街道地址数据
/// <para lang="zh">获得指定区县的街道地址数据</para>
/// <para lang="en">Gets detail addresses for the specified county</para>
/// </summary>
/// <param name="countyCode"></param>
/// <returns></returns>
HashSet<string> GetDetails(string countyCode);
}