Skip to content

Commit cf0f68b

Browse files
committed
1. 新增颜色选择器组件 <util-color-picker> .
2. 新增颜色块组件 <util-color-block> . 3. Razor页面监视服务 Util.Ui.Razor.RazorWatchService 改进新增Razor文件和异常处理逻辑.
1 parent 41a673e commit cf0f68b

25 files changed

+1190
-113
lines changed

build/version.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<VersionMajor>8</VersionMajor>
44
<VersionMinor>0</VersionMinor>
5-
<VersionPatch>10</VersionPatch>
5+
<VersionPatch>11</VersionPatch>
66
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
77
<VersionSuffix></VersionSuffix>
88
</PropertyGroup>

src/Util.Ui.Angular/Configs/AngularConst.cs

+16
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public static class AngularConst {
5353
/// </summary>
5454
public const string BindAcl = "bind-acl";
5555
/// <summary>
56+
/// 触发器
57+
/// </summary>
58+
public const string BindTrigger = "bind-trigger";
59+
/// <summary>
5660
/// 首页
5761
/// </summary>
5862
public const string BindHome = "bind-home";
@@ -73,6 +77,10 @@ public static class AngularConst {
7377
/// </summary>
7478
public const string BindRecursiveBreadcrumb = "bind-recursive-breadcrumb";
7579
/// <summary>
80+
/// 禁用透明度
81+
/// </summary>
82+
public const string BindDisabledAlpha = "bind-disabled-alpha";
83+
/// <summary>
7684
/// 定宽
7785
/// </summary>
7886
public const string BindWide = "bind-wide";
@@ -81,6 +89,10 @@ public static class AngularConst {
8189
/// </summary>
8290
public const string BindFixed = "bind-fixed";
8391
/// <summary>
92+
/// 显示文本
93+
/// </summary>
94+
public const string BindShowText = "bind-show-text";
95+
/// <summary>
8496
/// 行数
8597
/// </summary>
8698
public const string BindLines = "bind-lines";
@@ -117,6 +129,10 @@ public static class AngularConst {
117129
/// </summary>
118130
public const string BindText = "bind-text";
119131
/// <summary>
132+
/// 默认值
133+
/// </summary>
134+
public const string BindDefaultValue = "bind-default-value";
135+
/// <summary>
120136
/// 值
121137
/// </summary>
122138
public const string BindValue = "bind-value";

src/Util.Ui.NgZorro/Components/Avatars/AvatarTagHelper.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Microsoft.AspNetCore.Razor.TagHelpers;
22
using Util.Ui.Angular.TagHelpers;
3-
using Util.Ui.Configs;
43
using Util.Ui.NgZorro.Components.Avatars.Renders;
54
using Util.Ui.NgZorro.Enums;
65
using Util.Ui.Renders;

src/Util.Ui.NgZorro/Components/Avatars/Renders/AvatarRender.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Util.Ui.Builders;
2-
using Util.Ui.Configs;
32
using Util.Ui.NgZorro.Components.Avatars.Builders;
43
using Util.Ui.NgZorro.Components.Comments.Configs;
54
using Util.Ui.Renders;

src/Util.Ui.NgZorro/Components/Cards/Builders/CardBuilder.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Util.Ui.Angular.Builders;
22
using Util.Ui.Angular.Configs;
33
using Util.Ui.Angular.Extensions;
4-
using Util.Ui.Configs;
54
using Util.Ui.NgZorro.Configs;
65
using Util.Ui.NgZorro.Enums;
76
using Util.Ui.NgZorro.Extensions;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using Util.Ui.Angular.Builders;
2+
using Util.Ui.Angular.Configs;
3+
using Util.Ui.NgZorro.Enums;
4+
5+
namespace Util.Ui.NgZorro.Components.ColorPickers.Builders;
6+
7+
/// <summary>
8+
/// 颜色块标签生成器
9+
/// </summary>
10+
public class ColorBlockBuilder : AngularTagBuilder {
11+
/// <summary>
12+
/// 配置
13+
/// </summary>
14+
private readonly Config _config;
15+
16+
/// <summary>
17+
/// 初始化颜色块标签生成器
18+
/// </summary>
19+
/// <param name="config">配置</param>
20+
public ColorBlockBuilder( Config config ) : base( config, "nz-color-block" ) {
21+
_config = config;
22+
}
23+
24+
/// <summary>
25+
/// 配置颜色
26+
/// </summary>
27+
public ColorBlockBuilder Color() {
28+
AttributeIfNotEmpty( "nzColor", _config.GetValue( UiConst.Color ) );
29+
AttributeIfNotEmpty( "[nzColor]", _config.GetValue( AngularConst.BindColor ) );
30+
return this;
31+
}
32+
33+
/// <summary>
34+
/// 配置控件尺寸
35+
/// </summary>
36+
public ColorBlockBuilder Size() {
37+
AttributeIfNotEmpty( "nzSize", _config.GetValue<InputSize?>( UiConst.Size )?.Description() );
38+
AttributeIfNotEmpty( "[nzSize]", _config.GetValue( AngularConst.BindSize ) );
39+
return this;
40+
}
41+
42+
/// <summary>
43+
/// 配置事件
44+
/// </summary>
45+
public ColorBlockBuilder Events() {
46+
AttributeIfNotEmpty( "(nzOnClick)", _config.GetValue( UiConst.OnClick ) );
47+
return this;
48+
}
49+
50+
/// <summary>
51+
/// 配置
52+
/// </summary>
53+
public override void Config() {
54+
base.Config();
55+
Color().Size().Events();
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
using Util.Ui.Angular.Configs;
2+
using Util.Ui.NgZorro.Components.Base;
3+
using Util.Ui.NgZorro.Configs;
4+
using Util.Ui.NgZorro.Enums;
5+
using Util.Ui.NgZorro.Extensions;
6+
7+
namespace Util.Ui.NgZorro.Components.ColorPickers.Builders;
8+
9+
/// <summary>
10+
/// 颜色选择标签生成器
11+
/// </summary>
12+
public class ColorPickerBuilder : FormControlBuilderBase<ColorPickerBuilder> {
13+
/// <summary>
14+
/// 配置
15+
/// </summary>
16+
private readonly Config _config;
17+
18+
/// <summary>
19+
/// 初始化颜色选择标签生成器
20+
/// </summary>
21+
/// <param name="config">配置</param>
22+
public ColorPickerBuilder( Config config ) : base( config, "nz-color-picker" ) {
23+
_config = config;
24+
}
25+
26+
/// <summary>
27+
/// 配置标题
28+
/// </summary>
29+
public ColorPickerBuilder Title() {
30+
SetTitle( _config.GetValue( UiConst.Title ) );
31+
AttributeIfNotEmpty( "[nzTitle]", _config.GetValue( AngularConst.BindTitle ) );
32+
return this;
33+
}
34+
35+
/// <summary>
36+
/// 设置表单标签文本
37+
/// </summary>
38+
private void SetTitle( string value ) {
39+
var options = NgZorroOptionsService.GetOptions();
40+
if ( options.EnableI18n ) {
41+
this.AttributeByI18n( "[nzTitle]", value );
42+
return;
43+
}
44+
AttributeIfNotEmpty( "nzTitle", value );
45+
}
46+
47+
/// <summary>
48+
/// 配置颜色默认值
49+
/// </summary>
50+
public ColorPickerBuilder DefaultValue() {
51+
AttributeIfNotEmpty( "nzDefaultValue", _config.GetValue( UiConst.DefaultValue ) );
52+
AttributeIfNotEmpty( "[nzDefaultValue]", _config.GetValue( AngularConst.BindDefaultValue ) );
53+
return this;
54+
}
55+
56+
/// <summary>
57+
/// 配置颜色值
58+
/// </summary>
59+
public ColorPickerBuilder Value() {
60+
AttributeIfNotEmpty( "nzValue", _config.GetValue( UiConst.Value ) );
61+
AttributeIfNotEmpty( "[nzValue]", _config.GetValue( AngularConst.BindValue ) );
62+
return this;
63+
}
64+
65+
/// <summary>
66+
/// 配置显示颜色文本
67+
/// </summary>
68+
public ColorPickerBuilder ShowText() {
69+
AttributeIfNotEmpty( "[nzShowText]", _config.GetBoolValue( UiConst.ShowText ) );
70+
AttributeIfNotEmpty( "[nzShowText]", _config.GetValue( AngularConst.BindShowText ) );
71+
return this;
72+
}
73+
74+
/// <summary>
75+
/// 配置控件尺寸
76+
/// </summary>
77+
public ColorPickerBuilder Size() {
78+
AttributeIfNotEmpty( "nzSize", _config.GetValue<InputSize?>( UiConst.Size )?.Description() );
79+
AttributeIfNotEmpty( "[nzSize]", _config.GetValue( AngularConst.BindSize ) );
80+
return this;
81+
}
82+
83+
/// <summary>
84+
/// 配置禁用
85+
/// </summary>
86+
public ColorPickerBuilder Disabled() {
87+
AttributeIfNotEmpty( "[nzDisabled]", _config.GetBoolValue( UiConst.Disabled ) );
88+
AttributeIfNotEmpty( "[nzDisabled]", _config.GetValue( AngularConst.BindDisabled ) );
89+
return this;
90+
}
91+
92+
/// <summary>
93+
/// 配置禁用透明度
94+
/// </summary>
95+
public ColorPickerBuilder DisabledAlpha() {
96+
AttributeIfNotEmpty( "[nzDisabledAlpha]", _config.GetBoolValue( UiConst.DisabledAlpha ) );
97+
AttributeIfNotEmpty( "[nzDisabledAlpha]", _config.GetValue( AngularConst.BindDisabledAlpha ) );
98+
return this;
99+
}
100+
101+
/// <summary>
102+
/// 配置触发模式
103+
/// </summary>
104+
public ColorPickerBuilder Trigger() {
105+
AttributeIfNotEmpty( "nzTrigger", _config.GetValue<ColorPickerTrigger?>( UiConst.Trigger )?.Description() );
106+
AttributeIfNotEmpty( "[nzTrigger]", _config.GetValue( AngularConst.BindTrigger ) );
107+
return this;
108+
}
109+
110+
/// <summary>
111+
/// 配置允许清除
112+
/// </summary>
113+
public ColorPickerBuilder AllowClear() {
114+
AttributeIfNotEmpty( "[nzAllowClear]", _config.GetBoolValue( UiConst.AllowClear ) );
115+
AttributeIfNotEmpty( "[nzAllowClear]", _config.GetValue( AngularConst.BindAllowClear ) );
116+
return this;
117+
}
118+
119+
/// <summary>
120+
/// 配置颜色格式
121+
/// </summary>
122+
public ColorPickerBuilder Format() {
123+
AttributeIfNotEmpty( "nzFormat", _config.GetValue<ColorPickerFormat?>( UiConst.Format )?.Description() );
124+
AttributeIfNotEmpty( "[nzFormat]", _config.GetValue( AngularConst.BindFormat ) );
125+
return this;
126+
}
127+
128+
/// <summary>
129+
/// 配置显示弹出窗口
130+
/// </summary>
131+
public ColorPickerBuilder Open() {
132+
AttributeIfNotEmpty( "[nzOpen]", _config.GetValue( UiConst.Open ) );
133+
return this;
134+
}
135+
136+
/// <summary>
137+
/// 配置事件
138+
/// </summary>
139+
public ColorPickerBuilder Events() {
140+
AttributeIfNotEmpty( "(nzOnChange)", _config.GetValue( UiConst.OnChange ) );
141+
AttributeIfNotEmpty( "(nzOnClear)", _config.GetValue( UiConst.OnClear ) );
142+
AttributeIfNotEmpty( "(nzOnFormatChange)", _config.GetValue( UiConst.OnFormatChange ) );
143+
AttributeIfNotEmpty( "(nzOnOpenChange)", _config.GetValue( UiConst.OnOpenChange ) );
144+
return this;
145+
}
146+
147+
/// <summary>
148+
/// 配置
149+
/// </summary>
150+
public override void Config() {
151+
base.ConfigBase( _config );
152+
ConfigForm().Name().DefaultValue().Value()
153+
.Title().ShowText().Size().Disabled().DisabledAlpha()
154+
.Trigger().AllowClear().Format().Open()
155+
.Events();
156+
}
157+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Microsoft.AspNetCore.Razor.TagHelpers;
2+
using Util.Ui.Angular.TagHelpers;
3+
using Util.Ui.NgZorro.Components.ColorPickers.Renders;
4+
using Util.Ui.NgZorro.Enums;
5+
using Util.Ui.Renders;
6+
7+
namespace Util.Ui.NgZorro.Components.ColorPickers;
8+
9+
/// <summary>
10+
/// 颜色块,生成的标签为&lt;nz-color-block&gt;&lt;/nz-color-block&gt;
11+
/// </summary>
12+
[HtmlTargetElement( "util-color-block" )]
13+
public class ColorBlockTagHelper : AngularTagHelperBase {
14+
/// <summary>
15+
/// 配置
16+
/// </summary>
17+
private Config _config;
18+
/// <summary>
19+
/// nzColor, 颜色值, 默认值: #1677ff
20+
/// </summary>
21+
public string Color { get; set; }
22+
/// <summary>
23+
/// [nzColor], 颜色值, 默认值: #1677ff
24+
/// </summary>
25+
public string BindColor { get; set; }
26+
/// <summary>
27+
/// nzSize,控件尺寸, 可选值: 'default' | 'small' | 'large' , 默认值: 'default'
28+
/// </summary>
29+
public InputSize Size { get; set; }
30+
/// <summary>
31+
/// [nzSize],控件尺寸, 可选值: 'default' | 'small' | 'large' , 默认值: 'default'
32+
/// </summary>
33+
public string BindSize { get; set; }
34+
/// <summary>
35+
/// (nzOnClick),点击事件 ,类型: EventEmitter&lt;boolean>
36+
/// </summary>
37+
public string OnClick { get; set; }
38+
39+
/// <inheritdoc />
40+
protected override void ProcessBefore( TagHelperContext context, TagHelperOutput output ) {
41+
_config = new Config( context, output );
42+
}
43+
44+
/// <inheritdoc />
45+
protected override IRender GetRender( TagHelperContext context, TagHelperOutput output, TagHelperContent content ) {
46+
_config.Content = content;
47+
return new ColorBlockRender( _config );
48+
}
49+
}

0 commit comments

Comments
 (0)