From d9df874f3b54f4a9e26225ee23265fdd1d6fc47c Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 11 Dec 2024 14:34:12 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20SetLeftWidth?= =?UTF-8?q?=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Split/Split.razor.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/BootstrapBlazor/Components/Split/Split.razor.cs b/src/BootstrapBlazor/Components/Split/Split.razor.cs index dcf06b7c31e..bbb9a263971 100644 --- a/src/BootstrapBlazor/Components/Split/Split.razor.cs +++ b/src/BootstrapBlazor/Components/Split/Split.razor.cs @@ -124,6 +124,13 @@ protected override async Task OnAfterRenderAsync(bool firstRender) IsKeepOriginalSize }); + /// + /// 设置左侧窗格宽度 + /// + /// 可以是百分比或者其他单位 + /// + public Task SetLeftWidth(string leftWidth) => InvokeVoidAsync("setLeft", Id, leftWidth); + /// /// 窗格折叠时回调方法 由 JavaScript 调用 /// From 32d73fed8fb5471dfe46bb92fc0485338734f4b2 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 11 Dec 2024 14:34:27 +0800 Subject: [PATCH 2/6] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Split/Split.razor.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/BootstrapBlazor/Components/Split/Split.razor.js b/src/BootstrapBlazor/Components/Split/Split.razor.js index 2d5b886458d..aaafa748e32 100644 --- a/src/BootstrapBlazor/Components/Split/Split.razor.js +++ b/src/BootstrapBlazor/Components/Split/Split.razor.js @@ -170,6 +170,13 @@ const getMax = split => { return ret; } +export function setLeft(id, leftBasis) { + const split = Data.get(id) + if (split) { + split.splitLeft.style.setProperty('flex-basis', leftBasis); + } +} + const setLeftBasis = (split, triggerLeft) => { const { option, splitLeft, invoke, method } = split; let leftBasis = splitLeft.style.flexBasis; From e6555a7e8c9dd041a161e093c9d6e1a350abe00e Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 11 Dec 2024 14:34:38 +0800 Subject: [PATCH 3/6] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/Splits.razor | 20 +++++++++++++++++++ .../Components/Samples/Splits.razor.cs | 4 ++++ .../Components/Samples/Splittings.razor | 4 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Shared/Components/Samples/Splits.razor b/src/BootstrapBlazor.Shared/Components/Samples/Splits.razor index b7d22ff8126..29148b3f492 100644 --- a/src/BootstrapBlazor.Shared/Components/Samples/Splits.razor +++ b/src/BootstrapBlazor.Shared/Components/Samples/Splits.razor @@ -122,4 +122,24 @@ + +
+ + + +
+
+ + +
@Localizer["SplitsPanel1"]
+
+ +
@Localizer["SplitsPanel2"]
+
+
+
+
+ diff --git a/src/BootstrapBlazor.Shared/Components/Samples/Splits.razor.cs b/src/BootstrapBlazor.Shared/Components/Samples/Splits.razor.cs index 155e4963e65..b5af87f4e30 100644 --- a/src/BootstrapBlazor.Shared/Components/Samples/Splits.razor.cs +++ b/src/BootstrapBlazor.Shared/Components/Samples/Splits.razor.cs @@ -52,6 +52,10 @@ private Task OnResizedAsync(SplitterResizedEventArgs args) return Task.CompletedTask; } + private Split Split1 = default!; + + private Task OnSetLeft(string leftWidth) => Split1.SetLeftWidth(leftWidth); + /// /// 获得属性方法 /// diff --git a/src/BootstrapBlazor.Shared/Components/Samples/Splittings.razor b/src/BootstrapBlazor.Shared/Components/Samples/Splittings.razor index ef4ead056a8..d943de1a5cb 100644 --- a/src/BootstrapBlazor.Shared/Components/Samples/Splittings.razor +++ b/src/BootstrapBlazor.Shared/Components/Samples/Splittings.razor @@ -39,13 +39,13 @@ Introduction="@Localizer["SplittingColumnsIntro"]" Name="Columns">
-

+

-

+
From f3f6ce369bf5649730ce4cea5f0cd91c05af3775 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 11 Dec 2024 14:37:50 +0800 Subject: [PATCH 4/6] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Shared/Locales/en-US.json | 4 +++- src/BootstrapBlazor.Shared/Locales/zh-CN.json | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Shared/Locales/en-US.json b/src/BootstrapBlazor.Shared/Locales/en-US.json index b32e8193d6f..e6191fa36a2 100644 --- a/src/BootstrapBlazor.Shared/Locales/en-US.json +++ b/src/BootstrapBlazor.Shared/Locales/en-US.json @@ -1742,7 +1742,9 @@ "SplitsCollapsibleTrue": "Collapse button shown", "SplitsCollapsibleFalse": "Collapse button hidden", "SplitsFirstPaneMinimumSize": "The minimum size of the first pane supports any unit such as 10px 20% 5em 1rem. If no unit is provided, it defaults to px.", - "SplitsSecondPaneMinimumSize": "The minimum size of the second pane supports any unit such as 10px 20% 5em 1rem. If no unit is provided, it defaults to px." + "SplitsSecondPaneMinimumSize": "The minimum size of the second pane supports any unit such as 10px 20% 5em 1rem. If no unit is provided, it defaults to px.", + "SplitSetLeftTitle": "Code to set panel width", + "SplitSetLeftIntro": "Use the component instance method SetLeftWidth to set the width of the left/top panel, and the width of the right/bottom panel will be adaptive" }, "BootstrapBlazor.Shared.Components.Samples.Dropdowns": { "Title": "Dropdown", diff --git a/src/BootstrapBlazor.Shared/Locales/zh-CN.json b/src/BootstrapBlazor.Shared/Locales/zh-CN.json index 137b52e0efd..11d41d27de7 100644 --- a/src/BootstrapBlazor.Shared/Locales/zh-CN.json +++ b/src/BootstrapBlazor.Shared/Locales/zh-CN.json @@ -1742,7 +1742,9 @@ "SplitsCollapsibleTrue": "显示调整按钮", "SplitsCollapsibleFalse": "隐藏调整按钮", "SplitsFirstPaneMinimumSize": "第一个窗格最小尺寸支持任意单位如 10px 20% 5em 1rem 未提供单位时默认为 px", - "SplitsSecondPaneMinimumSize": "第二个窗格最小尺寸支持任意单位如 10px 20% 5em 1rem 未提供单位时默认为 px" + "SplitsSecondPaneMinimumSize": "第二个窗格最小尺寸支持任意单位如 10px 20% 5em 1rem 未提供单位时默认为 px", + "SplitSetLeftTitle": "代码设置面板宽度", + "SplitSetLeftIntro": "通过组件实例方法 SetLeftWidth 设置左侧/上侧面板宽度,右侧/下侧面板宽度自适应" }, "BootstrapBlazor.Shared.Components.Samples.Dropdowns": { "Title": "Dropdown 下拉菜单", From 48ce138be746964c17cc4252d466e0cd7bfa153b Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 11 Dec 2024 14:39:44 +0800 Subject: [PATCH 5/6] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/SplitTest.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/UnitTest/Components/SplitTest.cs b/test/UnitTest/Components/SplitTest.cs index bde4e35c14f..718bd1ac76f 100644 --- a/test/UnitTest/Components/SplitTest.cs +++ b/test/UnitTest/Components/SplitTest.cs @@ -109,6 +109,17 @@ public async Task OnResizedAsync_Ok() Assert.False(state.IsCollapsed); } + [Fact] + public async Task SetLeft_Ok() + { + var cut = Context.RenderComponent(pb => + { + pb.Add(b => b.FirstPaneTemplate, RenderSplitView("I am Pane1")); + pb.Add(b => b.SecondPaneTemplate, RenderSplitView("I am Pane2")); + }); + await cut.InvokeAsync(() => cut.Instance.SetLeftWidth("25%")); + } + static RenderFragment RenderSplitView(string name = "I am Pane1") => builder => { builder.OpenElement(1, "div"); From eb956f800ee12b516be7409ecd38d83177117f16 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 11 Dec 2024 14:40:16 +0800 Subject: [PATCH 6/6] chore: bump version 9.1.3-beta04 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 22686dd7d98..bb6d49653b5 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.1.3-beta03 + 9.1.3-beta04