Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
}
</p>

<Table TItem="AttributeItem" Items="Items" IsBordered="true" IsStriped="true" ShowFooter="@ShowFooter">
<Table TItem="AttributeItem" Items="_items" IsBordered="true" IsStriped="true" ShowFooter="@ShowFooter">
<TableColumns>
<TableColumn @bind-Field="@context.Name" />
<TableColumn @bind-Field="@context.Description" TextWrap="true" />
<TableColumn @bind-Field="@context.Type" />
<TableColumn @bind-Field="@context.Type" TextWrap="true" Width="180"></TableColumn>
<TableColumn @bind-Field="@context.Version" />
</TableColumns>
<TableFooter>
<TableFooterCell Text="合计:" colspan="3" Align="Alignment.Left" />
<TableFooterCell Text="@Localizer["Total"]" colspan="3" Align="Alignment.Left" />
<TableFooterCell Aggregate="AggregateType.Count" Field="@nameof(AttributeItem.Name)" />
</TableFooter>
</Table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ public sealed partial class AttributeTable
[NotNull]
public string? Title { get; set; }

/// <summary>
/// 获得/设置 表格数据
/// </summary>
[Parameter]
public IEnumerable<AttributeItem> Items { get; set; } = [];

/// <summary>
/// 获得/设置 表格关联组件类型
/// </summary>
Expand All @@ -39,18 +33,33 @@ public sealed partial class AttributeTable
[Parameter]
public bool ShowFooter { get; set; }

private List<AttributeItem> _items = [];

/// <summary>
/// <inheritdoc/>
/// </summary>
protected override void OnInitialized()
protected override void OnParametersSet()
{
base.OnInitialized();

Title ??= Localizer[nameof(Title)];
base.OnParametersSet();

if (Type != null)
{
Items = ComponentAttributeCacheService.GetAttributes(Type);
_items = ComponentAttributeCacheService.GetAttributes(Type);

Title ??= FormatTypeName(Type);
}
}

private static string FormatTypeName(Type type)
{
if (!type.IsGenericType)
{
return type.Name;
}

var index = type.Name.IndexOf('`');
var typeName = type.Name.Substring(0, index);
var genericArgs = string.Join(", ", type.GetGenericArguments().Select(i => i.Name));
return $"{typeName}<{genericArgs}>";
}
}
72 changes: 0 additions & 72 deletions src/BootstrapBlazor.Server/Components/Samples/Alerts.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,76 +116,4 @@ private static EventItem[] GetEvents() =>
Type = "EventCallback<MouseEventArgs>"
}
];

/// <summary>
/// 获得属性方法
/// </summary>
/// <returns></returns>
private static AttributeItem[] GetAttributes() =>
[
new()
{
Name = "ChildContent",
Description = "Content",
Type = "RenderFragment",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "Class",
Description = "Style",
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "Color",
Description = "Color",
Type = "Color",
ValueList = "Primary / Secondary / Success / Danger / Warning / Info / Dark",
DefaultValue = "Primary"
},
new()
{
Name = "Icon",
Description = "Icon",
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "ShowDismiss",
Description = "Close Button",
Type = "bool",
ValueList = " — ",
DefaultValue = "false"
},
new()
{
Name = "ShowBar",
Description = "Show the left Bar",
Type = "bool",
ValueList = "true|false",
DefaultValue = "false"
},
new()
{
Name = "ShowBorder",
Description = "Show border",
Type = "bool",
ValueList = "true|false",
DefaultValue = "false"
},
new()
{
Name = "ShowShadow",
Description = "Show Shadow",
Type = "bool",
ValueList = "true|false",
DefaultValue = "false"
}
];
}
36 changes: 0 additions & 36 deletions src/BootstrapBlazor.Server/Components/Samples/AnchorLinks.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,4 @@ public partial class AnchorLinks
[Inject]
[NotNull]
private IStringLocalizer<AnchorLinks>? Localizer { get; set; }

private AttributeItem[] GetAttributes() =>
[
new()
{
Name = nameof(AnchorLink.Id),
Description = Localizer[$"Attr{nameof(AnchorLink.Id)}"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = nameof(AnchorLink.Icon),
Description = Localizer[$"Attr{nameof(AnchorLink.Icon)}"],
Type = "string",
ValueList = " — ",
DefaultValue = "fa-solid fa-link"
},
new()
{
Name = nameof(AnchorLink.Text),
Description = Localizer[$"Attr{nameof(AnchorLink.Text)}"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = nameof(AnchorLink.TooltipText),
Description = Localizer[$"Attr{nameof(AnchorLink.TooltipText)}"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
}
];
}
48 changes: 0 additions & 48 deletions src/BootstrapBlazor.Server/Components/Samples/Anchors.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,4 @@ public partial class Anchors
[Inject]
[NotNull]
private IStringLocalizer<Anchors>? Localizer { get; set; }

/// <summary>
/// 获得属性方法
/// </summary>
/// <returns></returns>
private AttributeItem[] GetAttributes() =>
[
new()
{
Name = "Target",
Description = Localizer["DescTarget"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "Container",
Description = Localizer["DescContainer"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "IsAnimation",
Description = Localizer["DescIsAnimation"],
Type = "boolean",
ValueList = "true|false",
DefaultValue = "true"
},
new()
{
Name = "Offset",
Description = Localizer["DescOffset"],
Type = "int",
ValueList = " — ",
DefaultValue = "0"
},
new()
{
Name = "ChildContent",
Description = Localizer["DescChildContent"],
Type = "RenderFragment",
ValueList = " — ",
DefaultValue = " — "
}
];
}
128 changes: 0 additions & 128 deletions src/BootstrapBlazor.Server/Components/Samples/AutoCompletes.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,132 +48,4 @@ private Task GroupOnSelectedItemChanged(string val)
GroupLogger.Log($"Value: {val}");
return Task.CompletedTask;
}

/// <summary>
/// 获得属性方法
/// </summary>
/// <returns></returns>
private AttributeItem[] GetAttributes() =>
[
new()
{
Name = "ShowLabel",
Description = Localizer["Att1"],
Type = "bool",
ValueList = "true|false",
DefaultValue = "true"
},
new()
{
Name = "ChildContent",
Description = Localizer["Att2"],
Type = "RenderFragment",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "ItemTemplate",
Description = Localizer["AttItemTemplate"],
Type = "RenderFragment<string>",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "Items",
Description = Localizer["Att3"],
Type = "IEnumerable<string>",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "NoDataTip",
Description = Localizer["Att4"],
Type = "string",
ValueList = " — ",
DefaultValue = Localizer["Att4DefaultValue"]!
},
new()
{
Name = "DisplayCount",
Description = Localizer["Att5"],
Type = "int?",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "ValueChanged",
Description = Localizer["Att6"],
Type = "Action<string>",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "IsLikeMatch",
Description = Localizer["Att7"],
Type = "bool",
ValueList = "true|false",
DefaultValue = "false"
},
new()
{
Name = "IgnoreCase",
Description = Localizer["Att8"],
Type = "bool",
ValueList = "true|false",
DefaultValue = "true"
},
new()
{
Name = "OnCustomFilter",
Description = Localizer["Att9"],
Type = "Func<string, Task<IEnumerable<string>>>",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "Debounce",
Description = Localizer["Debounce"],
Type = "int",
ValueList = " — ",
DefaultValue = "0"
},
new()
{
Name = nameof(AutoComplete.SkipEnter),
Description = Localizer[nameof(AutoComplete.SkipEnter)],
Type = "bool",
ValueList = "true/false",
DefaultValue = "false"
},
new()
{
Name = nameof(AutoComplete.SkipEsc),
Description = Localizer[nameof(AutoComplete.SkipEsc)],
Type = "bool",
ValueList = "true/false",
DefaultValue = "false"
},
new()
{
Name = nameof(AutoComplete.OnValueChanged),
Description = Localizer[nameof(AutoComplete.OnValueChanged)],
Type = "Func<string, Task>",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = nameof(AutoComplete.OnSelectedItemChanged),
Description = Localizer[nameof(AutoComplete.OnSelectedItemChanged)],
Type = "Func<string, Task>",
ValueList = " — ",
DefaultValue = " — "
}
];
}
Loading