Skip to content
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

[Calendar] Add ReadOnly in day click/keydown logic #2720

Merged
merged 6 commits into from
Sep 26, 2024
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
5 changes: 2 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Test dependencies -->
<PackageVersion Include="bunit" Version="1.31.3" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
Expand All @@ -27,7 +27,6 @@
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20" />
<PackageVersion Include="Microsoft.VisualStudioEng.MicroBuild.Core" Version="1.0.0" />

</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="$(RuntimeVersion8)" />
Expand Down Expand Up @@ -66,4 +65,4 @@
<PackageVersion Include="System.Text.Encodings.Web" Version="$(RuntimeVersion9)" />
<PackageVersion Include="System.Text.Json" Version="$(RuntimeVersion9)" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,12 @@
<param name="column">The column to check against the current sorted on column.</param>
<returns>A <see cref="T:System.Threading.Tasks.Task"/> representing the completion of the operation.</returns>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.RemoveSortByColumnAsync">
<summary>
Removes the grid's sort on double click for the currently sorted column if it's not a default sort column.
</summary>
<returns>A <see cref="T:System.Threading.Tasks.Task"/> representing the completion of the operation.</returns>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ShowColumnOptionsAsync(Microsoft.FluentUI.AspNetCore.Components.ColumnBase{`0})">
<summary>
Displays the <see cref="P:Microsoft.FluentUI.AspNetCore.Components.ColumnBase`1.ColumnOptions"/> UI for the specified column, closing any other column
Expand All @@ -2042,6 +2048,22 @@
<param name="column">The column whose options are to be displayed, if any are available.</param>
<returns>A <see cref="T:System.Threading.Tasks.Task"/> representing the completion of the operation.</returns>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ShowColumnOptionsAsync(System.String)">
<summary>
Displays the <see cref="P:Microsoft.FluentUI.AspNetCore.Components.ColumnBase`1.ColumnOptions"/> UI for the specified column <paramref name="title"/> found first,
closing any other column options UI that was previously displayed. If the title is not found, nothing happens.
</summary>
<param name="title">The column title whose options UI is to be displayed.</param>
<returns>A <see cref="T:System.Threading.Tasks.Task"/> representing the completion of the operation.</returns>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ShowColumnOptionsAsync(System.Int32)">
<summary>
Displays the <see cref="P:Microsoft.FluentUI.AspNetCore.Components.ColumnBase`1.ColumnOptions"/> UI for the specified column <paramref name="index"/>,
closing any other column options UI that was previously displayed. If the index is out of range, nothing happens.
</summary>
<param name="index">The column index whose options UI is to be displayed.</param>
<returns>A <see cref="T:System.Threading.Tasks.Task"/> representing the completion of the operation.</returns>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ShowColumnResizeAsync(Microsoft.FluentUI.AspNetCore.Components.ColumnBase{`0})">
<summary>
Displays the column resize UI for the specified column, closing any other column
Expand All @@ -2050,6 +2072,22 @@
<param name="column">The column whose resize UI is to be displayed.</param>
<returns>A <see cref="T:System.Threading.Tasks.Task"/> representing the completion of the operation.</returns>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ShowColumnResizeAsync(System.String)">
<summary>
Displays the column resize UI for the specified column, closing any other column
resize UI that was previously displayed.
</summary>
<param name="title">The column title whose resize UI is to be displayed.</param>
<returns>A <see cref="T:System.Threading.Tasks.Task"/> representing the completion of the operation.</returns>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ShowColumnResizeAsync(System.Int32)">
<summary>
Displays the column resize UI for the specified column, closing any other column
resize UI that was previously displayed.
</summary>
<param name="index">The column index whose resize UI is to be displayed.</param>
<returns>A <see cref="T:System.Threading.Tasks.Task"/> representing the completion of the operation.</returns>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.RefreshDataAsync">
<summary>
Instructs the grid to re-fetch and render the current data from the supplied data source
Expand Down
8 changes: 4 additions & 4 deletions src/Core/Components/DateTime/FluentCalendar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
multi-end="@(multipleSelection.IsMultiple && SelectMode == CalendarSelectMode.Range && multipleSelection.Max == day)"
aria-label="@dayProperties.Title"
value="@dayProperties.DayIdentifier"
@onkeydown="(e => KeyDown.SimulateClickAsync(e, OnSelectDayHandlerAsync, day, dayProperties.IsDisabled || dayProperties.IsInactive))"
@onclick="@(e => OnSelectDayHandlerAsync(day, dayProperties.IsDisabled || dayProperties.IsInactive))"
@onmouseover="@(e => OnSelectDayMouseOverAsync(day, dayProperties.IsDisabled || dayProperties.IsInactive))">
@onkeydown="(e => KeyDown.SimulateClickAsync(e, OnSelectDayHandlerAsync, day, dayProperties.IsDisabled || dayProperties.IsInactive || ReadOnly))"
@onclick="@(e => OnSelectDayHandlerAsync(day, dayProperties.IsDisabled || dayProperties.IsInactive || ReadOnly))"
@onmouseover="@(e => OnSelectDayMouseOverAsync(day, dayProperties.IsDisabled || dayProperties.IsInactive || ReadOnly))">
@if (DaysTemplate == null)
{
@dayProperties.DayNumber
Expand Down Expand Up @@ -166,7 +166,7 @@
DisabledDateFunc="@(e => DisabledDateFunc != null ? DisabledDateFunc(e) : false)" />
}


@if (_pickerView == CalendarViews.Years)
{
<FluentCalendar View="CalendarViews.Years"
Expand Down
10 changes: 5 additions & 5 deletions tests/Core/AppBar/FluentAppBarItemTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// Act
var cut = Render<FluentAppBarItem>(
@<FluentAppBar>
<FluentAppBarItem Href="/" IconRest="@SampleIcons.Info" Text="My item">
<FluentAppBarItem Href="/" IconRest="@(new SampleIcons.Samples.Info())" Text="My item">
<div>Child content</div>
</FluentAppBarItem>
</FluentAppBar>);
Expand All @@ -41,7 +41,7 @@
// Act
var cut = Render<FluentAppBarItem>(
@<FluentAppBar>
<FluentAppBarItem Href="/" Text="My item" IconRest="@SampleIcons.Info">
<FluentAppBarItem Href="/" Text="My item" IconRest="@(new SampleIcons.Samples.Info())">
</FluentAppBarItem>
</FluentAppBar>);

Expand All @@ -57,7 +57,7 @@
// Act
var cut = Render<FluentAppBarItem>(
@<FluentAppBar>
<FluentAppBarItem Href="/" IconRest="@SampleIcons.Info">
<FluentAppBarItem Href="/" IconRest="@(new SampleIcons.Samples.Info())">
</FluentAppBarItem>
</FluentAppBar>);

Expand All @@ -73,7 +73,7 @@
// Act
var cut = Render<FluentAppBarItem>(
@<FluentAppBar>
<FluentAppBarItem Href="/" Text="My item" IconRest="@SampleIcons.Info" IconActive="@SampleIcons.Warning">
<FluentAppBarItem Href="/" Text="My item" IconRest="@(new SampleIcons.Samples.Info())" IconActive="@(new SampleIcons.Samples.Warning())">
</FluentAppBarItem>
</FluentAppBar>);

Expand All @@ -89,7 +89,7 @@
// Act
var cut = Render<FluentAppBarItem>(
@<FluentAppBar>
<FluentAppBarItem Href="/" Text="My item" IconRest="@SampleIcons.Info" IconActive="@SampleIcons.Warning" Tooltip="My item tooltip">
<FluentAppBarItem Href="/" Text="My item" IconRest="@(new SampleIcons.Samples.Info())" IconActive="@(new SampleIcons.Samples.Warning())" Tooltip="My item tooltip">
</FluentAppBarItem>
</FluentAppBar>);

Expand Down
8 changes: 4 additions & 4 deletions tests/Core/AppBar/FluentAppBarTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
// Act
var cut = Render<FluentAppBar>(
@<FluentAppBar Id="appbar">
<FluentAppBarItem Href="/" Id="id1" Text="My item" IconRest="@SampleIcons.Info" IconActive="@SampleIcons.Warning" Tooltip="My item tooltip">
<FluentAppBarItem Href="/" Id="id1" Text="My item" IconRest="@(new SampleIcons.Samples.Info())" IconActive="@(new SampleIcons.Samples.Warning())" Tooltip="My item tooltip">
</FluentAppBarItem>
<FluentAppBarItem Href="/" Id="id2" Text="My item 2" IconRest="@SampleIcons.Info" IconActive="@SampleIcons.Warning" Tooltip="My item 2 tooltip">
<FluentAppBarItem Href="/" Id="id2" Text="My item 2" IconRest="@(new SampleIcons.Samples.Info())" IconActive="@(new SampleIcons.Samples.Warning())" Tooltip="My item 2 tooltip">
</FluentAppBarItem>
</FluentAppBar>
);
Expand All @@ -59,9 +59,9 @@
// Act
var cut = Render<FluentAppBar>(
@<FluentAppBar Id="appbar" PopoverShowSearch="false">
<FluentAppBarItem Href="/" Id="id1" Text="My item" IconRest="@SampleIcons.Info" IconActive="@SampleIcons.Warning" Tooltip="My item tooltip">
<FluentAppBarItem Href="/" Id="id1" Text="My item" IconRest="@(new SampleIcons.Samples.Info())" IconActive="@(new SampleIcons.Samples.Warning())" Tooltip="My item tooltip">
</FluentAppBarItem>
<FluentAppBarItem Href="/" Id="id2" Text="My item 2" IconRest="@SampleIcons.Info" IconActive="@SampleIcons.Warning" Tooltip="My item 2 tooltip">
<FluentAppBarItem Href="/" Id="id2" Text="My item 2" IconRest="@(new SampleIcons.Samples.Info())" IconActive="@(new SampleIcons.Samples.Warning())" Tooltip="My item 2 tooltip">
</FluentAppBarItem>
</FluentAppBar>
);
Expand Down
9 changes: 6 additions & 3 deletions tests/Core/Button/FluentButtonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,10 @@ public void FluentButton_AdditionalAttributes()
public void FluentButton_IconStart()
{
// Arrange && Act
var icon = new SampleIcons.Samples.Info();
var cut = RenderComponent<FluentButton>(parameters =>
{
parameters.Add(p => p.IconStart, SampleIcons.Info);
parameters.Add(p => p.IconStart, icon);
parameters.AddChildContent("My button");
});

Expand All @@ -375,9 +376,10 @@ public void FluentButton_IconStart()
public void FluentButton_IconEnd()
{
// Arrange && Act
var icon = new SampleIcons.Samples.Info();
var cut = RenderComponent<FluentButton>(parameters =>
{
parameters.Add(p => p.IconEnd, SampleIcons.Info);
parameters.Add(p => p.IconEnd, icon);
parameters.AddChildContent("My button");
});

Expand All @@ -389,9 +391,10 @@ public void FluentButton_IconEnd()
public void FluentButton_IconNoContent()
{
// Arrange && Act
var icon = new SampleIcons.Samples.Info();
var cut = RenderComponent<FluentButton>(parameters =>
{
parameters.Add(p => p.IconEnd, SampleIcons.Info);
parameters.Add(p => p.IconEnd, icon);
});

// Assert
Expand Down
6 changes: 4 additions & 2 deletions tests/Core/NavMenu/FluentNavGroupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ public void FluentNavGroup_Icon()
{
// Arrange & Act
var m = new FluentNavMenu();
var icon = new SampleIcons.Samples.Info();
var cut = TestContext.RenderComponent<FluentNavGroup>(parameters =>
{
parameters.Add(p => p.Owner, m);
parameters.Add(p => p.Title, "Group title");
parameters.Add(p => p.Icon, SampleIcons.Info);
parameters.Add(p => p.Icon, icon);
parameters.AddChildContent("NavGroups and NavLinks here");
});

Expand All @@ -152,11 +153,12 @@ public void FluentNavGroup_IconAndIconColor()
{
// Arrange & Act
var m = new FluentNavMenu();
var icon = new SampleIcons.Samples.Info();
var cut = TestContext.RenderComponent<FluentNavGroup>(parameters =>
{
parameters.Add(p => p.Owner, m);
parameters.Add(p => p.Title, "Group title");
parameters.Add(p => p.Icon, SampleIcons.Info);
parameters.Add(p => p.Icon, icon);
parameters.Add(p => p.IconColor, Color.Neutral);
parameters.AddChildContent("NavGroups and NavLinks here");
});
Expand Down
9 changes: 6 additions & 3 deletions tests/Core/NavMenu/FluentNavLinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ public void FluentNavLink_ForceLoad()
public void FluentNavLink_Icon()
{
// Arrange & Act
var icon = new SampleIcons.Samples.Info();
var cut = TestContext.RenderComponent<FluentNavLink>(parameters =>
{
parameters.Add(p => p.Icon, SampleIcons.Info);
parameters.Add(p => p.Icon, icon);
parameters.AddChildContent("NavLink text");
});

Expand All @@ -125,10 +126,11 @@ public void FluentNavLink_IconAndIconColor()
{
// Arrange & Act
var m = new FluentNavMenu();
var icon = new SampleIcons.Samples.Info();
var cut = TestContext.RenderComponent<FluentNavLink>(parameters =>
{
parameters.Add(p => p.Owner, m);
parameters.Add(p => p.Icon, SampleIcons.Info);
parameters.Add(p => p.Icon, icon);
parameters.Add(p => p.IconColor, Color.Neutral);
parameters.AddChildContent("NavLink text");
});
Expand All @@ -142,10 +144,11 @@ public void FluentNavLink_IconWithCustomColor()
{
// Arrange & Act
var m = new FluentNavMenu();
var icon = new SampleIcons.Samples.Info();
var cut = TestContext.RenderComponent<FluentNavLink>(parameters =>
{
parameters.Add(p => p.Owner, m);
parameters.Add(p => p.Icon, SampleIcons.Info);
parameters.Add(p => p.Icon, icon);
parameters.Add(p => p.IconColor, Color.Custom);
parameters.Add(p => p.CustomColor, "red");
parameters.AddChildContent("NavLink text");
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/TreeView/FluentTreeViewItemsTests.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public partial class FluentTreeViewItemsTests
]),
};

private readonly Icon IconCollapsed = SampleIcons.Info;
private readonly Icon IconExpanded = SampleIcons.Warning;
private readonly Icon IconCollapsed = new SampleIcons.Samples.Info();
private readonly Icon IconExpanded = new SampleIcons.Samples.Warning();
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@

<div class="fluent-menubutton-container" b-nrgns4mio7="">
<fluent-button type="button" id="xxx" appearance="accent" blazor:onclick="1" aria-haspopup="true" blazor:onkeydown="2" b-x1200685t0="" blazor:elementreference="xxx">
<svg slot="start" style="width: 24px; fill: var(--neutral-layer-1);" focusable="false" viewBox="0 0 24 24" aria-hidden="true" blazor:onkeydown="3" blazor:onclick="4">
<path d="M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm0 8.25a1 1 0 0 0-1 .88v5.74a1 1 0 0 0 2 0v-5.62l-.01-.12a1 1 0 0 0-1-.88Zm0-3.75A1.25 1.25 0 1 0 12 9a1.25 1.25 0 0 0 0-2.5Z"></path>
</svg>
<svg slot="end" style="width: 12px; fill: var(--neutral-fill-rest);" focusable="false" viewBox="0 0 12 12" aria-hidden="true" blazor:onkeydown="5" blazor:onclick="6">
<path d="M2.15 4.65c.2-.2.5-.2.7 0L6 7.79l3.15-3.14a.5.5 0 1 1 .7.7l-3.5 3.5a.5.5 0 0 1-.7 0l-3.5-3.5a.5.5 0 0 1 0-.7Z"></path>
</svg>
</fluent-button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

<div class="fluent-menubutton-container" b-nrgns4mio7="">
<fluent-button type="button" id="xxx" appearance="accent" blazor:onclick="1" aria-haspopup="true" blazor:onkeydown="2" b-x1200685t0="" blazor:elementreference="xxx">
<svg slot="start" style="width: 24px; fill: var(--neutral-layer-1);" focusable="false" viewBox="0 0 24 24" aria-hidden="true" blazor:onkeydown="3" blazor:onclick="4">
<path d="M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm0 8.25a1 1 0 0 0-1 .88v5.74a1 1 0 0 0 2 0v-5.62l-.01-.12a1 1 0 0 0-1-.88Zm0-3.75A1.25 1.25 0 1 0 12 9a1.25 1.25 0 0 0 0-2.5Z"></path>
</svg>
<svg slot="end" style="width: 12px; fill: var(--neutral-fill-rest);" focusable="false" viewBox="0 0 12 12" aria-hidden="true" blazor:onkeydown="5" blazor:onclick="6">
<path d="M2.15 4.65c.2-.2.5-.2.7 0L6 7.79l3.15-3.14a.5.5 0 1 1 .7.7l-3.5 3.5a.5.5 0 0 1-.7 0l-3.5-3.5a.5.5 0 0 1 0-.7Z"></path>
</svg>
</fluent-button>
</div>
30 changes: 29 additions & 1 deletion tests/Core/_ToDo/MenuButton/FluentMenuButtonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,35 @@ public void FluentMenuButton_Default()
.Add(p => p.MenuStyle, menuStyle)
.Add(p => p.Items, items)
.Add(p => p.OnMenuChanged, onMenuChanged)
.Add(p => p.IconStart, SampleIcons.Info)
);
//Act

//Assert
cut.Verify();
}

[Fact]
public void FluentMenuButton_IconStart()
{
//Arrange
FluentButton button = default!;
FluentMenu menu = default!;
string text = default!;
string buttonStyle = default!;
string menuStyle = default!;
Dictionary<string, string> items = default!;
var icon = new SampleIcons.Samples.Info();

Action<MenuChangeEventArgs> onMenuChanged = _ => { };
var cut = TestContext.RenderComponent<FluentMenuButton>(parameters => parameters
.Add(p => p.Button, button)
.Add(p => p.Menu, menu)
.Add(p => p.Text, text)
.Add(p => p.ButtonStyle, buttonStyle)
.Add(p => p.MenuStyle, menuStyle)
.Add(p => p.Items, items)
.Add(p => p.OnMenuChanged, onMenuChanged)
.Add(p => p.IconStart, icon)
);
//Act

Expand Down
Loading