-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. 新增颜色块组件 <util-color-block> . 3. Razor页面监视服务 Util.Ui.Razor.RazorWatchService 改进新增Razor文件和异常处理逻辑.
- Loading branch information
Showing
25 changed files
with
1,190 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/Util.Ui.NgZorro/Components/ColorPickers/Builders/ColorBlockBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Util.Ui.Angular.Builders; | ||
using Util.Ui.Angular.Configs; | ||
using Util.Ui.NgZorro.Enums; | ||
|
||
namespace Util.Ui.NgZorro.Components.ColorPickers.Builders; | ||
|
||
/// <summary> | ||
/// 颜色块标签生成器 | ||
/// </summary> | ||
public class ColorBlockBuilder : AngularTagBuilder { | ||
/// <summary> | ||
/// 配置 | ||
/// </summary> | ||
private readonly Config _config; | ||
|
||
/// <summary> | ||
/// 初始化颜色块标签生成器 | ||
/// </summary> | ||
/// <param name="config">配置</param> | ||
public ColorBlockBuilder( Config config ) : base( config, "nz-color-block" ) { | ||
_config = config; | ||
} | ||
|
||
/// <summary> | ||
/// 配置颜色 | ||
/// </summary> | ||
public ColorBlockBuilder Color() { | ||
AttributeIfNotEmpty( "nzColor", _config.GetValue( UiConst.Color ) ); | ||
AttributeIfNotEmpty( "[nzColor]", _config.GetValue( AngularConst.BindColor ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置控件尺寸 | ||
/// </summary> | ||
public ColorBlockBuilder Size() { | ||
AttributeIfNotEmpty( "nzSize", _config.GetValue<InputSize?>( UiConst.Size )?.Description() ); | ||
AttributeIfNotEmpty( "[nzSize]", _config.GetValue( AngularConst.BindSize ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置事件 | ||
/// </summary> | ||
public ColorBlockBuilder Events() { | ||
AttributeIfNotEmpty( "(nzOnClick)", _config.GetValue( UiConst.OnClick ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置 | ||
/// </summary> | ||
public override void Config() { | ||
base.Config(); | ||
Color().Size().Events(); | ||
} | ||
} |
157 changes: 157 additions & 0 deletions
157
src/Util.Ui.NgZorro/Components/ColorPickers/Builders/ColorPickerBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
using Util.Ui.Angular.Configs; | ||
using Util.Ui.NgZorro.Components.Base; | ||
using Util.Ui.NgZorro.Configs; | ||
using Util.Ui.NgZorro.Enums; | ||
using Util.Ui.NgZorro.Extensions; | ||
|
||
namespace Util.Ui.NgZorro.Components.ColorPickers.Builders; | ||
|
||
/// <summary> | ||
/// 颜色选择标签生成器 | ||
/// </summary> | ||
public class ColorPickerBuilder : FormControlBuilderBase<ColorPickerBuilder> { | ||
/// <summary> | ||
/// 配置 | ||
/// </summary> | ||
private readonly Config _config; | ||
|
||
/// <summary> | ||
/// 初始化颜色选择标签生成器 | ||
/// </summary> | ||
/// <param name="config">配置</param> | ||
public ColorPickerBuilder( Config config ) : base( config, "nz-color-picker" ) { | ||
_config = config; | ||
} | ||
|
||
/// <summary> | ||
/// 配置标题 | ||
/// </summary> | ||
public ColorPickerBuilder Title() { | ||
SetTitle( _config.GetValue( UiConst.Title ) ); | ||
AttributeIfNotEmpty( "[nzTitle]", _config.GetValue( AngularConst.BindTitle ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 设置表单标签文本 | ||
/// </summary> | ||
private void SetTitle( string value ) { | ||
var options = NgZorroOptionsService.GetOptions(); | ||
if ( options.EnableI18n ) { | ||
this.AttributeByI18n( "[nzTitle]", value ); | ||
return; | ||
} | ||
AttributeIfNotEmpty( "nzTitle", value ); | ||
} | ||
|
||
/// <summary> | ||
/// 配置颜色默认值 | ||
/// </summary> | ||
public ColorPickerBuilder DefaultValue() { | ||
AttributeIfNotEmpty( "nzDefaultValue", _config.GetValue( UiConst.DefaultValue ) ); | ||
AttributeIfNotEmpty( "[nzDefaultValue]", _config.GetValue( AngularConst.BindDefaultValue ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置颜色值 | ||
/// </summary> | ||
public ColorPickerBuilder Value() { | ||
AttributeIfNotEmpty( "nzValue", _config.GetValue( UiConst.Value ) ); | ||
AttributeIfNotEmpty( "[nzValue]", _config.GetValue( AngularConst.BindValue ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置显示颜色文本 | ||
/// </summary> | ||
public ColorPickerBuilder ShowText() { | ||
AttributeIfNotEmpty( "[nzShowText]", _config.GetBoolValue( UiConst.ShowText ) ); | ||
AttributeIfNotEmpty( "[nzShowText]", _config.GetValue( AngularConst.BindShowText ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置控件尺寸 | ||
/// </summary> | ||
public ColorPickerBuilder Size() { | ||
AttributeIfNotEmpty( "nzSize", _config.GetValue<InputSize?>( UiConst.Size )?.Description() ); | ||
AttributeIfNotEmpty( "[nzSize]", _config.GetValue( AngularConst.BindSize ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置禁用 | ||
/// </summary> | ||
public ColorPickerBuilder Disabled() { | ||
AttributeIfNotEmpty( "[nzDisabled]", _config.GetBoolValue( UiConst.Disabled ) ); | ||
AttributeIfNotEmpty( "[nzDisabled]", _config.GetValue( AngularConst.BindDisabled ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置禁用透明度 | ||
/// </summary> | ||
public ColorPickerBuilder DisabledAlpha() { | ||
AttributeIfNotEmpty( "[nzDisabledAlpha]", _config.GetBoolValue( UiConst.DisabledAlpha ) ); | ||
AttributeIfNotEmpty( "[nzDisabledAlpha]", _config.GetValue( AngularConst.BindDisabledAlpha ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置触发模式 | ||
/// </summary> | ||
public ColorPickerBuilder Trigger() { | ||
AttributeIfNotEmpty( "nzTrigger", _config.GetValue<ColorPickerTrigger?>( UiConst.Trigger )?.Description() ); | ||
AttributeIfNotEmpty( "[nzTrigger]", _config.GetValue( AngularConst.BindTrigger ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置允许清除 | ||
/// </summary> | ||
public ColorPickerBuilder AllowClear() { | ||
AttributeIfNotEmpty( "[nzAllowClear]", _config.GetBoolValue( UiConst.AllowClear ) ); | ||
AttributeIfNotEmpty( "[nzAllowClear]", _config.GetValue( AngularConst.BindAllowClear ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置颜色格式 | ||
/// </summary> | ||
public ColorPickerBuilder Format() { | ||
AttributeIfNotEmpty( "nzFormat", _config.GetValue<ColorPickerFormat?>( UiConst.Format )?.Description() ); | ||
AttributeIfNotEmpty( "[nzFormat]", _config.GetValue( AngularConst.BindFormat ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置显示弹出窗口 | ||
/// </summary> | ||
public ColorPickerBuilder Open() { | ||
AttributeIfNotEmpty( "[nzOpen]", _config.GetValue( UiConst.Open ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置事件 | ||
/// </summary> | ||
public ColorPickerBuilder Events() { | ||
AttributeIfNotEmpty( "(nzOnChange)", _config.GetValue( UiConst.OnChange ) ); | ||
AttributeIfNotEmpty( "(nzOnClear)", _config.GetValue( UiConst.OnClear ) ); | ||
AttributeIfNotEmpty( "(nzOnFormatChange)", _config.GetValue( UiConst.OnFormatChange ) ); | ||
AttributeIfNotEmpty( "(nzOnOpenChange)", _config.GetValue( UiConst.OnOpenChange ) ); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 配置 | ||
/// </summary> | ||
public override void Config() { | ||
base.ConfigBase( _config ); | ||
ConfigForm().Name().DefaultValue().Value() | ||
.Title().ShowText().Size().Disabled().DisabledAlpha() | ||
.Trigger().AllowClear().Format().Open() | ||
.Events(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/Util.Ui.NgZorro/Components/ColorPickers/ColorBlockTagHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Microsoft.AspNetCore.Razor.TagHelpers; | ||
using Util.Ui.Angular.TagHelpers; | ||
using Util.Ui.NgZorro.Components.ColorPickers.Renders; | ||
using Util.Ui.NgZorro.Enums; | ||
using Util.Ui.Renders; | ||
|
||
namespace Util.Ui.NgZorro.Components.ColorPickers; | ||
|
||
/// <summary> | ||
/// 颜色块,生成的标签为<nz-color-block></nz-color-block> | ||
/// </summary> | ||
[HtmlTargetElement( "util-color-block" )] | ||
public class ColorBlockTagHelper : AngularTagHelperBase { | ||
/// <summary> | ||
/// 配置 | ||
/// </summary> | ||
private Config _config; | ||
/// <summary> | ||
/// nzColor, 颜色值, 默认值: #1677ff | ||
/// </summary> | ||
public string Color { get; set; } | ||
/// <summary> | ||
/// [nzColor], 颜色值, 默认值: #1677ff | ||
/// </summary> | ||
public string BindColor { get; set; } | ||
/// <summary> | ||
/// nzSize,控件尺寸, 可选值: 'default' | 'small' | 'large' , 默认值: 'default' | ||
/// </summary> | ||
public InputSize Size { get; set; } | ||
/// <summary> | ||
/// [nzSize],控件尺寸, 可选值: 'default' | 'small' | 'large' , 默认值: 'default' | ||
/// </summary> | ||
public string BindSize { get; set; } | ||
/// <summary> | ||
/// (nzOnClick),点击事件 ,类型: EventEmitter<boolean> | ||
/// </summary> | ||
public string OnClick { get; set; } | ||
|
||
/// <inheritdoc /> | ||
protected override void ProcessBefore( TagHelperContext context, TagHelperOutput output ) { | ||
_config = new Config( context, output ); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override IRender GetRender( TagHelperContext context, TagHelperOutput output, TagHelperContent content ) { | ||
_config.Content = content; | ||
return new ColorBlockRender( _config ); | ||
} | ||
} |
Oops, something went wrong.