diff --git a/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor b/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor index b4fae6803be..2d45a430aaf 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor @@ -149,6 +149,30 @@ + +
+

@((MarkupString)Localizer["GroupDescription"].Value)

+ + + + + + + +
+ + + + + + + + + + + +
+ diff --git a/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor.cs index f451e966079..249084b481d 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor.cs @@ -26,6 +26,7 @@ public sealed partial class EditorForms private IStringLocalizer? FooLocalizer { get; set; } private List _ignoreItems = []; + private EditorFormGroupType _groupType = EditorFormGroupType.GroupBox; private Task OnSwitchIgnoreItems() { diff --git a/src/BootstrapBlazor.Server/Locales/en-US.json b/src/BootstrapBlazor.Server/Locales/en-US.json index 533283f3425..7846f91f9b8 100644 --- a/src/BootstrapBlazor.Server/Locales/en-US.json +++ b/src/BootstrapBlazor.Server/Locales/en-US.json @@ -2129,6 +2129,9 @@ "EditorFormTips3": "Complex edit columns, set up EditTemplate templates, and edit custom components", "EditorFormTips4": "The buttons in the form can be set up multiplely, just set the buttons Buttons template", "GroupBoxTitle": "An example of a form", + "GroupDescription": "Grouping is enabled by setting the GroupName parameter of the EditorItem component, and the order is controlled by GroupOrder.", + "GroupIntro": "The grouping format can be controlled by setting the groupType value.", + "GroupTitle": "Group", "IgnoreItemsDescription": "This attribute has the same priority as the Ignore parameter in EditorItem. If it is set to ignore anywhere, it will not be rendered.", "IgnoreItemsIntro": "By setting the IgnoreItems value, you can notify the component not to render the specified column in the collection.", "IgnoreItemsSwitchButtonText": "Switch", diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json index f5090947aac..d881e55de8f 100644 --- a/src/BootstrapBlazor.Server/Locales/zh-CN.json +++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json @@ -2129,6 +2129,9 @@ "EditorFormTips3": "复杂编辑列,设置 EditTemplate 模板,进行自定义组件进行编辑", "EditorFormTips4": "表单内按钮可以设置多个,设置 Buttons 模板即可", "GroupBoxTitle": "表单示例", + "GroupDescription": "通过设置 EditorItem 组件参数 GroupName 开启分组功能,通过 GroupOrder 控制顺序 ", + "GroupIntro": "通过设置 GroupType 值控制分组形式", + "GroupTitle": "分组功能", "IgnoreItemsDescription": "此属性的优先级与 EditorItem 参数 Ignore 相同,任何一个地方设置了忽略,最终都不会渲染", "IgnoreItemsIntro": "通过设置 IgnoreItems 值通知组件不渲染集合中的指定列", "IgnoreItemsSwitchButtonText": "切换", diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 093db25ddde..c31ef07228b 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@  - 10.3.1-beta02 + 10.3.1-beta03 diff --git a/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs b/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs index 5695ceb3771..f54352c97bf 100644 --- a/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs +++ b/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs @@ -16,6 +16,7 @@ namespace BootstrapBlazor.Components; public partial class EditorForm : IShowLabel, IDisposable { private string? ClassString => CssBuilder.Default("bb-editor") + .AddClass("bb-editor-group-row-header", GroupType == EditorFormGroupType.RowHeader) .AddClassFromAttributes(AdditionalAttributes) .Build(); @@ -192,6 +193,13 @@ public partial class EditorForm : IShowLabel, IDisposable [Parameter] public bool IsRenderWhenValueChanged { get; set; } + /// + /// 获得/设置 分组类型 默认 + /// Gets or sets group type. Default is + /// + [Parameter] + public EditorFormGroupType GroupType { get; set; } + /// /// 获得/设置 级联上下文 EditContext 实例 内置于 EditForm 或者 ValidateForm 时有值 /// Gets or sets Cascading EditContext Instance. Available when inside EditForm or ValidateForm diff --git a/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.scss b/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.scss index e90496b074b..0e1b29d833e 100644 --- a/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.scss +++ b/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.scss @@ -1,4 +1,4 @@ -.bb-editor { +.bb-editor { position: relative; .ef-loading { @@ -9,4 +9,43 @@ bottom: 0; background-color: var(--bs-body-bg); } + + &.bb-editor-group-row-header { + .groupbox { + --bb-groupbox-padding: 0; + --bb-groupbox-legend-top: 0; + --bb-groupbox-legend-left: 0; + --bb-groupbox-divider-color: var(--bs-border-color); + display: flex; + flex-direction: row; + flex-wrap: nowrap; + align-items: center; + border: 0; + + .legend { + writing-mode: vertical-rl; + text-orientation: mixed; + position: relative; + color: var(--bb-groupbox-divider-color); + } + + .row { + margin-inline-start: 1rem; + flex: 1; + width: 1%; + min-width: 0; + position: relative; + + &::before { + content: ""; + width: 1px; + background-color: var(--bb-groupbox-divider-color); + position: absolute; + top: 1rem; + bottom: 0; + left: -0.5rem; + } + } + } + } } diff --git a/src/BootstrapBlazor/Components/GroupBox/GroupBox.razor b/src/BootstrapBlazor/Components/GroupBox/GroupBox.razor index f69ada6fc1a..8abd0d2c7be 100644 --- a/src/BootstrapBlazor/Components/GroupBox/GroupBox.razor +++ b/src/BootstrapBlazor/Components/GroupBox/GroupBox.razor @@ -1,7 +1,7 @@ -@namespace BootstrapBlazor.Components +@namespace BootstrapBlazor.Components @inherits BootstrapComponentBase
- + @Title @ChildContent
diff --git a/src/BootstrapBlazor/Enums/EditorFormGroupType.cs b/src/BootstrapBlazor/Enums/EditorFormGroupType.cs new file mode 100644 index 00000000000..fca287b1c36 --- /dev/null +++ b/src/BootstrapBlazor/Enums/EditorFormGroupType.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License +// See the LICENSE file in the project root for more information. +// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone + +namespace BootstrapBlazor.Components; + +/// +/// EditorForm 分组类型 +/// EditorForm group type +/// +public enum EditorFormGroupType +{ + /// + /// 使用 GroupBox 形式 + /// Group box + /// + GroupBox, + + /// + /// 使用 RowHeader 形式 + /// Row header + /// + RowHeader, +} diff --git a/test/UnitTest/Components/EditorFormTest.cs b/test/UnitTest/Components/EditorFormTest.cs index b6b1fcbf617..736a136e38b 100644 --- a/test/UnitTest/Components/EditorFormTest.cs +++ b/test/UnitTest/Components/EditorFormTest.cs @@ -177,6 +177,25 @@ public void Buttons_Ok() }); } + [Fact] + public void GroupType_Ok() + { + var foo = new Foo(); + var cut = Context.Render>(pb => + { + pb.Add(a => a.Model, foo); + pb.Add(a => a.GroupType, EditorFormGroupType.GroupBox); + }); + + cut.DoesNotContain("bb-editor-group-row-header"); + + cut.Render(pb => + { + pb.Add(a => a.GroupType, EditorFormGroupType.RowHeader); + }); + cut.Contains("bb-editor-group-row-header"); + } + [Fact] public void Alignment_Right() {