Skip to content

Commit

Permalink
For mudblazor 7.0.0 (#94)
Browse files Browse the repository at this point in the history
* Step 1 compilable

* Begin bugfix rename step 1

* Repair treeview for mud 7

* Fix all bugs.
Styles still broken

* Fix some broken styles

* Change theme selection a little bit to charm

* Add subline to index

* Fix styles for ObjectEdit Dialog and fix conditional updates for Conditions for Components in dialog

* Add internal extensions

* Smal.net 7 change

* Fix some style bugs
  • Loading branch information
fgilde authored Jul 8, 2024
1 parent d9630d2 commit fef363c
Show file tree
Hide file tree
Showing 128 changed files with 945 additions and 707 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net8</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
Expand All @@ -13,7 +13,7 @@
<Title>MudExObjectEdit.CodeGatorAdapter</Title>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageId>MudExObjectEdit.CodeGatorAdapter</PackageId>
<PackageVersion>1.0.12</PackageVersion>
<PackageVersion>2.0.0</PackageVersion>
<Authors>fgilde</Authors>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<RepositoryType>Git</RepositoryType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,20 @@ public void CombineIconsCentered_ShouldReturnCombinedSvgImages_CenteredOverlappe
public void SvgPropertyNameForValue_ShouldReturnFullyQualifiedNameOfConstant_WhenPassedValueAndSingleOwnerType()
{
// Act
var result = MudExSvg.SvgPropertyNameForValue(Icons.Outlined.Search, typeof(Icons));
var result = MudExSvg.SvgPropertyNameForValue(Icons.Material.Outlined.Search, typeof(Icons));

// Assert
Assert.Equal("MudBlazor.Icons.Outlined.Search", result);
Assert.Equal("MudBlazor.Icons.Material.Outlined.Search", result);
}

[Fact]
public void SvgPropertyNameForValue_ShouldReturnFullyQualifiedNameOfConstant_WhenPassedValueAndMultipleOwnerTypes()
{
// Act
var result = MudExSvg.SvgPropertyNameForValue(Icons.Outlined.Search, typeof(Icons), typeof(OtherIcons));
var result = MudExSvg.SvgPropertyNameForValue(Icons.Material.Outlined.Search, typeof(Icons), typeof(OtherIcons));

// Assert
Assert.Equal("MudBlazor.Icons.Outlined.Search", result);
Assert.Equal("MudBlazor.Icons.Material.Outlined.Search", result);
}

[Fact]
Expand All @@ -104,10 +104,10 @@ public void SvgPropertyNameForValue_ShouldReturnFullyQualifiedNameOfConstant_Whe
var allOwnerTypes = new[] { typeof(Icons), typeof(OtherIcons) };

// Act
var result = MudExSvg.SvgPropertyNameForValue(Icons.Outlined.Search, allOwnerTypes);
var result = MudExSvg.SvgPropertyNameForValue(Icons.Material.Outlined.Search, allOwnerTypes);

// Assert
Assert.Equal("MudBlazor.Icons.Outlined.Search", result);
Assert.Equal("MudBlazor.Icons.Material.Outlined.Search", result);
}

[Fact]
Expand All @@ -124,10 +124,10 @@ public void SvgPropertyNameForValue_ShouldReturnNull_WhenPassedNonExistentValue(
public void SvgPropertyValueForName_ShouldReturnValueOfConstant_WhenPassedFullyQualifiedNameOfConstant()
{
// Act
var result = MudExSvg.SvgPropertyValueForName("MudBlazor.Icons.Outlined.Search");
var result = MudExSvg.SvgPropertyValueForName("MudBlazor.Icons.Material.Outlined.Search");

// Assert
Assert.Equal(Icons.Outlined.Search, result);
Assert.Equal(Icons.Material.Outlined.Search, result);
}

[Fact]
Expand Down
8 changes: 4 additions & 4 deletions MudBlazor.Extensions/Components/MudExApiView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<MudSwitch Color="Color.Primary" @bind-Value="ShowInherited">Show inherited</MudSwitch>
<MudSpacer/>
<MudExToggleableSearch AutoCloseOnBlur="false"
OnKeyUp="@(() => { _methodPanel.Expand(); _propertyPanel.Expand(); })"
OnKeyUp="@(() => { _= _methodPanel.ExpandAsync(); _= _propertyPanel.ExpandAsync(); })"
@bind-Filter="_searchString"></MudExToggleableSearch>
</MudToolBar>
}
Expand All @@ -43,7 +43,7 @@
<p>Enum</p>

var names = Enum.GetNames(Type).Where(s => string.IsNullOrEmpty(_searchString) || s.Contains(_searchString, StringComparison.OrdinalIgnoreCase));
<MudExpansionPanel IsInitiallyExpanded="@IsInitiallyExpanded" Text="Enum Member">
<MudExpansionPanel Expanded="@Expanded" Text="Enum Member">
<MudTable Items="@names" Hover="true" Breakpoint="Breakpoint.Sm">
<RowTemplate>
<MudTd DataLabel="Member">@context</MudTd>
Expand All @@ -54,7 +54,7 @@

@if (ShowProperties)
{
<MudExpansionPanel @ref="_propertyPanel" Disabled="@Compact" IsExpandedChanged="@OnExpandedChanged" IsInitiallyExpanded="@(IsInitiallyExpanded)" Text="Properties">
<MudExpansionPanel @ref="_propertyPanel" Disabled="@Compact" ExpandedChanged="@OnExpandedChanged" Expanded="@(Expanded)" Text="Properties">
@if (_properties?.Any() == true)
{
<MudDataGrid T="ApiMemberInfo<PropertyInfo>" Items="@_properties.Where(p => (ShowInherited || !p.IsInherited) && (ShowOnly == null || ShowOnly.Contains(p.Name)))" SortMode="SortMode.Multiple" Filterable="true" QuickFilter="@_quickFilter"
Expand Down Expand Up @@ -129,7 +129,7 @@

@if (ShowMethods)
{
<MudExpansionPanel @ref="_methodPanel" Disabled="@Compact" IsExpandedChanged="@OnExpandedChanged" IsInitiallyExpanded="@IsInitiallyExpanded" Text="Methods">
<MudExpansionPanel @ref="_methodPanel" Disabled="@Compact" ExpandedChanged="@OnExpandedChanged" Expanded="@Expanded" Text="Methods">
@if (_methods?.Any() == true)
{
<MudDataGrid T="ApiMemberInfo<MethodInfo>" Items="@_methods.Where(p => ShowInherited || !p.IsInherited && (ShowOnly == null || ShowOnly.Contains(p.Name)))" SortMode="SortMode.Multiple" Filterable="true" QuickFilter="@_quickFilter"
Expand Down
4 changes: 2 additions & 2 deletions MudBlazor.Extensions/Components/MudExApiView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public partial class MudExApiView
/// Is the panel initially expanded
/// </summary>
[Parameter]
public bool IsInitiallyExpanded { get; set; } = true;
public bool Expanded { get; set; } = true;

/// <summary>
/// Search string
Expand All @@ -100,7 +100,7 @@ private List<BreadcrumbItem> GetInheritancePath(Type type)
/// <inheritdoc />
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && IsInitiallyExpanded)
if (firstRender && Expanded)
{
await LoadInfos();
}
Expand Down
2 changes: 1 addition & 1 deletion MudBlazor.Extensions/Components/MudExCodeView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
if (CodeViewModeWithRenderFragment == CodeViewModeWithRenderFragment.ExpansionPanel)
{
<MudExpansionPanel IsExpandedChanged="OnExpandedChanged" IsInitiallyExpanded="@CodeIsExpanded" Text="@(_isExpanded ? ExpandedText : CollapsedText)">
<MudExpansionPanel ExpandedChanged="OnExpandedChanged" Expanded="@CodeIsExpanded" Text="@(_isExpanded ? ExpandedText : CollapsedText)">
@CodeView()
</MudExpansionPanel>
}
Expand Down
4 changes: 2 additions & 2 deletions MudBlazor.Extensions/Components/MudExColorEdit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</MudTabPanel>
}
<MudTabPanel OnClick="@CustomTabClick" Text="@TryLocalize(@LabelCustomTab)">
<MudExColorPicker InitialColor="@_initialMudColorValue" ColorPickerMode="ColorPickerMode.HEX" DisableToolbar="@DisableToolbar" ValueChanged="@(Select)" PickerVariant="PickerVariant.Static" />
<MudExColorPicker InitialColor="@_initialMudColorValue" ColorPickerMode="ColorPickerMode.HEX" ShowToolbar="@ShowToolbar" ValueChanged="@(Select)" PickerVariant="PickerVariant.Static" />
</MudTabPanel>
</MudTabs>;
}
Expand Down Expand Up @@ -66,7 +66,7 @@
@<div>
<MudTextField Class="mt-5 mr-5 ml-5 mb-2" Clearable="true" Variant="@FilterVariant" Immediate="true" Placeholder="@TryLocalize("Filter")" @bind-Value="@Filter" T="string"></MudTextField>
<MudPaper Elevation="0">
<MudList Dense="true" Class="m-0" Clickable="true">
<MudList T="ColorItem" Dense="true" Class="m-0">
@foreach (var group in _colors.Where(c => Matches(c.Name)).GroupBy(c => c.Group))
{
@DividerContent(group.Key)
Expand Down
16 changes: 9 additions & 7 deletions MudBlazor.Extensions/Components/MudExColorEdit.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,25 @@ protected override void OnAfterRender(bool firstRender)
base.OnAfterRender(firstRender);
}


/// <inheritdoc />
protected override void OnPickerClosed()
protected override Task OnPickerClosedAsync()
{
if (DelayValueChangeToPickerClose)
RaiseChanged();
return base.OnPickerClosedAsync();
}

/// <inheritdoc />
protected override void OnPickerOpened()
protected override Task OnPickerOpenedAsync()
{
_ = UpdateInitialMudColor();
_ = EnsureCssVarsAsync();
base.OnPickerOpened();
return base.OnPickerOpenedAsync();
}

/// <inheritdoc />
protected override async Task StringValueChanged(string value)
protected override async Task StringValueChangedAsync(string value)
{
SetSuggestedFormat();
if (!rendered)
Expand Down Expand Up @@ -312,7 +314,7 @@ private string OnSet(MudExColor color)

private void RaiseChangedIf()
{
if (DelayValueChangeToPickerClose && IsOpen)
if (DelayValueChangeToPickerClose && Open)
return;
RaiseChanged();
}
Expand All @@ -332,7 +334,7 @@ private void UpdatePreview()
private void CloseIf(AutoCloseBehaviour behaviour)
{
if (AutoCloseBehaviour == behaviour || AutoCloseBehaviour == AutoCloseBehaviour.Always)
Close();
CloseAsync();
}

private void Select(string color)
Expand Down Expand Up @@ -423,7 +425,7 @@ private async Task UpdateInitialMudColor()

private static bool IsCssVarStr(string s) => s.StartsWith("var(") || s.StartsWith("--");

private bool GetIsOpen() => IsOpen || PickerVariant == PickerVariant.Static;
private bool GetIsOpen() => Open || PickerVariant == PickerVariant.Static;

private string ColorItemStyle(ColorItem context)
{
Expand Down
10 changes: 5 additions & 5 deletions MudBlazor.Extensions/Components/MudExColorPicker.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ protected override void OnInitialized()
}

/// <inheritdoc />
protected override void OnPickerOpened()
protected override async Task OnPickerOpenedAsync()
{

base.OnPickerOpened();
await base.OnPickerOpenedAsync();
if (!ShouldDelay) return;

_originalValueChanged = ValueChanged;
Expand All @@ -83,11 +83,11 @@ protected override void OnPickerOpened()
}

/// <inheritdoc />
protected override void OnPickerClosed()
protected override Task OnPickerClosedAsync()
{
if (ShouldDelay)
_originalValueChanged.InvokeAsync(Value);
base.OnPickerClosed();
return base.OnPickerClosedAsync();
}

private Task NativeColorChange(ChangeEventArgs arg)
Expand All @@ -108,7 +108,7 @@ private void SetInitialColorOneTime()
typeof(MudColorPicker).GetMethod("UpdateColorSelectorBasedOnRgb", BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(this, new object[] { });
typeof(MudColorPicker).GetMethod("UpdateBaseColorSlider", BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(this, new object[] { InitialColor.H });
typeof(MudColorPicker).GetMethod("SelectPaletteColor", BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(this, new object[] { InitialColor });
SetTextAsync(InitialColor.ToString(!DisableAlpha ? MudColorOutputFormats.HexA : MudColorOutputFormats.Hex), false).AndForget();
_ = SetTextAsync(InitialColor.ToString(ShowAlpha ? MudColorOutputFormats.HexA : MudColorOutputFormats.Hex), false);
FieldChanged(InitialColor);
StateHasChanged();
_value = c;
Expand Down
11 changes: 6 additions & 5 deletions MudBlazor.Extensions/Components/MudExDialog.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ public override async Task SetParametersAsync(ParameterView parameters)
{
if (parameters.TryGetValue<DialogOptions>(nameof(Options), out var options) && options is DialogOptionsEx ex)
_options = ex;
bool oldVisible = IsVisible;
bool oldVisible = Visible;
await base.SetParametersAsync(parameters);
if (oldVisible != IsVisible)
if (oldVisible != Visible)
{
if (IsVisible)
if (Visible)
await Show();
else
Close();
await CloseAsync();
}
}

Expand All @@ -110,7 +110,8 @@ void OnAdded(IDialogReference reference)
OptionsEx.JsRuntime = Js;
OptionsEx.AppearanceService = AppearanceService;
await DialogServiceExt.PrepareOptionsBeforeShow(OptionsEx);
return await base.Show(title, options).InjectOptionsAsync(DialogService, OptionsEx);
Task<IDialogReference> x = ShowAsync(title, options);
return await x.InjectOptionsAsync(DialogService, OptionsEx);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions MudBlazor.Extensions/Components/MudExFileDisplay.razor
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
Size="Size.Small"
Href="@PossiblePlugin.Url"
Target="_blank"
StartIcon="@(Icons.TwoTone.Shop)">
StartIcon="@(Icons.Material.Filled.Shop)">
@(TryLocalize("The Plugin '{0}' may be able to help", PossiblePlugin.Name))
</MudButton>
}
Expand All @@ -104,7 +104,7 @@
@if (!string.IsNullOrEmpty(FileName))
{
<MudSpacer />
<MudMenu Style="margin-bottom:2px;" AnchorOrigin="Origin.TopRight" TransformOrigin="Origin.TopRight" Dense="@Dense" Size="Size.Medium" Icon="@MudExSvg.CombineIconsHorizontal(Icons.Material.Filled.MoreVert, BrowserFileExt.IconForFile(ContentType))">
<MudMenu AnchorOrigin="Origin.TopRight" TransformOrigin="Origin.TopRight" Dense="@Dense" Size="Size.Medium" Icon="@MudExSvg.CombineIconsHorizontal(Icons.Material.Filled.MoreVert, BrowserFileExt.IconForFile(ContentType))">
<div class="mud-ex-file-display-menu-header">
<MudExIcon Color="@(ColorizeIcons ? BrowserFileExt.GetPreferredColor(ContentType) : IconColor)" Icon="@BrowserFileExt.IconForFile(ContentType)"></MudExIcon>
<MudText Class="mud-ex-file-display-toolbar-text">@FileName</MudText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@inherits MudExFileDisplay

@namespace MudBlazor.Extensions.Components
<MudDialog Style="@Style" Class="@(MudExCss.Get(MudExCss.Classes.Dialog.FullHeightContent, "overflow-hidden", MudExCss.Classes.Dialog._Initial))" ClassContent="@ClassContent">
<MudDialog Style="@Style" Class="@(MudExCss.Get(MudExCss.Classes.Dialog.FullHeightContent, "overflow-hidden", MudExCss.Classes.Dialog._Initial))" ContentClass="@ContentClass">
<TitleContent>
<MudText Typo="Typo.h6">
<MudExIcon Color="@DialogIconColor" Icon="@Icon" Class="mr-3 mb-n1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial class MudExFileDisplayDialog
/// </summary>
[Parameter]
[SafeCategory("Appearance")]
public string ClassContent { get; set; } = "full-height";
public string ContentClass { get; set; } = "full-height";

/// <summary>
/// Icon to display in the dialog.
Expand Down
Loading

0 comments on commit fef363c

Please sign in to comment.