-
-
Notifications
You must be signed in to change notification settings - Fork 7
feat(DockView): add OnlyWhenVisible render mode #974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f4071a8
dba799f
d29a292
6b6c57d
3f61fbf
086ac3e
5828562
4f5f3d9
8602c8a
e2da3b1
9c787a6
9e498b3
ff548b4
80f03dc
192b4f1
6a05eb8
462e41a
b7a6e13
3ebb364
342ec92
00edcca
11a144c
a590ab2
5ffc2ca
6666447
852f9ca
7ae9604
20a1c74
57e1240
d8b1250
46482e2
6c852a3
2a1ef0e
2e4d3af
c440af1
c095c99
161471a
58be1e3
3aabbca
5f04f38
a5fa298
dbe9e03
25a88e5
248b1b4
1af7881
0e7c357
01c4b9c
d0e0b02
fdbe66f
475725c
e7434ab
cef1c76
40f769c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||||||||||||||||||||||||
| // Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| // Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||||||||||||||||||||||||||||||||||||||||||
| // Website: https://www.blazor.zone or https://argozhang.github.io/ | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -8,131 +8,152 @@ | |||||||||||||||||||||||||||||||||||||||||
| namespace BootstrapBlazor.Components; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// DockContentItem 配置项子项对标 content 配置项内部 content 配置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">DockView 组件配置项,对应 content 配置项中的组件项</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">DockView component option corresponding to a component item in the content configuration</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| public partial class DockViewComponent | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 组件是否显示 Header 默认 true 显示 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 组件是否显示标题栏,默认为 true</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets whether the component header is displayed. Default is true</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public bool ShowHeader { get; set; } = true; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 组件 Title | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 组件标题</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets the component title</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public string? Title { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 组件 Title 宽度 默认 null 未设置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 组件标题宽度,默认为 null</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets the component title width. Default is null</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public int? TitleWidth { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 组件 Title 样式 默认 null 未设置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 组件标题样式类,默认为 null</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets the component title CSS class. Default is null</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public string? TitleClass { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 Title 模板 默认 null 未设置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 标题模板,默认为 null</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets the title template. Default is null</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| [JsonIgnore] | ||||||||||||||||||||||||||||||||||||||||||
| public RenderFragment? TitleTemplate { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 组件 Class 默认 null 未设置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 组件样式类,默认为 null</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets the component CSS class. Default is null</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public string? Class { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 组件是否可见 默认 true 可见 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 组件是否可见,默认为 true</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets whether the component is visible. Default is true</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public bool Visible { get; set; } = true; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 组件是否允许关闭 默认 null 使用 DockView 的配置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 组件是否允许关闭,默认为 null,未设置时使用 DockView 的配置</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets whether the component can be closed. Default is null. When not set, the DockView configuration is used</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public bool? ShowClose { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 组件唯一标识值 默认 null 未设置时取 Title 作为唯一标识 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 组件唯一标识,默认为 null,未设置时使用 Title 作为唯一标识</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets the unique component identifier. Default is null. When not set, Title is used as the unique identifier</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public string? Key { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 是否锁定 默认 null 未设置时取 DockView 的配置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 组件是否锁定,默认为 null,未设置时使用 DockView 的配置</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets whether the component is locked. Default is null. When not set, the DockView configuration is used</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// <remarks>锁定后无法拖动</remarks> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public bool? IsLock { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 是否显示锁定按钮 默认 null 未设置时取 DockView 的配置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 是否显示锁定按钮,默认为 null,未设置时使用 DockView 的配置</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets whether the lock button is displayed. Default is null. When not set, the DockView configuration is used</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public bool? ShowLock { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 是否悬浮 默认 null 未设置时取 DockView 的配置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 是否悬浮,默认为 null,未设置时使用 DockView 的配置</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets whether the component is floating. Default is null. When not set, the DockView configuration is used</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public bool? IsFloating { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 是否显示可悬浮按钮 默认 null 未设置时取 DockView 的配置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 是否显示悬浮按钮,默认为 null,未设置时使用 DockView 的配置</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets whether the float button is displayed. Default is null. When not set, the DockView configuration is used</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public bool? ShowFloat { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 是否显示最大化按钮 默认 null 未设置时取 DockView 的配置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 是否显示最大化按钮,默认为 null,未设置时使用 DockView 的配置</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets whether the maximize button is displayed. Default is null. When not set, the DockView configuration is used</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| public bool? ShowMaximize { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 是否一直显示 默认 null 未设置时取 DockView 的配置 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 组件渲染模式,默认为 null,未设置时使用 DockView 的配置</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets the component render mode. Default is null. When not set, the DockView configuration is used</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||||||||||||||||||||||||||||||||||||||||||
| public string? Renderer { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 是否显示标题前置图标 默认 false 不显示 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 是否显示标题前置图标,默认为 false</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets whether the leading title icon is displayed. Default is false</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| [JsonIgnore] | ||||||||||||||||||||||||||||||||||||||||||
| public bool ShowTitleBar { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 标题前置图标 默认 null 未设置使用默认图标 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 标题前置图标,默认为 null,未设置时使用默认图标</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets the leading title icon. Default is null. When not set, the default icon is used</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| [JsonIgnore] | ||||||||||||||||||||||||||||||||||||||||||
| public string? TitleBarIcon { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 标题前置图标 Url 默认 null 未设置使用默认图标 | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 标题前置图标地址,默认为 null,未设置时使用默认图标</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets the leading title icon URL. Default is null. When not set, the default icon is used</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| [JsonIgnore] | ||||||||||||||||||||||||||||||||||||||||||
| public string? TitleBarIconUrl { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// 获得/设置 标题前置图标点击回调方法 默认 null | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="zh">获得/设置 标题前置图标点击回调方法,默认为 null</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// <para lang="en">Gets or sets the click callback for the leading title icon. Default is null</para> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| [Parameter] | ||||||||||||||||||||||||||||||||||||||||||
| [JsonIgnore] | ||||||||||||||||||||||||||||||||||||||||||
| public Func<Task>? OnClickTitleBarCallback { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| [CascadingParameter] | ||||||||||||||||||||||||||||||||||||||||||
| [NotNull] | ||||||||||||||||||||||||||||||||||||||||||
| private DockViewV2? DockView { get; set; } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// <inheritdoc/> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -141,6 +162,20 @@ protected override void OnInitialized() | |||||||||||||||||||||||||||||||||||||||||
| base.OnInitialized(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Type = DockViewContentType.Component; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // 增加组件状态用于序列化 | ||||||||||||||||||||||||||||||||||||||||||
| DockView?.AddComponentState(new DockViewComponentState(this) { Key = Key }); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||
| /// <inheritdoc/> | ||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||
| protected override void OnParametersSet() | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| base.OnParametersSet(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // 同步组件状态到缓存 | ||||||||||||||||||||||||||||||||||||||||||
| DockView.UpdateComponentState(Key, Visible, IsLock); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+175
to
179
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| private async Task OnClickBar() | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -151,12 +186,20 @@ private async Task OnClickBar() | |||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| private bool IsRender() => DockView.IsRender(Key); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+189
to
+190
|
||||||||||||||||||||||||||||||||||||||||||
| internal void SetVisible(bool visible) => Visible = visible; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| internal void SetLock(bool isLock) => IsLock = isLock; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+191
to
+194
|
||||||||||||||||||||||||||||||||||||||||||
| internal void SetVisible(bool visible) => Visible = visible; | |
| internal void SetLock(bool isLock) => IsLock = isLock; | |
| /// <summary> | |
| /// <para lang="zh">设置组件显示状态</para> | |
| /// <para lang="en">Sets the component visibility state</para> | |
| /// </summary> | |
| /// <param name="visible"></param> | |
| public void SetVisible(bool visible) => SetVisibleCore(visible); | |
| /// <summary> | |
| /// <para lang="zh">设置组件锁定状态</para> | |
| /// <para lang="en">Sets the component lock state</para> | |
| /// </summary> | |
| /// <param name="isLock"></param> | |
| public void SetLock(bool isLock) => SetLockCore(isLock); | |
| internal void SetVisibleCore(bool visible) => Visible = visible; | |
| internal void SetLockCore(bool isLock) => IsLock = isLock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TitleTemplateis aRenderFragmentbut it’s no longer marked with[JsonIgnore]. SinceDockViewComponentinstances are serialized intoDockViewConfig.Contentsfor JS interop, this can causeSystem.Text.Jsonserialization to fail at runtime. Add[JsonIgnore]back forTitleTemplate(and any other non-serializable component parameters).