diff --git a/TDesign.sln b/TDesign.sln
index 3733a4c3..504900e9 100644
--- a/TDesign.sln
+++ b/TDesign.sln
@@ -18,8 +18,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{13ED86A3-CF19-4A3E-9A7C-B463221D6D1F}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
+ common.props = common.props
Contributing.md = Contributing.md
- nuget.config = nuget.config
readme.md = readme.md
EndProjectSection
EndProject
diff --git a/common.props b/common.props
new file mode 100644
index 00000000..32a3f503
--- /dev/null
+++ b/common.props
@@ -0,0 +1,36 @@
+
+
+ 10
+ 11
+ net6.0;net7.0
+
+
+ true
+ true
+
+
+
+
+ true
+ full
+ false
+ DEBUG;TRACE
+
+
+
+
+ false
+ true
+ TRACE
+ false
+ ..\..\pack
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/TDesign.Docs.ServerSide/TDesign.Docs.ServerSide.csproj b/doc/TDesign.Docs.ServerSide/TDesign.Docs.ServerSide.csproj
index faba3552..fd15abc3 100644
--- a/doc/TDesign.Docs.ServerSide/TDesign.Docs.ServerSide.csproj
+++ b/doc/TDesign.Docs.ServerSide/TDesign.Docs.ServerSide.csproj
@@ -1,7 +1,6 @@
-
+
- net6.0
enable
enable
TDesign.Docs.ServerSide
diff --git a/doc/TDesign.Docs.ServerSide/TDesign.xml b/doc/TDesign.Docs.ServerSide/TDesign.xml
index 88206a3e..b3fb728c 100644
--- a/doc/TDesign.Docs.ServerSide/TDesign.xml
+++ b/doc/TDesign.Docs.ServerSide/TDesign.xml
@@ -632,10 +632,7 @@
设置后面追加的任意 UI 内容。
-
-
-
-
+
diff --git a/doc/TDesign.Docs.Shared/Components/Example.razor b/doc/TDesign.Docs.Shared/Components/Example.razor
index 91f4cf93..97d73d1e 100644
--- a/doc/TDesign.Docs.Shared/Components/Example.razor
+++ b/doc/TDesign.Docs.Shared/Components/Example.razor
@@ -43,12 +43,12 @@
bool Active = false;
string GetStyle() => Active ? "" : "display:none";
- string CodeClass => HtmlHelper.Class.Append("content code")
+ string CodeClass => HtmlHelper.Instance.Class().Append("content code")
//.Append(Active, "code-collapse", "code-expand")
.ToString()
;
- string BtnClass => HtmlHelper.Class.Append("action").Append("active", Active).ToString();
+ string BtnClass => HtmlHelper.Instance.Class().Append("action").Append("active", Active).ToString();
void ToogleCode()
{
diff --git a/doc/TDesign.Docs.Shared/TDesign.Docs.Shared.csproj b/doc/TDesign.Docs.Shared/TDesign.Docs.Shared.csproj
index b233a87a..4ed0cc82 100644
--- a/doc/TDesign.Docs.Shared/TDesign.Docs.Shared.csproj
+++ b/doc/TDesign.Docs.Shared/TDesign.Docs.Shared.csproj
@@ -1,7 +1,6 @@
-
+
- net6.0
enable
enable
TDesign.Docs.Shared
@@ -17,7 +16,6 @@
-
diff --git a/doc/TDesign.Docs.WebAssembly/TDesign.Docs.WebAssembly.csproj b/doc/TDesign.Docs.WebAssembly/TDesign.Docs.WebAssembly.csproj
index be66ce43..f2e1c050 100644
--- a/doc/TDesign.Docs.WebAssembly/TDesign.Docs.WebAssembly.csproj
+++ b/doc/TDesign.Docs.WebAssembly/TDesign.Docs.WebAssembly.csproj
@@ -1,7 +1,7 @@
-
+
+
- net6.0
enable
enable
false
@@ -16,11 +16,14 @@
-
-
-
+
+
+
+
+
+
+
-
diff --git a/doc/TDesign.Docs.WebAssembly/wwwroot/TDesign.xml b/doc/TDesign.Docs.WebAssembly/wwwroot/TDesign.xml
index 88206a3e..b3fb728c 100644
--- a/doc/TDesign.Docs.WebAssembly/wwwroot/TDesign.xml
+++ b/doc/TDesign.Docs.WebAssembly/wwwroot/TDesign.xml
@@ -632,10 +632,7 @@
设置后面追加的任意 UI 内容。
-
-
-
-
+
diff --git a/doc/TDesignBlazor.Docs.Shared/Layouts/NavMenu.razor b/doc/TDesignBlazor.Docs.Shared/Layouts/NavMenu.razor
deleted file mode 100644
index 46eccbf5..00000000
--- a/doc/TDesignBlazor.Docs.Shared/Layouts/NavMenu.razor
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
diff --git a/doc/TDesignBlazor.Docs.Shared/Pages/Components/FormPage.razor b/doc/TDesignBlazor.Docs.Shared/Pages/Components/FormPage.razor
deleted file mode 100644
index 09970b22..00000000
--- a/doc/TDesignBlazor.Docs.Shared/Pages/Components/FormPage.razor
+++ /dev/null
@@ -1,282 +0,0 @@
-@page "/components/form"
-
-
- 用以收集、校验和提交数据,一般由输入框、单选框、复选框、选择器等控件组成。
-
-
-
-
-
-
-
-
- @Code.Create(@"
- ```html
-
- ```
-
- ```cs
- @code{
- class BasicForm
- {
- public string Name { get; set; }
- public string Password { get; set; }
- public string Gender { get; set; } = ""男"";
- public bool? Agree{ get; set; }
- }
-
- BasicForm basicForm = new();
- }
- ```
- ")
-
-
-
-@code {
- class BasicForm
- {
- public string Name { get; set; }
- public string Password { get; set; }
- public string Gender { get; set; } = "男";
- public bool? Agree { get; set; }
- }
-
- BasicForm basicForm = new();
-}
-
-
- Alignment
可设置表单中的 Label 文本的对齐方式
-
-
- 居左对齐
- 居右对齐
- 居顶对齐
-
-
-
-
-
-
- @Code.Create(@"
- ```html
-
- 居左对齐
- 居右对齐
- 居顶对齐
-
-
-
- ```
- ```cs
- @code{
- FormAlignment Alignment { get; set; } = FormAlignment.Left;
- }
- ```
- ")
-
-
-@code {
- FormAlignment Alignment { get; set; } = FormAlignment.Left;
-}
-
-
- 设置 Inline
使局部变成横向的
-
-
-
-
- @Code.Create(@"
- ```html
-
- ```
- ")
-
-
-
- HelpText
可以设置输入控件的帮助文本
-
-
-
-
- @Code.Create(@"
- ```html
-
- ```
- ")
-
-
-
-
-
- 用法与 EditForm
组件一致,支持 System.ComponentModel.DataAnnotations
的特性验证。要设置 提交按钮的 HtmlType="ButtonHtmlType.Submit"
类型。
-
-
-
-
-
- @Code.Create(@"
- ```html
-
- ```
- ```cs
- @using System.ComponentModel.DataAnnotations
- @code{
- ValidationForm validationForm = new();
- class ValidationForm
- {
- [Display(Name=""用户名"")]
- [Required(ErrorMessage =""{0}是必填的"")]
- public string UserName{get;set;}
-
- [Display(Name =""密码"")]
- [Required(ErrorMessage =""{0}不能为空"")]
- [StringLength(10)]
- public string Password{ get; set; }
- }
-
- void Submit(EditContext context)
- {
-
- }
- }
- ```
- ")
-
-
-@using System.ComponentModel.DataAnnotations
-@code {
-
- ValidationForm validationForm = new();
- class ValidationForm
- {
- [Display(Name = "用户名")]
- [Required(ErrorMessage = "{0}是必填的")]
- public string UserName { get; set; }
-
- [Display(Name = "密码")]
- [Required(ErrorMessage = "{0}不能为空")]
- [StringLength(10)]
- public string Password { get; set; }
- }
-
- void Submit()
- {
-
- }
-}
\ No newline at end of file
diff --git a/src/TDesign.Test/Components/Data/CardTest.cs b/src/TDesign.Test/Components/Data/CardTest.cs
index 9904b5d1..620c8323 100644
--- a/src/TDesign.Test/Components/Data/CardTest.cs
+++ b/src/TDesign.Test/Components/Data/CardTest.cs
@@ -30,7 +30,7 @@ public void Test_Card_Hover()
[Fact(DisplayName ="Card - 头部标题")]
public void Test_Card_HeadContent()
{
- var component = RenderComponent(m => m.Add(p => p.HeaderTitleContent, HtmlHelper.CreateContent("Header")));
+ var component = RenderComponent(m => m.Add(p => p.HeaderTitleContent, HtmlHelper.Instance.CreateContent("Header")));
component.Find(".t-card__header>.t-card__header-wrapper>div>.t-card__title").Html().Should().Be("Header");
}
@@ -38,8 +38,8 @@ public void Test_Card_HeadContent()
[Fact(DisplayName ="Card - 头部副标题")]
public void Test_Card_HeadContent_SubTitle()
{
- var component = RenderComponent(m => m.Add(p => p.HeaderTitleContent, HtmlHelper.CreateContent("Header"))
- .Add(p=>p.HeaderSubTitleContent,HtmlHelper.CreateContent("SubTitle")));
+ var component = RenderComponent(m => m.Add(p => p.HeaderTitleContent, HtmlHelper.Instance.CreateContent("Header"))
+ .Add(p=>p.HeaderSubTitleContent,HtmlHelper.Instance.CreateContent("SubTitle")));
component.Find(".t-card__header>.t-card__header-wrapper>div>.t-card__subtitle").Html().Should().Be("SubTitle");
}
@@ -47,7 +47,7 @@ public void Test_Card_HeadContent_SubTitle()
[Fact(DisplayName ="Card - 头部没有主标题,但是有副标题,则不显示")]
public void Test_Card_HeaderContent_Without_HeadTitleContent_And_Set_SubTitleContent_Then_SubTitle_Dose_Not_Display()
{
- var component = RenderComponent(m => m.Add(p => p.HeaderSubTitleContent, HtmlHelper.CreateContent("SubTitle")));
+ var component = RenderComponent(m => m.Add(p => p.HeaderSubTitleContent, HtmlHelper.Instance.CreateContent("SubTitle")));
Throws(() => component.Find(".t-card__header>.t-card__header-wrapper>div>.t-card__subtitle"));
}
@@ -55,8 +55,8 @@ public void Test_Card_HeaderContent_Without_HeadTitleContent_And_Set_SubTitleCon
[Fact(DisplayName = "Card - 头部描述")]
public void Test_Card_HeadContent_Description()
{
- var component = RenderComponent(m => m.Add(p => p.HeaderTitleContent, HtmlHelper.CreateContent("Header"))
- .Add(p => p.HeaderDescriptionContent, HtmlHelper.CreateContent("Description")));
+ var component = RenderComponent(m => m.Add(p => p.HeaderTitleContent, HtmlHelper.Instance.CreateContent("Header"))
+ .Add(p => p.HeaderDescriptionContent, HtmlHelper.Instance.CreateContent("Description")));
component.Find(".t-card__header>.t-card__header-wrapper>div>.t-card__description").Html().Should().Be("Description");
}
@@ -64,7 +64,7 @@ public void Test_Card_HeadContent_Description()
[Fact(DisplayName = "Card - 头部没有主标题,但是有副标题,则不显示")]
public void Test_Card_HeaderContent_Without_HeadTitleContent_And_Set_DescriptionContent_Then_Description_Dose_Not_Display()
{
- var component = RenderComponent(m => m.Add(p => p.HeaderDescriptionContent, HtmlHelper.CreateContent("Description")));
+ var component = RenderComponent(m => m.Add(p => p.HeaderDescriptionContent, HtmlHelper.Instance.CreateContent("Description")));
Throws(() => component.Find(".t-card__header>.t-card__header-wrapper>div>.t-card__description"));
}
@@ -72,14 +72,14 @@ public void Test_Card_HeaderContent_Without_HeadTitleContent_And_Set_Description
[Fact(DisplayName ="Card - 头部操作内容")]
public void Test_Card_HeaderAction()
{
- var component = RenderComponent(m => m.Add(p => p.HeaderActionContent, HtmlHelper.CreateContent("Action")));
+ var component = RenderComponent(m => m.Add(p => p.HeaderActionContent, HtmlHelper.Instance.CreateContent("Action")));
component.Find(".t-card__header>.t-card__actions").Html().Should().Be("Action");
}
[Fact(DisplayName ="Card - 头部分割线")]
public void Test_Card_HeaderDivider()
{
- var component = RenderComponent(m => m.Add(p => p.HeaderTitleContent, HtmlHelper.CreateContent("Header"))
+ var component = RenderComponent(m => m.Add(p => p.HeaderTitleContent, HtmlHelper.Instance.CreateContent("Header"))
.Add(p=>p.HeaderDivider,true));
component.Find(".t-card__header").Should().HaveClass("t-card__title--bordered");
}
@@ -94,7 +94,7 @@ public void Test_Card_HeaderDivier_Without_Set_HeaderTitleContent_Then_Header_Do
[Fact(DisplayName ="Card - 底部内容")]
public void Test_Card_FooterContent()
{
- var component = RenderComponent(m => m.Add(p => p.FooterContent, HtmlHelper.CreateContent("Footer")));
+ var component = RenderComponent(m => m.Add(p => p.FooterContent, HtmlHelper.Instance.CreateContent("Footer")));
component.Find(".t-card__footer>.t-card__footer-wrapper").Html().Should().Be("Footer");
}
diff --git a/src/TDesign.Test/Components/Data/TableTest.cs b/src/TDesign.Test/Components/Data/TableTest.cs
index 8e4ea550..258ff609 100644
--- a/src/TDesign.Test/Components/Data/TableTest.cs
+++ b/src/TDesign.Test/Components/Data/TableTest.cs
@@ -71,7 +71,7 @@
// // {
// // b.CreateComponent>(0, attributes: new {
// // Field = nameof(TestData.Id),
-// // FooterContent =HtmlHelper.CreateContent(b=>b.AddContent(0,"列1")) });
+// // FooterContent =HtmlHelper.Instance.CreateContent(b=>b.AddContent(0,"列1")) });
// // })))
// // .Add(p => p.Data, DataSource.Parse(TestData.GetData()))
// // );
diff --git a/src/TDesign.Test/Components/Input/InputAdornmentTest.cs b/src/TDesign.Test/Components/Input/InputAdornmentTest.cs
index 8a9a2b7d..2fc116d3 100644
--- a/src/TDesign.Test/Components/Input/InputAdornmentTest.cs
+++ b/src/TDesign.Test/Components/Input/InputAdornmentTest.cs
@@ -1,4 +1,5 @@
using ComponentBuilder;
+using ComponentBuilder.FluentRenderTree;
using Microsoft.AspNetCore.Components.Forms;
using System;
using System.Collections.Generic;
@@ -21,39 +22,67 @@ public void Test_Render()
public void Test_Prepend_Parameter()
{
RenderComponent(m => m.Add(p => p.Prepend, "http"))
- .Should()
- .HaveClass("t-input-adornment--prepend")
- .And
- .HaveChildMarkup(builder => builder.CreateElement(0, "span", "http", new { @class = "t-input-adornment__prepend" }));
+ .MarkupMatches(builder =>
+ {
+ builder.Div("t-input-adornment").Content(prepend =>
+ {
+ prepend.Span("t-input-adornment__prepend").Content(text =>
+ {
+ text.Span("t-input-adornment__text").Content("http").Close();
+ }).Close();
+ })
+ .Close();
+ });
}
[Fact(DisplayName = "InputAdornment - PrependContent 参数")]
public void Test_PrependContent_Parameter()
{
RenderComponent(m => m.Add(p => p.PrependContent, builder => builder.AddContent(0, "html content")))
- .Should()
- .HaveClass("t-input-adornment--prepend")
- .And
- .HaveChildMarkup(builder => builder.CreateElement(0, "span", content => content.AddContent(0, "html content"), new { @class = "t-input-adornment__prepend" }));
+ .MarkupMatches(builder =>
+ {
+ builder.Div("t-input-adornment").Content(prepend =>
+ {
+ prepend.Span("t-input-adornment__prepend").Content(text =>
+ {
+ text.Span("t-input-adornment__text").Content("html content").Close();
+ }).Close();
+ })
+ .Close();
+ });
}
[Fact(DisplayName = "InputAdornment - Append 参数")]
public void Test_Append_Parameter()
{
RenderComponent(m => m.Add(p => p.Append, "http"))
- .Should()
- .HaveClass("t-input-adornment--append")
- .And
- .HaveChildMarkup(builder => builder.CreateElement(0, "span", "http", new { @class = "t-input-adornment__append" }));
+ .MarkupMatches(builder =>
+ {
+ builder.Div("t-input-adornment").Content(prepend =>
+ {
+ prepend.Span("t-input-adornment__append").Content(text =>
+ {
+ text.Span("t-input-adornment__text").Content("http").Close();
+ }).Close();
+ })
+ .Close();
+ });
}
[Fact(DisplayName = "InputAdornment - AppendContent 参数")]
public void Test_AppendContent_Parameter()
{
RenderComponent(m => m.Add(p => p.AppendContent, builder => builder.AddContent(0, "html content")))
- .Should()
- .HaveClass("t-input-adornment--append")
- .And
- .HaveChildMarkup(builder => builder.CreateElement(0, "span", content => content.AddContent(0, "html content"), new { @class = "t-input-adornment__append" }));
+ .MarkupMatches(builder =>
+ {
+ builder.Div("t-input-adornment").Content(prepend =>
+ {
+ prepend.Span("t-input-adornment__append").Content(text =>
+ {
+ text.Span("t-input-adornment__text").Content("html content").Close();
+ }).Close();
+ })
+ .Close();
+ });
}
}
diff --git a/src/TDesign.Test/TDesign.Test.csproj b/src/TDesign.Test/TDesign.Test.csproj
index 917f0290..13983fdb 100644
--- a/src/TDesign.Test/TDesign.Test.csproj
+++ b/src/TDesign.Test/TDesign.Test.csproj
@@ -1,7 +1,6 @@
-
+
- net6.0;net7.0
enable
enable
diff --git a/src/TDesign/Components/Anchor/TAnchor.cs b/src/TDesign/Components/Anchor/TAnchor.cs
index 2a03f3a9..d1fe1516 100644
--- a/src/TDesign/Components/Anchor/TAnchor.cs
+++ b/src/TDesign/Components/Anchor/TAnchor.cs
@@ -9,7 +9,7 @@ namespace TDesign
[HtmlTag("div")]
[ParentComponent]
[CssClass("t-anchor")]
- public class TAnchor : BlazorComponentBase, IHasChildContent, IHasOnSwitch
+ public class TAnchor : TDesignComponentBase, IHasChildContent, IHasOnSwitch
{
private DotNetObjectReference? objRef;
///
@@ -55,7 +55,7 @@ public async Task OnScrollAnchorChangeAsync(double index)
if (!ClickLoad)
{
var containerId = Container?.Split("#")[1];
- var anchorObj = await JS.Value.InvokeAsync("import", "./_content/TDesign/tdesign-blazor.js");
+ var anchorObj = await JS.InvokeAsync("import", "./_content/TDesign/tdesign-blazor.js");
index += await anchorObj.InvokeAsync("anchor.getOffsetTop", containerId);
for (int i = 0; i < ChildComponents.Count; i++)
{
@@ -104,7 +104,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
if (firstRender && !string.IsNullOrEmpty(Container))
{
var containerId = Container?.Split("#")[1];
- var anchorObj = await JS.Value.InvokeAsync("import", "./_content/TDesign/tdesign-blazor.js");
+ var anchorObj = await JS.InvokeAsync("import", "./_content/TDesign/tdesign-blazor.js");
await anchorObj.InvokeVoidAsync("anchor.onAnchorScroll", objRef, containerId);
}
await base.OnAfterRenderAsync(firstRender);
diff --git a/src/TDesign/Components/Anchor/TAnchorItem.cs b/src/TDesign/Components/Anchor/TAnchorItem.cs
index 0955cbf0..648efcda 100644
--- a/src/TDesign/Components/Anchor/TAnchorItem.cs
+++ b/src/TDesign/Components/Anchor/TAnchorItem.cs
@@ -37,7 +37,7 @@ public enum AnchorItemTarget
[HtmlTag("div")]
[CssClass("t-anchor__item")]
[ChildComponentAttribute(typeof(TAnchor))]
- public class TAnchorItem : BlazorComponentBase, IHasChildContent, IHasActive
+ public class TAnchorItem : TDesignComponentBase, IHasChildContent, IHasActive
{
private string? _href;
@@ -132,7 +132,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
Href,
Title,
Target = Target?.GetHtmlAttribute(),
- onclick = HtmlHelper.Event.Create(this, async x =>
+ onclick = HtmlHelper.Instance.Callback().Create(this, async x =>
{
CascadingAnchor.ClickLoad = true;
for (int i = 0; i < CascadingAnchor?.ChildComponents.Count; i++)
@@ -151,7 +151,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
await item.Refresh();
}
}
- var anchorObj = await JS.Value.InvokeAsync("import", "./_content/TDesign/tdesign-blazor.js");
+ var anchorObj = await JS.InvokeAsync("import", "./_content/TDesign/tdesign-blazor.js");
await anchorObj.InvokeVoidAsync("anchor.hash", Href?.Split("#")[1], CascadingAnchor?.Container?.Split("#")[1]);
await this.Refresh();
diff --git a/src/TDesign/Components/Breadcrumb/TBreadcrumbItem.cs b/src/TDesign/Components/Breadcrumb/TBreadcrumbItem.cs
index 8e7f4dd9..35818b56 100644
--- a/src/TDesign/Components/Breadcrumb/TBreadcrumbItem.cs
+++ b/src/TDesign/Components/Breadcrumb/TBreadcrumbItem.cs
@@ -44,7 +44,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
overflow.CreateElement(0, "span", ChildContent, new { @class = "t-breadcrumb__inner", style = "max-width:120px" });
}, new
{
- @class = HtmlHelper.Class.Append("t-breadcrumb--text-overflow")
+ @class = HtmlHelper.Instance.Class().Append("t-breadcrumb--text-overflow")
.Append("t-link", HasLink).Append("t-is-disabled", Disabled)
});
diff --git a/src/TDesign/Components/Collapse/TCollapsePanel.cs b/src/TDesign/Components/Collapse/TCollapsePanel.cs
index 492431be..bcb13b3e 100644
--- a/src/TDesign/Components/Collapse/TCollapsePanel.cs
+++ b/src/TDesign/Components/Collapse/TCollapsePanel.cs
@@ -71,8 +71,8 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
}
}, new
{
- @class = HtmlHelper.Class.Append("t-collapse-panel__header").Append("t-is-clickable", !CascadingCollaspe.IconToggle && !Disabled),
- onclick = HtmlHelper.Event.Create(this, () =>
+ @class = HtmlHelper.Instance.Class().Append("t-collapse-panel__header").Append("t-is-clickable", !CascadingCollaspe.IconToggle && !Disabled),
+ onclick = HtmlHelper.Instance.Callback().Create(this, () =>
{
if (!CascadingCollaspe.IconToggle)
{
@@ -94,11 +94,11 @@ private void BuildTIcon(RenderTreeBuilder builder, int sequence)
builder.CreateComponent(sequence, attributes: new
{
Name = !Active ? (CascadingCollaspe.RightTIcon.HasValue && CascadingCollaspe.RightTIcon.Value ? IconName.ChevronLeft : IconName.ChevronRight) : IconName.ChevronDown,
- AdditionalClass = HtmlHelper.Class
+ AdditionalClass = HtmlHelper.Instance.Class()
.Append("t-collapse-panel__icon")
.Append("t-collapse-panel__icon--left", CascadingCollaspe.RightTIcon.HasValue && !CascadingCollaspe.RightTIcon.Value)
.Append("t-collapse-panel__icon--right", CascadingCollaspe.RightTIcon.HasValue && CascadingCollaspe.RightTIcon.Value).ToString(),
- onclick = HtmlHelper.Event.Create(this, () =>
+ onclick = HtmlHelper.Instance.Callback().Create(this, () =>
{
if (CascadingCollaspe.IconToggle)
{
@@ -116,9 +116,9 @@ void BuildContent(RenderTreeBuilder builder, int sequence)
@class = "t-collapse-panel__content"
}), new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-collapse-panel__body"),
- style = HtmlHelper.Style
+ style = HtmlHelper.Instance.Style()
.Append("display:none", !Active)
.Append("")
});
diff --git a/src/TDesign/Components/Forms/TDesignInputComonentBase.cs b/src/TDesign/Components/Forms/TDesignInputComonentBase.cs
index 56c6b3a0..435607f3 100644
--- a/src/TDesign/Components/Forms/TDesignInputComonentBase.cs
+++ b/src/TDesign/Components/Forms/TDesignInputComonentBase.cs
@@ -76,7 +76,7 @@ protected virtual void BuildInputWrapper(RenderTreeBuilder builder, int sequence
{
wrap.CreateElement(0, "div", content, new
{
- @class = HtmlHelper.Class.Append("t-input")
+ @class = HtmlHelper.Instance.Class().Append("t-input")
.Append("t-is-readonly", Readonly)
.Append("t-is-disabled", Disabled)
.Append("t-input--auto-width", AutoWidth)
@@ -89,12 +89,12 @@ protected virtual void BuildInputWrapper(RenderTreeBuilder builder, int sequence
wrap.CreateElement(1, "div", TipContent, new
{
- @class = HtmlHelper.Class.Append("t-input__tips")
+ @class = HtmlHelper.Instance.Class().Append("t-input__tips")
.Append($"t-input__tips--{Status.GetCssClass()}")
}, TipContent is not null);
}, new
{
- @class = HtmlHelper.Class.Append("t-input__wrap").Append(wrapClass)
+ @class = HtmlHelper.Instance.Class().Append("t-input__wrap").Append(wrapClass)
});
}
@@ -107,7 +107,7 @@ protected override void BuildAttributes(IDictionary attributes)
protected virtual void BuildEventAttribute(IDictionary attributes)
{
- attributes[EventName] = HtmlHelper.Event.CreateBinder(this, _value =>
+ attributes[EventName] = HtmlHelper.Instance.Callback().CreateBinder(this, _value =>
{
this.ChangeValue(_value);
}, Value);
diff --git a/src/TDesign/Components/Forms/TFormItem.cs b/src/TDesign/Components/Forms/TFormItem.cs
index 5b1df68e..55216836 100644
--- a/src/TDesign/Components/Forms/TFormItem.cs
+++ b/src/TDesign/Components/Forms/TFormItem.cs
@@ -109,13 +109,13 @@ void BuildLabel(RenderTreeBuilder builder, int sequence)
content.CreateElement(0, "label", Label, new { @for = "" });
}, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-form__label")
.Append($"t-form__label--{CascadingForm.Alignment.GetCssClass()}")
.Append("t-form__label--colon", LabelColon)
.Append("t-form__label--required", Required)
,
- style = HtmlHelper.Style.Append($"width:{LabelWidth}", !string.IsNullOrEmpty(LabelWidth) && CascadingForm.Alignment != FormAlignment.Top)
+ style = HtmlHelper.Instance.Style().Append($"width:{LabelWidth}", !string.IsNullOrEmpty(LabelWidth) && CascadingForm.Alignment != FormAlignment.Top)
});
}
@@ -135,10 +135,10 @@ void BuildControl(RenderTreeBuilder builder, int sequence)
}
}, new
{
- @class = HtmlHelper.Class.Append("t-form__controls")
+ @class = HtmlHelper.Instance.Class().Append("t-form__controls")
.Append($"t-is-{StatusCssClass}", Identifier.HasValue)
.Append($"t-form--success-border", StatusCssClass == Status.Success.GetCssClass()),
- style = HtmlHelper.Style.Append("margin-left:60px", CascadingForm.Alignment != FormAlignment.Top)
+ style = HtmlHelper.Instance.Style().Append("margin-left:60px", CascadingForm.Alignment != FormAlignment.Top)
});
}
diff --git a/src/TDesign/Components/Forms/TInputAdornment.cs b/src/TDesign/Components/Forms/TInputAdornment.cs
index 30758c68..abe2527e 100644
--- a/src/TDesign/Components/Forms/TInputAdornment.cs
+++ b/src/TDesign/Components/Forms/TInputAdornment.cs
@@ -32,35 +32,28 @@ public class TInputAdornment : BlazorComponentBase, IHasChildContent
[Parameter]public RenderFragment? AppendContent { get; set; }
///
- protected override void OnParametersSet()
+ protected override void AfterSetParameters(ParameterView parameters)
{
- base.OnParametersSet();
-
- if ( !string.IsNullOrEmpty(Prepend) )
+ base.AfterSetParameters(parameters);
+ if (!string.IsNullOrWhiteSpace( Prepend ))
{
PrependContent ??= builder => builder.AddContent(0, Prepend);
}
- if ( !string.IsNullOrEmpty(Append) )
+ if ( !string.IsNullOrWhiteSpace(Append) )
{
AppendContent ??= builder => builder.AddContent(0, Append);
}
}
- ///
- protected override void BuildCssClass(ICssClassBuilder builder)
- {
- builder.Append("t-input-adornment--prepend", PrependContent is not null)
- .Append("t-input-adornment--append",AppendContent is not null)
- ;
- }
-
///
protected override void AddContent(RenderTreeBuilder builder, int sequence)
{
- builder.CreateElement(sequence, "span", PrependContent, new { @class = "t-input-adornment__prepend" }, PrependContent is not null);
-
+ builder.Span("t-input-adornment__prepend",PrependContent is not null).Content(text => BuildText(text, PrependContent)).Close();
builder.AddContent(sequence + 1, ChildContent);
+ builder.Span("t-input-adornment__append", AppendContent is not null).Content(text => BuildText(text, AppendContent)).Close();
- builder.CreateElement(sequence+2, "span", AppendContent, new { @class = "t-input-adornment__append" },AppendContent is not null);
}
+
+ void BuildText(RenderTreeBuilder builder, RenderFragment? fragment)
+ => builder.Span("t-input-adornment__text").Content(fragment).Close();
}
diff --git a/src/TDesign/Components/Forms/TInputCheckBox.cs b/src/TDesign/Components/Forms/TInputCheckBox.cs
index c7988102..bcb24773 100644
--- a/src/TDesign/Components/Forms/TInputCheckBox.cs
+++ b/src/TDesign/Components/Forms/TInputCheckBox.cs
@@ -31,7 +31,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
content.CloseRegion();
}, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-checkbox")
.Append("t-is-disabled", Disabled)
.Append("t-is-indeterminate", Value is null && Indeterminate)
diff --git a/src/TDesign/Components/Forms/TInputNumber.cs b/src/TDesign/Components/Forms/TInputNumber.cs
index 03679df9..2f2b3846 100644
--- a/src/TDesign/Components/Forms/TInputNumber.cs
+++ b/src/TDesign/Components/Forms/TInputNumber.cs
@@ -103,16 +103,16 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
AutoWidth,
Readonly,
Disabled,
- TipContent = TipAlign is not null && TipAlign == TDesign.TipAlign.Input ? HtmlHelper.CreateContent(Tip) : HtmlHelper.CreateContent(""),
+ TipContent = TipAlign is not null && TipAlign == TDesign.TipAlign.Input ? HtmlHelper.Instance.CreateContent(Tip) : HtmlHelper.Instance.CreateContent(""),
@Type = InputType.Number,
Step,
Min,
Max,
- onblur = HtmlHelper.Event.Create(this, async () =>
+ onblur = HtmlHelper.Instance.Callback().Create(this, async () =>
{
await ConvertNumberAsync(_inputString);
}),
- oninput = HtmlHelper.Event.Create(this, async args =>
+ oninput = HtmlHelper.Instance.Callback().Create(this, async args =>
{
_inputString = args?.Value?.ToString() ?? "";
await ConvertNumberAsync(_inputString);
@@ -188,12 +188,12 @@ private void BuildButton(RenderTreeBuilder builder, int sequence, object iconNam
{
Varient = ButtonVarient.Outline,
Shape = ButtonShape.Square,
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append($"t-input-number__decrease", iconName.ToString() == IconName.Remove.ToString())
.Append($"t-input-number__increase", iconName.ToString() == IconName.Add.ToString())
.Append($"t-is-disabled", iconName.ToString() == IconName.Remove.ToString() && disabled)
.Append($"t-is-disabled", iconName.ToString() == IconName.Add.ToString() && disabled),
- onclick = HtmlHelper.Event.Create(this, e => click?.Invoke(e)),
+ onclick = HtmlHelper.Instance.Callback().Create(this, e => click?.Invoke(e)),
Disabled = disabled,
}, condition);
diff --git a/src/TDesign/Components/Forms/TInputRadio.cs b/src/TDesign/Components/Forms/TInputRadio.cs
index 54367c28..490d7518 100644
--- a/src/TDesign/Components/Forms/TInputRadio.cs
+++ b/src/TDesign/Components/Forms/TInputRadio.cs
@@ -60,21 +60,21 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
content.OpenRegion(10000);
content.CreateElement(0, "span", attributes: new
{
- @class = HtmlHelper.Class.Append("t-radio__input", !IsButtonStyle, "t-radio-button__input")
+ @class = HtmlHelper.Instance.Class().Append("t-radio__input", !IsButtonStyle, "t-radio-button__input")
});
content.CreateElement(1, "span", ChildContent, new
{
- @class = HtmlHelper.Class.Append("t-radio__label", !IsButtonStyle, "t-radio-button__label")
+ @class = HtmlHelper.Instance.Class().Append("t-radio__label", !IsButtonStyle, "t-radio-button__label")
});
content.CloseRegion();
},
new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-radio", !IsButtonStyle, "t-radio-button")
.Append("t-is-disabled", Disabled)
.Append("t-is-checked", Checked),
- style = HtmlHelper.Style.Append("background-color: var(--td-bg-color-container-select);transition: all .2s cubic-bezier(.38,0,.24,1);", CascadingRadioGroup?.ButtonStyle == RadioButtonStyle.Filled && Checked)
+ style = HtmlHelper.Instance.Style().Append("background-color: var(--td-bg-color-container-select);transition: all .2s cubic-bezier(.38,0,.24,1);", CascadingRadioGroup?.ButtonStyle == RadioButtonStyle.Filled && Checked)
.Append("background-color: var(--td-brand-color);transition: all .2s cubic-bezier(.38,0,.24,1);", CascadingRadioGroup?.ButtonStyle == RadioButtonStyle.PrimaryFilled && Checked)
});
}
diff --git a/src/TDesign/Components/Forms/TInputTag.cs b/src/TDesign/Components/Forms/TInputTag.cs
index 3fde9b92..45bd61ab 100644
--- a/src/TDesign/Components/Forms/TInputTag.cs
+++ b/src/TDesign/Components/Forms/TInputTag.cs
@@ -1,6 +1,4 @@
-using ComponentBuilder;
-using ComponentBuilder.JSInterope;
-using Microsoft.JSInterop;
+using Microsoft.JSInterop;
namespace TDesign;
@@ -51,7 +49,7 @@ protected override void OnParametersSet()
if ( Prefix.IsNotNullOrEmpty() )
{
- PrefixContent ??= HtmlHelper.CreateContent(Prefix);
+ PrefixContent ??= HtmlHelper.Instance.CreateContent(Prefix);
}
}
protected override void OnAfterRender(bool firstRender)
@@ -97,7 +95,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
}, captureReference: el => _inputRef = el);
inner.Span("t-input__input-pre").Close();
- }, "t-input--prefix", HtmlHelper.Class.Append("t-tag-input")
+ }, "t-input--prefix", HtmlHelper.Instance.Class().Append("t-tag-input")
.Append("t-is-empty", !Value!.Any())
.Append("t-tag-input--with-tag", Value.Any())
.ToString());
@@ -107,8 +105,8 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
{
//if ( firstRender )
//{
- var tdesignJs = await JS.Value.ImportTDesignScriptAsync();
- await tdesignJs.InvokeVoidAsync("tagInput.pressKey", _inputRef, CallbackFactory.Create((keyCode, inputText) =>
+ var tdesignJs = await JS.ImportTDesignScriptAsync();
+ await tdesignJs.Module.InvokeVoidAsync("tagInput.pressKey", _inputRef, JSInvokeMethodFactory.Create((keyCode, inputText) =>
{
_inputText = inputText;
HandleKey(keyCode);
diff --git a/src/TDesign/Components/Forms/TInputText.cs b/src/TDesign/Components/Forms/TInputText.cs
index b8f763c2..d209ce79 100644
--- a/src/TDesign/Components/Forms/TInputText.cs
+++ b/src/TDesign/Components/Forms/TInputText.cs
@@ -61,7 +61,7 @@ void BuildPrefixOrSuffix(RenderTreeBuilder builder, int sequence, string? text,
}
}, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append($"t-input__{cssClassName}", !string.IsNullOrEmpty(text) || icon is not null)
.Append($"t-input__{cssClassName}-icon", icon is not null)
}, !string.IsNullOrEmpty(text) || icon is not null);
diff --git a/src/TDesign/Components/Forms/TInputTextArea.cs b/src/TDesign/Components/Forms/TInputTextArea.cs
index 146a2ac4..006e8594 100644
--- a/src/TDesign/Components/Forms/TInputTextArea.cs
+++ b/src/TDesign/Components/Forms/TInputTextArea.cs
@@ -24,7 +24,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
base.BuildRenderTree(content);
}, new
{
- @class = HtmlHelper.Class.Append("t-textarea")
+ @class = HtmlHelper.Instance.Class().Append("t-textarea")
.Append("t-is-disabled", Disabled)
.Append("t-is-readonly", Readonly)
});
diff --git a/src/TDesign/Components/Forms/TSelect.razor.cs b/src/TDesign/Components/Forms/TSelect.razor.cs
index a2297982..b889a7d8 100644
--- a/src/TDesign/Components/Forms/TSelect.razor.cs
+++ b/src/TDesign/Components/Forms/TSelect.razor.cs
@@ -114,7 +114,7 @@ protected override void BuildCssClass(ICssClassBuilder builder)
///
protected override void BuildAttributes(IDictionary attributes)
{
- attributes["onclick"] = HtmlHelper.Event.Create(this, () =>
+ attributes["onclick"] = HtmlHelper.Instance.Callback().Create(this, () =>
{
if (!Disabled)
{
diff --git a/src/TDesign/Components/Forms/TSwitch.cs b/src/TDesign/Components/Forms/TSwitch.cs
index 24e5c300..4752396f 100644
--- a/src/TDesign/Components/Forms/TSwitch.cs
+++ b/src/TDesign/Components/Forms/TSwitch.cs
@@ -44,10 +44,10 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
},
attributes: new
{
- @class = HtmlHelper.Class.Append("t-switch__handle").Append(LOADING_CLASS_NAME, Loading).Append(DISABLED_CLASS_NAME, Disabled)
+ @class = HtmlHelper.Instance.Class().Append("t-switch__handle").Append(LOADING_CLASS_NAME, Loading).Append(DISABLED_CLASS_NAME, Disabled)
});
var content = Value ? TrueContent : FalseContent;
- var cssBuilder = HtmlHelper.Class.Append("t-switch__content").Append(Size.GetCssClass()).Append(DISABLED_CLASS_NAME, Disabled);
+ var cssBuilder = HtmlHelper.Instance.Class().Append("t-switch__content").Append(Size.GetCssClass()).Append(DISABLED_CLASS_NAME, Disabled);
if (content == null)
{
builder.CreateElement(++sequence, "div", attributes: new { @class = cssBuilder });
@@ -71,7 +71,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
protected override void BuildEventAttribute(IDictionary attributes)
{
- attributes[EventName] = HtmlHelper.Event.Create(this, e =>
+ attributes[EventName] = HtmlHelper.Instance.Callback().Create(this, e =>
{
//ChangedValue = !ChangedValue;
Value = !Value;
diff --git a/src/TDesign/Components/Menu/TMenu.cs b/src/TDesign/Components/Menu/TMenu.cs
index 956c7d4e..e0641283 100644
--- a/src/TDesign/Components/Menu/TMenu.cs
+++ b/src/TDesign/Components/Menu/TMenu.cs
@@ -84,7 +84,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
builder.CreateElement(1, "ul", ChildContent, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-menu")
.Append("t-menu--scroll narrow-scrollbar", Aside),
});
diff --git a/src/TDesign/Components/Menu/TMenuItem.cs b/src/TDesign/Components/Menu/TMenuItem.cs
index e687fcc3..855e2c34 100644
--- a/src/TDesign/Components/Menu/TMenuItem.cs
+++ b/src/TDesign/Components/Menu/TMenuItem.cs
@@ -80,7 +80,7 @@ protected override void BuildAttributes(IDictionary attributes)
if (CanNavigationChanged && !string.IsNullOrWhiteSpace(Link))
{
attributes["href"] = Link;
- attributes["onclick"] = HtmlHelper.Event.Create(this, NavigateTo);
+ attributes["onclick"] = HtmlHelper.Instance.Callback().Create(this, NavigateTo);
}
}
diff --git a/src/TDesign/Components/Menu/TSubMenu.cs b/src/TDesign/Components/Menu/TSubMenu.cs
index 5cf33347..b5a2ee41 100644
--- a/src/TDesign/Components/Menu/TSubMenu.cs
+++ b/src/TDesign/Components/Menu/TSubMenu.cs
@@ -49,7 +49,7 @@ protected override void BuildAttributes(IDictionary attributes)
{
if (CascadingMenu.Popup)
{
- attributes["onmouseleave"] = HtmlHelper.Event.Create(this, async () =>
+ attributes["onmouseleave"] = HtmlHelper.Instance.Callback().Create(this, async () =>
{
await Task.Delay(100);
if (CanClose)
@@ -79,20 +79,20 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
Dictionary htmlAttributes = new()
{
- ["class"] = HtmlHelper.Class.Append(CascadingMenu.GetMenuExpandClass())
+ ["class"] = HtmlHelper.Instance.Class().Append(CascadingMenu.GetMenuExpandClass())
.Append(IsOpenCssClass, IsOpened),
- ["style"] = HtmlHelper.Style.Append(CascadingMenu.GetMenuExapndStyle())
+ ["style"] = HtmlHelper.Instance.Style().Append(CascadingMenu.GetMenuExapndStyle())
};
var eventAttribute = new Dictionary();
if (CascadingMenu.Popup)
{
- htmlAttributes["onmouseenter"] = HtmlHelper.Event.Create(this, () =>
+ htmlAttributes["onmouseenter"] = HtmlHelper.Instance.Callback().Create(this, () =>
{
CanClose = false;
});
- htmlAttributes["onmouseleave"] = HtmlHelper.Event.Create(this, () =>
+ htmlAttributes["onmouseleave"] = HtmlHelper.Instance.Callback().Create(this, () =>
{
CanClose = true;
CollapseSubMenuItem();
@@ -117,11 +117,11 @@ private void BuildCallbackAttributes(Dictionary htmlAttributes)
{
if (CascadingMenu.Popup)
{
- htmlAttributes["onmouseenter"] = HtmlHelper.Event.Create(this, ExpandSubMenuItem);
+ htmlAttributes["onmouseenter"] = HtmlHelper.Instance.Callback().Create(this, ExpandSubMenuItem);
}
else
{
- htmlAttributes["onclick"] = HtmlHelper.Event.Create(this, () =>
+ htmlAttributes["onclick"] = HtmlHelper.Instance.Callback().Create(this, () =>
{
if (IsOpened)
{
diff --git a/src/TDesign/Components/Notify/Messages/TMessage.cs b/src/TDesign/Components/Notify/Messages/TMessage.cs
index cec0a320..d31b67fb 100644
--- a/src/TDesign/Components/Notify/Messages/TMessage.cs
+++ b/src/TDesign/Components/Notify/Messages/TMessage.cs
@@ -63,7 +63,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
}, attributes: new
{
@class = "t-message__close",
- onclick = HtmlHelper.Event.Create(this, () =>
+ onclick = HtmlHelper.Instance.Callback().Create(this, () =>
{
Closed = true;
StateHasChanged();
diff --git a/src/TDesign/Components/Notify/Messages/TMessageContainer.cs b/src/TDesign/Components/Notify/Messages/TMessageContainer.cs
index 2fd952f5..91bb3d36 100644
--- a/src/TDesign/Components/Notify/Messages/TMessageContainer.cs
+++ b/src/TDesign/Components/Notify/Messages/TMessageContainer.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components.Rendering;
-
using TDesign.Notification;
namespace TDesign;
@@ -27,13 +26,13 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
});
}
},
- HtmlHelper.CreateHtmlAttributes(attributes =>
+ HtmlHelper.Instance.CreateHtmlAttributes(attributes =>
{
var (classOrStyle, value) = MessageConfiguration.GetPlacement(item.Key);
- attributes["class"] = HtmlHelper.Class.Append("t-message__list").Append(value, classOrStyle);
+ attributes["class"] = HtmlHelper.Instance.Class().Append("t-message__list").Append(value, classOrStyle);
if (!classOrStyle)
{
- attributes["style"] = HtmlHelper.Class.Append(value);
+ attributes["style"] = HtmlHelper.Instance.Class().Append(value);
}
})
);
diff --git a/src/TDesign/Components/Notify/Notification/TNotificationContainer.cs b/src/TDesign/Components/Notify/Notification/TNotificationContainer.cs
index 5def024e..7d9bff76 100644
--- a/src/TDesign/Components/Notify/Notification/TNotificationContainer.cs
+++ b/src/TDesign/Components/Notify/Notification/TNotificationContainer.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components.Rendering;
-
using TDesign.Notification;
namespace TDesign;
@@ -24,15 +23,15 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
configuration.SubTitle,
configuration?.Theme,
configuration?.Icon,
- style = HtmlHelper.Style.Append("margin-bottom:16px")
+ style = HtmlHelper.Instance.Style().Append("margin-bottom:16px")
}); ;
}
},
- HtmlHelper.CreateHtmlAttributes(attributes =>
+ HtmlHelper.Instance.CreateHtmlAttributes(attributes =>
{
var (classOrStyle, value) = MessageConfiguration.GetPlacement(item.Key);
- attributes["class"] = HtmlHelper.Class.Append(value, classOrStyle);
- attributes["style"] = HtmlHelper.Class.Append("z-index:6000").Append(value, !classOrStyle);
+ attributes["class"] = HtmlHelper.Instance.Class().Append(value, classOrStyle);
+ attributes["style"] = HtmlHelper.Instance.Class().Append("z-index:6000").Append(value, !classOrStyle);
})
);
}
diff --git a/src/TDesign/Components/Popup/PopperExtensions.cs b/src/TDesign/Components/Popup/PopperExtensions.cs
index d14ce7b1..0c12b155 100644
--- a/src/TDesign/Components/Popup/PopperExtensions.cs
+++ b/src/TDesign/Components/Popup/PopperExtensions.cs
@@ -16,8 +16,8 @@ public static class PopperExtensions
public static async ValueTask InvokePopupAsync(this IJSRuntime js, ElementReference selectorRef, ElementReference popupRef, PopperOptions options)
{
var tdesignJsObj = await js.ImportTDesignScriptAsync();
- var popperObject = await tdesignJsObj.InvokeAsync("popup.show", selectorRef, popupRef, options, DotNetObjectReference.Create(options));
+ var popperObject = await tdesignJsObj.Module.InvokeAsync("popup.show", selectorRef, popupRef, options, DotNetObjectReference.Create(options));
- return new (tdesignJsObj,popperObject, options);
+ return new (tdesignJsObj.Module,popperObject, options);
}
}
diff --git a/src/TDesign/Components/Popup/TPopup.cs b/src/TDesign/Components/Popup/TPopup.cs
index 2f10ca45..a00cd85b 100644
--- a/src/TDesign/Components/Popup/TPopup.cs
+++ b/src/TDesign/Components/Popup/TPopup.cs
@@ -76,7 +76,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
},
new
{
- @class = HtmlHelper.Class.Append("t-popup__content").Append("t-popup__content--arrow", Arrow)
+ @class = HtmlHelper.Instance.Class().Append("t-popup__content").Append("t-popup__content--arrow", Arrow)
});
}
@@ -102,7 +102,7 @@ protected override void CaptureElementReference(RenderTreeBuilder builder, int s
/// 被触发弹出层的元素引用。
public async Task Show(IBlazorComponent selector)
{
- _instance = await JS.Value.InvokePopupAsync(selector.Reference!.Value, Reference!.Value, new()
+ _instance = await JS.InvokePopupAsync(selector.Reference!.Value, Reference!.Value, new()
{
Timeout = Timeout ?? Options.Value.PopupTimeout ?? 400,
Placement = Placement
diff --git a/src/TDesign/Components/Step/TStepItem.cs b/src/TDesign/Components/Step/TStepItem.cs
index 4cbc9538..0041362a 100644
--- a/src/TDesign/Components/Step/TStepItem.cs
+++ b/src/TDesign/Components/Step/TStepItem.cs
@@ -51,7 +51,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
BuildTIcon(inner, 0);
BuildContent(inner, 1);
- }, new { @class = HtmlHelper.Class.Append("t-steps-item__inner") });
+ }, new { @class = HtmlHelper.Instance.Class().Append("t-steps-item__inner") });
}
private void BuildContent(RenderTreeBuilder builder, int sequence)
@@ -108,7 +108,7 @@ private void BuildTIcon(RenderTreeBuilder builder, int sequence)
},
new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-steps-item__icon")
.Append($"t-steps-item--{Status.GetCssClass()}")
});
diff --git a/src/TDesign/Components/TAffix.cs b/src/TDesign/Components/TAffix.cs
index 4091ad5f..204b1e13 100644
--- a/src/TDesign/Components/TAffix.cs
+++ b/src/TDesign/Components/TAffix.cs
@@ -5,7 +5,7 @@ namespace TDesign;
///
/// 固钉组件。
///
-public class TAffix : BlazorComponentBase, IHasChildContent
+public class TAffix : TDesignComponentBase, IHasChildContent
{
#region Parameters
@@ -145,7 +145,7 @@ protected async override Task OnAfterRenderAsync(bool firstRender)
if (firstRender)
{
var objRef = DotNetObjectReference.Create(this);
- var popperWrapper = await JS.Value.InvokeAsync("import", "./_content/TDesign/tdesign-blazor.js");
+ var popperWrapper = await JS.InvokeAsync("import", "./_content/TDesign/tdesign-blazor.js");
await popperWrapper.InvokeVoidAsync("affix.init", Container, objRef);
var y = await popperWrapper.InvokeAsync("affix.positionY", _affixId);
_affixYInit = y;
diff --git a/src/TDesign/Components/TAlert.cs b/src/TDesign/Components/TAlert.cs
index b1be7903..dec9ccdc 100644
--- a/src/TDesign/Components/TAlert.cs
+++ b/src/TDesign/Components/TAlert.cs
@@ -65,7 +65,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
builder.CreateElement(sequence + 2, "div", icon => icon.CreateComponent(0, attributes: new { Name = IconName.Close }), new
{
@class = "t-alert__close",
- onclick = HtmlHelper.Event.Create(this, () =>
+ onclick = HtmlHelper.Instance.Callback().Create(this, () =>
{
Closed = !Closable;
StateHasChanged();
diff --git a/src/TDesign/Components/TBadge.cs b/src/TDesign/Components/TBadge.cs
index f82d3c6c..61c33003 100644
--- a/src/TDesign/Components/TBadge.cs
+++ b/src/TDesign/Components/TBadge.cs
@@ -43,10 +43,10 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
builder.CreateElement(sequence, "div", ChildContent, new { @class = "badge-block" });
builder.CreateElement(sequence + 1, "div", Text, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append($"t-badge--{Shape.GetCssClass()}")
.Append("t-size-s", Small),
- style = HtmlHelper.Style
+ style = HtmlHelper.Instance.Style()
.Append($"background-color:{Color}", !string.IsNullOrEmpty(Color))
.Append($"top:{Top}px", Top.HasValue)
.Append($"right:{Right}px", Right.HasValue)
diff --git a/src/TDesign/Components/TButton.cs b/src/TDesign/Components/TButton.cs
index 83441c77..60301075 100644
--- a/src/TDesign/Components/TButton.cs
+++ b/src/TDesign/Components/TButton.cs
@@ -7,7 +7,7 @@ namespace TDesign;
///
[HtmlTag("button")]
[CssClass("t-button")]
-public class TButton : TDesignComponentBase, IHasOnClick, IHasChildContent
+public class TButton : TDesignComponentBase, IHasChildContent
{
///
///
diff --git a/src/TDesign/Components/TCard.cs b/src/TDesign/Components/TCard.cs
index cd999a74..43a811f3 100644
--- a/src/TDesign/Components/TCard.cs
+++ b/src/TDesign/Components/TCard.cs
@@ -75,7 +75,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
header.CreateElement(1, "div", HeaderActionContent, new { @class = "t-card__actions" }, HeaderActionContent is not null);
}, new
{
- @class = HtmlHelper.Class.Append("t-card__header")
+ @class = HtmlHelper.Instance.Class().Append("t-card__header")
.Append("t-card__title--bordered", HeaderDivider)
}, HasHeader);
diff --git a/src/TDesign/Components/TDialog.cs b/src/TDesign/Components/TDialog.cs
index a29334e7..11391ff8 100644
--- a/src/TDesign/Components/TDialog.cs
+++ b/src/TDesign/Components/TDialog.cs
@@ -56,7 +56,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
}, new
{
@class = "t-dialog__close",
- onclick = HtmlHelper.Event.Create(this, () => this.Activate(false))
+ onclick = HtmlHelper.Instance.Callback().Create(this, () => this.Activate(false))
});
}, new { @class = "t-dialog__header" });
@@ -68,10 +68,10 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
dialog.CreateElement(3, "div", FooterContent, new { @class = "t-dialog__footer" }, FooterContent is not null);
}, new
{
- @class = HtmlHelper.Class.Append("t-dialog")
+ @class = HtmlHelper.Instance.Class().Append("t-dialog")
.Append("t-dialog--default")
});
- }, new { @class = HtmlHelper.Class.Append("t-dialog__position").Append("t-dialog--center", Center, "t-dialog--top") });
+ }, new { @class = HtmlHelper.Instance.Class().Append("t-dialog__position").Append("t-dialog--center", Center, "t-dialog--top") });
}, new { @class = "t-dialog__wrap" });
}
diff --git a/src/TDesign/Components/TImage.cs b/src/TDesign/Components/TImage.cs
index f63c1e4f..8ff43fe8 100644
--- a/src/TDesign/Components/TImage.cs
+++ b/src/TDesign/Components/TImage.cs
@@ -90,7 +90,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
builder.CreateElement(sequence + 2, "img", attributes: new
{
src = Src,
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-image")
.Append(Fit.GetCssClass())
.Append($"t-image--position-{Position.GetCssClass()}"),
@@ -110,7 +110,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
}, attributes: new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-image__overlay-content")
.Append("t-image__overlay-content--hidden", OverlayTrigger != null)
}, Gallery || OverlayTrigger != null);
diff --git a/src/TDesign/Components/TPagination.cs b/src/TDesign/Components/TPagination.cs
index 3491c9e5..d9abdf08 100644
--- a/src/TDesign/Components/TPagination.cs
+++ b/src/TDesign/Components/TPagination.cs
@@ -200,7 +200,7 @@ void BuildTotal(RenderTreeBuilder builder)
///
///
void BuildPageSizeSelect(RenderTreeBuilder builder)
- => builder.Fluent().Div("t-select__wrap t-pagination__select").Content(HtmlHelper.CreateContent($"{PageSize} 条/页")).Close();
+ => builder.Fluent().Div("t-select__wrap t-pagination__select").Content(HtmlHelper.Instance.CreateContent($"{PageSize} 条/页")).Close();
///
/// 构建上一页或下一页按钮。
@@ -391,7 +391,7 @@ void BuildJumper(RenderTreeBuilder builder)
Size,
Value = JumpPage,
ValueExpression = (Expression>)(() => JumpPage),
- ValueChanged = HtmlHelper.Event.Create(this, NavigateToPage)
+ ValueChanged = HtmlHelper.Instance.Callback().Create(this, NavigateToPage)
}))
.Close();
})
diff --git a/src/TDesign/Components/TPopConfirm.cs b/src/TDesign/Components/TPopConfirm.cs
index b1df597b..9db6fe4c 100644
--- a/src/TDesign/Components/TPopConfirm.cs
+++ b/src/TDesign/Components/TPopConfirm.cs
@@ -146,7 +146,7 @@ void BuildButton(RenderTreeBuilder builder,int sequence,string? text,EventCallba
{
Theme = theme,
Varient = varient,
- OnClick = HtmlHelper.Event.Create(this, async (_) =>
+ OnClick = HtmlHelper.Instance.Callback().Create(this, async (_) =>
{
PopConfirmEventArgs e = new();
await callback.InvokeAsync(e);
diff --git a/src/TDesign/Components/TProgress.cs b/src/TDesign/Components/TProgress.cs
index 447ce509..b8e48fbe 100644
--- a/src/TDesign/Components/TProgress.cs
+++ b/src/TDesign/Components/TProgress.cs
@@ -100,7 +100,7 @@ private void BuildLine(RenderTreeBuilder builder)
},
new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-progress--thin")
.Append("t-progress--status--undefined", Status is null, $"t-progress--status--{Status?.GetCssClass()}")
.Append("t-progress--status--active", Active)
@@ -128,7 +128,7 @@ private void BuildPlump(RenderTreeBuilder builder)
}
}, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-progress__bar")
.Append("t-progress--plump")
.Append("t-progress--status--undefined", Status is null, $"t-progress--status--{Status?.GetCssClass()}")
@@ -178,11 +178,11 @@ private void BuildCircle(RenderTreeBuilder builder)
});
}, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-progress--circle")
.Append("t-progress--status--undefined", Status is null, $"t-progress--status--{Status?.GetCssClass()}")
.Append("t-progress--status--active", Active),
- style = HtmlHelper.Style
+ style = HtmlHelper.Instance.Style()
.Append($"width:{size}px", size.HasValue)
.Append($"height:{size}px", size.HasValue)
.Append($"font-size:{fontSize}px", fontSize.HasValue)
@@ -218,7 +218,7 @@ private void BuildProgressInner(RenderTreeBuilder content, int sequence = 0, Ren
new
{
@class = "t-progress__inner",
- style = HtmlHelper.Style.Append($"width:{Value}%").Append(additionalStyle ??= string.Empty),
+ style = HtmlHelper.Instance.Style().Append($"width:{Value}%").Append(additionalStyle ??= string.Empty),
});
}
diff --git a/src/TDesign/Components/TTag.cs b/src/TDesign/Components/TTag.cs
index b5e546b9..fba6a902 100644
--- a/src/TDesign/Components/TTag.cs
+++ b/src/TDesign/Components/TTag.cs
@@ -106,7 +106,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
{
Name = IconName.Close,
AdditionalCLass = "t-tag__icon-close",
- onclick = HtmlHelper.Event.Create(this, () =>
+ onclick = HtmlHelper.Instance.Callback().Create(this, () =>
{
if (Disabled)
{
@@ -133,7 +133,7 @@ protected override void BuildCssClass(ICssClassBuilder builder)
///
protected override void BuildAttributes(IDictionary attributes)
{
- attributes["onclick"] = HtmlHelper.Event.Create(this, async _ =>
+ attributes["onclick"] = HtmlHelper.Instance.Callback().Create(this, async _ =>
{
if (Checkbox && !Disabled)
{
diff --git a/src/TDesign/Components/Tab/TTab.cs b/src/TDesign/Components/Tab/TTab.cs
index 2a5868a9..1de734fb 100644
--- a/src/TDesign/Components/Tab/TTab.cs
+++ b/src/TDesign/Components/Tab/TTab.cs
@@ -45,7 +45,7 @@ void BuildTabHeader(RenderTreeBuilder builder, int sequence)
{
builder.CreateElement(sequence, "div", BuildTabHeaderNav, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-tabs__header")
.Append(Position.GetCssClass("t-is-")),
});
@@ -69,7 +69,7 @@ void BuildTabHeaderNav(RenderTreeBuilder builder)
}, new { @class = "t-tabs__nav-scroll" });
}, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-tabs__nav-container")
.Append(CardCss, Card)
.Append(Position.GetCssClass("t-is-"))
@@ -111,10 +111,10 @@ void BuildTabHeaderItem(RenderTreeBuilder builder, int sequence)
{
builder.CreateElement(0, "div", attributes: new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-tabs__bar")
.Append(Position.GetCssClass("t-is-")),
- //style = HtmlHelper.Style
+ //style = HtmlHelper.Instance.Style()
// .Append($"left:{tabItem.Width * SwitchIndex}px")
// .Append($"width:{tabItem?.Width}px", tabItem!.Width.HasValue)
});
@@ -130,19 +130,19 @@ void BuildTabHeaderItem(RenderTreeBuilder builder, int sequence)
}, new { @class = "t-tabs__nav-item-text-wrapper" });
}, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-tabs__nav-item-wrapper")
.Append(GetActiveCss(index))
});
}, new
{
- @class = HtmlHelper.Class
+ @class = HtmlHelper.Instance.Class()
.Append("t-tabs__nav-item")
.Append(CardCss, Card)
.Append(GetActiveCss(index))
.Append("t-is-disabled", tabItem!.Disabled)
.Append(Size.GetCssClass("t-size-")),
- onclick = HtmlHelper.Event.Create(this, () =>
+ onclick = HtmlHelper.Instance.Callback().Create(this, () =>
{
if (!tabItem!.Disabled)
{
diff --git a/src/TDesign/Components/Table/TTable.build.cs b/src/TDesign/Components/Table/TTable.build.cs
index f8b66528..33a17dcf 100644
--- a/src/TDesign/Components/Table/TTable.build.cs
+++ b/src/TDesign/Components/Table/TTable.build.cs
@@ -211,11 +211,11 @@ void BuildPagination(RenderTreeBuilder builder, int sequence)
builder.CreateComponent(sequence, attributes: new
{
PageIndex,
- PageIndexChanged = HtmlHelper.Event.Create(this, value => QueryData(value, PageSize)),
+ PageIndexChanged = HtmlHelper.Instance.Callback().Create(this, value => QueryData(value, PageSize)),
PageSize,
- PageSizeChanged = HtmlHelper.Event.Create(this, value => QueryData(1, value)),
+ PageSizeChanged = HtmlHelper.Instance.Callback().Create(this, value => QueryData(1, value)),
Total = TotalCount,
- TotalChanged = HtmlHelper.Event.Create(this, value => QueryData(1, PageSize)),
+ TotalChanged = HtmlHelper.Instance.Callback().Create(this, value => QueryData(1, PageSize)),
ShowJumpPage = true
});
}, new { @class = "t-table__pagination" });
diff --git a/src/TDesign/Components/Timeline/TTimelineItem.cs b/src/TDesign/Components/Timeline/TTimelineItem.cs
index 969fa59f..e71cdbed 100644
--- a/src/TDesign/Components/Timeline/TTimelineItem.cs
+++ b/src/TDesign/Components/Timeline/TTimelineItem.cs
@@ -51,7 +51,7 @@ protected override void AddContent(RenderTreeBuilder builder, int sequence)
.Class("t-timeline-item__wrapper")
.Content(content =>
{
- content.Fluent().Div()
+ content.Div()
.Class("t-timeline-item__dot")
.Class(Color.GetCssClass("t-timeline-item__dot--"))
.Class( "t-timeline-item__dot--custom", IconName is not null)
diff --git a/src/TDesign/TDesign.csproj b/src/TDesign/TDesign.csproj
index 54f42142..75b3ef36 100644
--- a/src/TDesign/TDesign.csproj
+++ b/src/TDesign/TDesign.csproj
@@ -1,9 +1,6 @@
-
+
- 10
- 11
- net6.0;net7.0
enable
TDesign
TDesign
@@ -31,29 +28,6 @@
logo.png
组件 TDesign Blazor Component WebAssembly
-
- true
- true
-
-
-
-
- true
- full
- false
- DEBUG;TRACE
-
-
-
-
- false
- true
- TRACE
- false
- ..\..\pack
-
-
-
@@ -71,8 +45,12 @@
-
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/TDesign/TDesignComponentBase.cs b/src/TDesign/TDesignComponentBase.cs
index 2a3e22be..d20ecd8a 100644
--- a/src/TDesign/TDesignComponentBase.cs
+++ b/src/TDesign/TDesignComponentBase.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Components.Rendering;
using Microsoft.Extensions.Options;
+using Microsoft.JSInterop;
namespace TDesign;
///
@@ -11,6 +12,7 @@ public abstract class TDesignComponentBase : BlazorComponentBase
/// 获取注入的配置。
///
[Inject]protected IOptions Options { get; set; }
+ [Inject]protected IJSRuntime JS { get; set; }
///
/// 级联 TPopup 组件。
///
@@ -46,19 +48,19 @@ protected virtual void BuildPopupAttributes(IDictionary attribut
switch (CascadingPopup!.Trigger)
{
case PopupTrigger.Click:
- attributes["onclick"] = HtmlHelper.Event.Create(this, TogglePopup);
- //attributes["onblur"] = HtmlHelper.Event.Create(this, HidePopup);
+ attributes["onclick"] = HtmlHelper.Instance.Callback().Create(this, TogglePopup);
+ //attributes["onblur"] = HtmlHelper.Instance.Callback().Create(this, HidePopup);
break;
case PopupTrigger.Hover:
- attributes["onmouseenter"] = HtmlHelper.Event.Create(this, ShowPopup);
- attributes["onmouseleave"] = HtmlHelper.Event.Create(this, HidePopup);
+ attributes["onmouseenter"] = HtmlHelper.Instance.Callback().Create(this, ShowPopup);
+ attributes["onmouseleave"] = HtmlHelper.Instance.Callback().Create(this, HidePopup);
break;
case PopupTrigger.Focus:
- attributes["onfocus"] = HtmlHelper.Event.Create(this, ShowPopup);
- attributes["onblur"] = HtmlHelper.Event.Create(this, HidePopup);
+ attributes["onfocus"] = HtmlHelper.Instance.Callback().Create(this, ShowPopup);
+ attributes["onblur"] = HtmlHelper.Instance.Callback().Create(this, HidePopup);
break;
case PopupTrigger.ContextMenu:
- attributes["onclick"] = HtmlHelper.Event.Create(this, e =>
+ attributes["onclick"] = HtmlHelper.Instance.Callback().Create(this, e =>
{
if (e.Button != 2)
{
diff --git a/src/TDesign/TDesignExtensions.cs b/src/TDesign/TDesignExtensions.cs
index 0fcc3135..60955924 100644
--- a/src/TDesign/TDesignExtensions.cs
+++ b/src/TDesign/TDesignExtensions.cs
@@ -1,6 +1,4 @@
-using ComponentBuilder.JSInterope;
-using Microsoft.JSInterop;
-using System.Reflection;
+using Microsoft.JSInterop;
namespace TDesign;
///
@@ -8,11 +6,6 @@ namespace TDesign;
///
public static class TDesignExtensions
{
- public static bool TryGetCustomAttribute(this MemberInfo? memberInfo, out TAttribute attribute) where TAttribute : Attribute
- {
- attribute = memberInfo?.GetCustomAttribute();
- return attribute is not null;
- }
///
/// 获取状态对应的图标名称。
///
@@ -40,8 +33,8 @@ public static bool TryGetCustomAttribute(this MemberInfo? memberInfo
///
///
///
- public static ValueTask ImportTDesignScriptAsync(this IJSRuntime js)
- => js.InvokeAsync("import", "./_content/TDesign/tdesign-blazor.js");
+ public static ValueTask ImportTDesignScriptAsync(this IJSRuntime js)
+ => js.ImportAsync("./_content/TDesign/tdesign-blazor.js");
///
/// 执行切换暗黑和浅色模式切换
@@ -51,7 +44,7 @@ public static ValueTask ImportTDesignScriptAsync(this IJSRun
public static async Task ChangeThemeMode(this IJSRuntime js, bool isDark = true)
{
var jsObject = await js.ImportTDesignScriptAsync();
- await jsObject.InvokeVoidAsync(isDark ? "theme.dark" : "theme.light");
+ await jsObject.Module.InvokeVoidAsync(isDark ? "theme.dark" : "theme.light");
}
public static async ValueTask FocusAsync(this IJSRuntime js, ElementReference? inputElement,Action? focused = default)
@@ -62,6 +55,6 @@ public static async ValueTask FocusAsync(this IJSRuntime js, ElementReference? i
}
var tdesignScript = await js.ImportTDesignScriptAsync();
- await tdesignScript.InvokeVoidAsync("tdesign.focus", inputElement);
+ await tdesignScript.Module.InvokeVoidAsync("tdesign.focus", inputElement);
}
}
diff --git a/src/TDesign/Using.cs b/src/TDesign/Using.cs
index b462a4d0..8ffba877 100644
--- a/src/TDesign/Using.cs
+++ b/src/TDesign/Using.cs
@@ -1,9 +1,10 @@
global using ComponentBuilder;
-global using ComponentBuilder.Fluent;
+global using ComponentBuilder.FluentRenderTree;
global using ComponentBuilder.Definitions;
+global using ComponentBuilder.JSInterop;
global using Microsoft.AspNetCore.Components;
global using Microsoft.AspNetCore.Components.Web;
global using Microsoft.AspNetCore.Components.Rendering;
-global using OneOf;
+global using OneOf;
\ No newline at end of file