Skip to content

Commit 1de188f

Browse files
ArgoZhangice6
andcommitted
Merge branch 'main' into feat-input
Co-Authored-By: ice6 <[email protected]>
2 parents 374508f + 575f399 commit 1de188f

File tree

14 files changed

+148
-17
lines changed

14 files changed

+148
-17
lines changed

src/BootstrapBlazor.Server/Components/Samples/Cascaders.razor

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@
6060
</DemoBlock>
6161

6262
<DemoBlock Title="@Localizer["Block3Title"]" Introduction="@Localizer["Block3Intro"]" Name="Bind">
63+
<section ignore>
64+
@((MarkupString)Localizer["Block3Desc"].Value)
65+
</section>
6366
<div class="row g-3">
6467
<div class="col-12 col-sm-6">
65-
<Cascader Color="Color.Primary" Items="@_items" @bind-Value="@Value" />
68+
<Cascader Color="Color.Primary" Items="@_items" @bind-Value="@Value" IsClearable="true" />
6669
</div>
6770
<div class="col-12 col-sm-6">
6871
<BootstrapInput readonly @bind-Value="@Value" />

src/BootstrapBlazor.Server/Components/Samples/Lights.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@
9494
<Light Color="Color.Warning" IsFlat="true"></Light>
9595
</div>
9696
<div class="col-12 col-sm-4 col-md-3 col-lg-auto">
97-
<Light Color="Color.Primary" IsFlat="true"></Light>
97+
<Light Color="Color.Primary" IsFlat="true" IsFlash="true"></Light>
9898
</div>
9999
<div class="col-12 col-sm-4 col-md-3 col-lg-auto">
100-
<Light Color="Color.Secondary" IsFlat="true"></Light>
100+
<Light Color="Color.Secondary" IsFlat="true" IsFlash="true"></Light>
101101
</div>
102102
<div class="col-12 col-sm-4 col-md-3 col-lg-auto">
103-
<Light Color="Color.Dark" IsFlat="true"></Light>
103+
<Light Color="Color.Dark" IsFlat="true" IsFlash="true"></Light>
104104
</div>
105105
</div>
106106
<div class="row g-3 light-sm">

src/BootstrapBlazor.Server/Components/Samples/SelectObjects.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<section ignore>
1111
@((MarkupString)Localizer["NormalDesc"].Value)
1212
</section>
13-
<SelectObject @bind-Value="_value" GetTextCallback="GetTextCallback" IsClearable>
13+
<SelectObject @bind-Value="_value" GetTextCallback="GetTextCallback" IsClearable="true">
1414
<ListView TItem="ListViews.Product" Items="@Products" OnListViewItemClick="item => OnListViewItemClick(item, context)">
1515
<BodyTemplate Context="value">
1616
<Card>

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,14 @@
485485
"LightsNormalTitle": "common usage",
486486
"LightsNormalIntro": "for status indication",
487487
"LightsFlashingTitle": "flicker",
488-
"LightsFlashingIntro": "Flash the light by setting the property <code>IsFlash</code>",
488+
"LightsFlashingIntro": "Flash the light by setting the parameter <code>IsFlash</code>",
489489
"LightsColorTitle": "discoloration",
490-
"LightsColorIntro": "Color the light by setting the value of the property <code>Color</code>",
490+
"LightsColorIntro": "Color the light by setting the value of the parameter <code>Color</code>",
491491
"LightsTooltipTextTitle": "prompt text",
492492
"LightsTooltipTextIntro": "By setting the value of the attribute <code>TooltipText</code> to make the <code>tooltip</code> text prompt when the mouse hovers over the indicator light",
493-
"TooltipText": "I am prompt text message"
493+
"TooltipText": "I am prompt text message",
494+
"LightsFlatTitle": "Flat",
495+
"LightsFlatIntro": "Make the indicator light flat by setting the parameter <code>IsFlat</code>"
494496
},
495497
"BootstrapBlazor.Server.Components.Samples.Charts.Index": {
496498
"Chart": "Chart",
@@ -2282,6 +2284,7 @@
22822284
"Block2Intro": "Cascading selection is not available",
22832285
"Block3Title": "Two-way binding",
22842286
"Block3Intro": "The values in the text box change when you change the cascading selection option by binding the <code>Value</code> property with the <code>Select</code> component.",
2287+
"Block3Desc": "You can use <code>IsClearable</code> to control whether to display the clear button. The default value is <code>false</code>",
22852288
"Block4Title": "Client validation",
22862289
"Block4Intro": "When cascading selection is not selected, click the submit button to block.",
22872290
"Block5Title": "The binding generic is the Guid structure",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,9 @@
490490
"LightsColorIntro": "通过设置属性 <code>Color</code> 值使指示灯进行变色",
491491
"LightsTooltipTextTitle": "提示文字",
492492
"LightsTooltipTextIntro": "通过设置属性 <code>TooltipText</code> 值使鼠标悬浮指示灯上时提示 <code>tooltip</code> 文字",
493-
"TooltipText": "我是提示文字信息"
493+
"TooltipText": "我是提示文字信息",
494+
"LightsFlatTitle": "扁平化",
495+
"LightsFlatIntro": "通过设置属性 <code>IsFlat</code> 使指示灯扁平化"
494496
},
495497
"BootstrapBlazor.Server.Components.Samples.Charts.Index": {
496498
"Chart": "Chart 图表",
@@ -2282,6 +2284,7 @@
22822284
"Block2Intro": "级联选择不可用状态",
22832285
"Block3Title": "Cascader 双向绑定",
22842286
"Block3Intro": "通过 <code>Select</code> 组件绑定 <code>Value</code> 属性,改变级联选择选项时,文本框内的数值随之改变。",
2287+
"Block3Desc": "通过设置 <code>Clearable=\"true\"</code> 参数,使组件获得焦点或者鼠标悬浮时显示一个 <b>清除</b> 小按钮",
22852288
"Block4Title": "Cascader 客户端验证",
22862289
"Block4Intro": "级联选择未选择时,点击提交按钮时拦截。",
22872290
"Block5Title": "绑定泛型为 Guid 结构",

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.2.7-beta02</Version>
4+
<Version>9.2.7-beta03</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Cascader/Cascader.razor

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
<div @attributes="AdditionalAttributes" id="@Id" class="@ClassString" tabindex="-1">
1010
<input type="text" id="@InputId" readonly disabled="@Disabled" class="@InputClassName" data-bs-toggle="dropdown" placeholder="@PlaceHolder" value="@DisplayTextString" @onblur="OnBlur" />
1111
<span class="@AppendClassName"><i class="@Icon"></i></span>
12+
@if (GetClearable())
13+
{
14+
<span class="@ClearClassString" @onclick="OnClearValue"><i class="@ClearIcon"></i></span>
15+
}
1216
<div class="dropdown-menu shadow">
1317
<CascadingValue Value="SelectedItems">
1418
@foreach (var item in Items)

src/BootstrapBlazor/Components/Cascader/Cascader.razor.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@ public partial class Cascader<TValue>
7878
[Parameter]
7979
public string? SubMenuIcon { get; set; }
8080

81+
/// <summary>
82+
/// 获得/设置 是否可清除 默认 false
83+
/// </summary>
84+
[Parameter]
85+
public bool IsClearable { get; set; }
86+
87+
/// <summary>
88+
/// 获得/设置 右侧清除图标 默认 fa-solid fa-angle-up
89+
/// </summary>
90+
[Parameter]
91+
[NotNull]
92+
public string? ClearIcon { get; set; }
93+
94+
/// <summary>
95+
/// 获得/设置 清除文本内容 OnClear 回调方法 默认 null
96+
/// </summary>
97+
[Parameter]
98+
public Func<Task>? OnClearAsync { get; set; }
99+
81100
/// <summary>
82101
/// 获得/设置 失去焦点回调方法 默认 null
83102
/// </summary>
@@ -98,6 +117,12 @@ public partial class Cascader<TValue>
98117
.AddClass(SubMenuIcon, !string.IsNullOrEmpty(SubMenuIcon))
99118
.Build();
100119

120+
private string? ClearClassString => CssBuilder.Default("clear-icon")
121+
.AddClass($"text-{Color.ToDescriptionString()}", Color != Color.None)
122+
.AddClass($"text-success", IsValid.HasValue && IsValid.Value)
123+
.AddClass($"text-danger", IsValid.HasValue && !IsValid.Value)
124+
.Build();
125+
101126
/// <summary>
102127
/// OnParametersSet 方法
103128
/// </summary>
@@ -107,6 +132,7 @@ protected override void OnParametersSet()
107132

108133
Icon ??= IconTheme.GetIconByKey(ComponentIcons.CascaderIcon);
109134
SubMenuIcon ??= IconTheme.GetIconByKey(ComponentIcons.CascaderSubMenuIcon);
135+
ClearIcon ??= IconTheme.GetIconByKey(ComponentIcons.SelectClearIcon);
110136

111137
Items ??= [];
112138

@@ -178,6 +204,7 @@ private void SetDefaultValue(string defaultValue)
178204

179205
private string? ClassString => CssBuilder.Default("select cascade menu dropdown")
180206
.AddClass("disabled", IsDisabled)
207+
.AddClass("cls", IsClearable)
181208
.AddClass(CssClass).AddClass(ValidCss)
182209
.Build();
183210

@@ -196,6 +223,8 @@ private void SetDefaultValue(string defaultValue)
196223
.AddClass($"text-{Color.ToDescriptionString()}", Color != Color.None && !IsDisabled)
197224
.Build();
198225

226+
private bool GetClearable() => IsClearable && !IsDisabled;
227+
199228
/// <summary>
200229
/// 选择项是否 Active 方法
201230
/// </summary>
@@ -252,4 +281,14 @@ private static void SetSelectedNodeWithParent(CascaderItem? item, List<CascaderI
252281
list.Add(item);
253282
}
254283
}
284+
285+
private async Task OnClearValue()
286+
{
287+
if (OnClearAsync != null)
288+
{
289+
await OnClearAsync();
290+
}
291+
292+
CurrentValue = default;
293+
}
255294
}

src/BootstrapBlazor/Components/Light/Light.razor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public partial class Light
1616
protected string? ClassString => CssBuilder.Default("light")
1717
.AddClass("is-flat", IsFlat)
1818
.AddClass("flash", IsFlash && !IsFlat)
19+
.AddClass("is-flat-flash", IsFlash && IsFlat)
1920
.AddClass($"light-{Color.ToDescriptionString()}", Color != Color.None)
2021
.AddClassFromAttributes(AdditionalAttributes)
2122
.Build();

src/BootstrapBlazor/Components/Light/Light.razor.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
height: 100%;
7777
border-radius: 50%;
7878
border: 1px solid var(--bb-light-bg);
79+
}
80+
81+
&.is-flat-flash:after {
7982
animation: light-flat 1.2s infinite ease-in-out;
8083
}
8184
}
@@ -196,7 +199,7 @@
196199
@include animation(light-danger, #e17777, #892726);
197200
@include animation(light-success, #5cb85c, #116811);
198201
@include animation(light-info, #5bc0de, #1d7792);
199-
@include animation(light-light-warning, #ffc107, #cc9f18);
202+
@include animation(light-warning, #ffc107, #cc9f18);
200203
@include animation(light-primary, #007bff, #0f5fb5);
201204
@include animation(light-secondary, #6c757d, #4b5054);
202205
@include animation(light-dark, #6061e2, #3232a0);

0 commit comments

Comments
 (0)