Skip to content

Commit

Permalink
Merge branch 'master' into HxDropdownToggleButton-Add-AutoClose-Param…
Browse files Browse the repository at this point in the history
…eter-to-control-the-closing-behavior-#600
  • Loading branch information
TPIvan authored Oct 20, 2023
2 parents ecedbba + 9416a03 commit f94476a
Show file tree
Hide file tree
Showing 139 changed files with 6,402 additions and 5,629 deletions.
8 changes: 7 additions & 1 deletion BlazorAppTest/BlazorAppTest.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -21,4 +21,10 @@
<ProjectReference Include="..\Havit.SourceGenerators.StrongApiStringLocalizers\Havit.SourceGenerators.StrongApiStringLocalizers.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Havit.Blazor.Components.Web.Bootstrap.Documentation\DemoData\**\*.*">
<Link>DemoData\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
</ItemGroup>

</Project>
46 changes: 46 additions & 0 deletions BlazorAppTest/Pages/HxAutosuggest_Issue584_Test.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@page "/HxAutosuggest_Issue584_Test"
@using Havit.Blazor.Components.Web.Bootstrap.Documentation.DemoData;
@inject IDemoDataService DemoDataService

<EditForm Model="exampleModel" OnValidSubmit="HandleValidSubmit">
<HxAutosuggest Label="Employee"
Placeholder="Start typing to search by name"
TItem="EmployeeDto"
TValue="int?"
@bind-Value="@exampleModel.SelectedEmployeeId"
DataProvider="ProvideSuggestions"
MinimumLength="0"
ValueSelector="employee => employee.Id"
TextSelector="employee => employee.Name"
ItemFromValueResolver="ResolveAutosuggestItemFromValue">
<EmptyTemplate>
<span class="p-2">Couldn't find any matching employee</span>
</EmptyTemplate>
</HxAutosuggest>
<p class="mt-3">submitExecuted = @submitExecuted</p>
</EditForm>

@code {
private ExampleModel exampleModel = new();
private bool submitExecuted;
private void HandleValidSubmit()
{
submitExecuted = true;
}

private async Task<AutosuggestDataProviderResult<EmployeeDto>> ProvideSuggestions(AutosuggestDataProviderRequest request)
{
var matchingEmployees = await DemoDataService.FindEmployeesByNameAsync(request.UserInput, limitCount: 10, request.CancellationToken);
return new AutosuggestDataProviderResult<EmployeeDto> { Data = matchingEmployees };
}

private async Task<EmployeeDto> ResolveAutosuggestItemFromValue(int? value)
{
if (value is null)
{
return null;
}
return await DemoDataService.GetEmployeeByIdAsync(value.Value);
}
private record ExampleModel { public int? SelectedEmployeeId { get; set; } };
}
2 changes: 1 addition & 1 deletion BlazorAppTest/Pages/HxGrid_InfiniteScroll_Test.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<h1>HxGrid with infinite scroll</h1>

<HxGrid TItem="CultureInfo" DataProvider="@ClientCultureInfosDataProvider" ContentNavigationMode="GridContentNavigationMode.InfiniteScroll" TableContainerCssClass="mt-5" ItemRowHeight="50" HeaderRowCssClass="myheader">
<HxGrid TItem="CultureInfo" PlaceholdersRowCount="100" DataProvider="@ClientCultureInfosDataProvider" ContentNavigationMode="GridContentNavigationMode.InfiniteScroll" TableContainerCssClass="mt-5" ItemRowHeight="50" HeaderRowCssClass="myheader">
<Columns>
<HxGridColumn TItem="CultureInfo" HeaderText="Display Name" ItemTextSelector="@(item => item.DisplayName)" SortKeySelector="@(item => item.DisplayName)" IsDefaultSortColumn="true">
<PlaceholderTemplate>
Expand Down
113 changes: 113 additions & 0 deletions BlazorAppTest/Pages/HxGrid_Issue615_Test.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
@page "/HxGrid_Issue615_Test"
@using System.Globalization
@using Havit.Collections;

<h1>HxGrid</h1>


<div class="container">
<h3>Invoices</h3>
<HxGrid ContentNavigationMode="GridContentNavigationMode.Pagination"
DataProvider="OnLoadItems"
Hover="true"
PageSize="10"
PlaceholdersRowCount="10"
Responsive="true"
SelectedDataItemChanged="OnInvoiceSelected"
SelectionEnabled="true"
Striped="true"
TItem="Invoice">
<Columns>
<HxGridColumn HeaderText="Number"
IsDefaultSortColumn="true"
ItemTextSelector="@(i => i.Number.ToString(CultureInfo.CurrentUICulture))"
SortDirection="SortDirection.Ascending"
SortKeySelector="@(i => i.Number)"
TItem="Invoice" />
<HxGridColumn HeaderText="Client"
IsDefaultSortColumn="false"
ItemTextSelector="@(i => i.ClientName)"
SortKeySelector="@(i => i.ClientName)"
TItem="Invoice" />
<HxGridColumn FooterCssClass="text-end"
FooterText="@(GetGrandTotal().ToString("C", CultureInfo.CurrentUICulture))"
HeaderCssClass="text-end"
HeaderText="Total"
IsDefaultSortColumn="false"
ItemCssClass="text-end"
ItemTextSelector="@(i => i.Total.ToString("C", CultureInfo.CurrentUICulture))"
SortKeySelector="@(i => i.Total)"
TItem="Invoice" />
</Columns>
</HxGrid>
</div>

@code {
private readonly IEnumerable<Invoice> _invoices = new List<Invoice>()
{
new Invoice(1, "Client #1", 10.00m),
new Invoice(2, "Client #2", 20.00m),
new Invoice(3, "Client #3", 30.00m),
new Invoice(4, "Client #4", 40.00m),
new Invoice(5, "Client #5", 50.00m),
new Invoice(6, "Client #6", 60.00m),
new Invoice(7, "Client #7", 70.00m),
new Invoice(8, "Client #8", 80.00m),
new Invoice(9, "Client #9", 90.00m),
new Invoice(10, "Client #10", 100.00m),
new Invoice(11, "Client #11", 110.00m),
new Invoice(12, "Client #12", 120.00m),
new Invoice(13, "Client #13", 130.00m),
new Invoice(14, "Client #14", 140.00m),
new Invoice(15, "Client #15", 150.00m),
new Invoice(16, "Client #16", 160.00m),
new Invoice(17, "Client #17", 170.00m),
new Invoice(18, "Client #18", 180.00m),
new Invoice(19, "Client #19", 190.00m),
new Invoice(20, "Client #20", 200.00m)
}.AsEnumerable();

[Inject] private IHxMessageBoxService MessageBox { get; set; }

public Task<GridDataProviderResult<Invoice>> OnLoadItems(GridDataProviderRequest<Invoice> request)
{
return Task.FromResult(request.ApplyTo(_invoices));
}

public async Task OnInvoiceSelected(Invoice selectedInvoice)
{
if (selectedInvoice == null || MessageBox == null)
return;

await MessageBox.ShowAsync(
"Information",
$"Invoice #{selectedInvoice.Number} clicked!");
}

public decimal GetGrandTotal()
{
return _invoices.Sum(i => i.Total);
}

public class Invoice
{
public Invoice(
int number,
string clientName,
decimal total)
{
if (string.IsNullOrWhiteSpace(clientName))
throw new ArgumentNullException(nameof(clientName));

Number = number;
ClientName = clientName;
Total = total;
}

public int Number { get; private set; }

public string ClientName { get; private set; }

public decimal Total { get; private set; }
}
}
1 change: 1 addition & 0 deletions BlazorAppTest/Pages/HxInputDateTest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<HxInputDate Label="HxInputDate (default, DateTime?)" @bind-Value="@model.NullableDateTime" Placeholder="Datum narození" />
<HxInputDate Label="HxInputDate (default, DateTimeOffset)" @bind-Value="@model.DateTimeOffset" />
<HxInputDate Label="HxInputDate (default, DateTimeOffset?)" @bind-Value="@model.NullableDateTimeOffset" />
<HxInputDate Label="HxInputDate (DisplayName)" @bind-Value="@model.DateTime" />
<HxInputDate Label="HxInputDate (wo/ PredefinedDates, wo/ validation)" @bind-Value="@model.DateTime" ShowPredefinedDates="false" ValidationMessageMode="ValidationMessageMode.None" />
<HxInputDate Label="HxInputDate (custom PredefinedDates)" @bind-Value="@model.DateTime" PredefinedDates="@GetPredefinedDates()" />
<HxInputDate Label="HxInputDate (disabled)" @bind-Value="@model.DateTime" PredefinedDates="@GetPredefinedDates()" Enabled="false" />
Expand Down
23 changes: 23 additions & 0 deletions BlazorAppTest/Pages/HxInputDate_Issue631_Test.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@page "/HxInputDate_Issue631_Test"
@using Havit;

<h1>HxInputDate</h1>

<HxCard>
<HeaderTemplate><HxIcon Icon="@BootstrapIcon.Calendar4Range" />&ensp;Date Range</HeaderTemplate>
<BodyTemplate>
<div class="row">
<div class="col-6">
<HxInputDate Label="Start" @bind-Value="@startDate" MaxDate="@DateTime.Today" />
</div>
<div class="col-6">
<HxInputDate Label="End" @bind-Value="@endDate" MaxDate="@DateTime.Today" />
</div>
</div>
</BodyTemplate>
</HxCard>

@code {
private DateTime startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
private DateTime endDate = DateTime.Today;
}
4 changes: 2 additions & 2 deletions BlazorAppTest/Pages/HxSearchBoxTest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
{
SearchBoxDataProviderResult<SearchBoxItem> result = new()
{
Data = Data.Where(i => i.Title.Contains(request.UserInput)).ToArray()
};
Data = Data.Where(i => i.Title.Contains(request.UserInput, StringComparison.OrdinalIgnoreCase)).ToArray()
};

return Task.FromResult(result);
}
Expand Down
78 changes: 78 additions & 0 deletions BlazorAppTest/Pages/HxSearchBox_Issue572_Test.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@page "/HxSearchBox_Issue572_Test"

<HxSearchBox TItem="SearchBoxItem"
DataProvider="ProvideSearchResults"
MinimumLength="0"
Label="Search"
ItemTitleSelector="(i) => i.Title"
@bind-TextQuery="textQuery"
ItemSelectionBehavior="SearchBoxItemSelectionBehavior.SelectAndReplaceTextQueryWithItemTitle"
OnItemSelected="HandleItemSelected"
OnTextQueryTriggered="HandleTextQueryTriggered">
<DefaultContentTemplate>
<div class="small py-2 px-3 text-muted">Search for Mouse, Table or Door...</div>
</DefaultContentTemplate>
</HxSearchBox>

<p>selectedItemTitle: @selectedItemTitle</p>
<p>textQueryTriggered: @textQueryTriggered</p>
<p>textQuery: @textQuery</p>

@code {
private string selectedItemTitle = string.Empty;
private string textQueryTriggered = string.Empty;
private string textQuery = string.Empty;
private void HandleItemSelected(SearchBoxItem item)
{
selectedItemTitle = item.Title;
}
private void HandleTextQueryTriggered(string text)
{
textQueryTriggered = text;
}
List<SearchBoxItem> Data { get; set; } = new()
{
new()
{
Title = "Table",
Subtitle = "$5000",
Icon = BootstrapIcon.Table
},
new()
{
Title = "Mouse",
Subtitle = "$40",
Icon = BootstrapIcon.Mouse
},
new()
{
Title = "Door",
Subtitle = "$100",
Icon = BootstrapIcon.DoorClosed
}
};

Task<SearchBoxDataProviderResult<SearchBoxItem>> ProvideSearchResults(SearchBoxDataProviderRequest request)
{
if (request.UserInput?.Length > 0)
{
SearchBoxDataProviderResult<SearchBoxItem> result2 = new()
{
Data = Data.Where(i => i.Title.Contains(request.UserInput, StringComparison.OrdinalIgnoreCase)).ToArray()
};
return Task.FromResult(result2);
}
SearchBoxDataProviderResult<SearchBoxItem> result = new()
{
Data = Data.Take(10).ToArray()
};
return Task.FromResult(result);
}

record SearchBoxItem
{
public string Title { get; set; }
public string Subtitle { get; set; }
public BootstrapIcon Icon { get; set; }
}
}
70 changes: 70 additions & 0 deletions BlazorAppTest/Pages/HxSearchBox_Issue575_Test.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
@page "/HxSearchBox_Issue575_Test"

<HxSearchBox TItem="SearchBoxItem"
DataProvider="ProvideSearchResults"
Label="Search"
ItemTitleSelector="(i) => i.Title"
@bind-TextQuery="textQuery"
ItemSelectionBehavior="SearchBoxItemSelectionBehavior.SelectAndReplaceTextQueryWithItemTitle"
OnItemSelected="HandleItemSelected"
OnTextQueryTriggered="HandleTextQueryTriggered">
<DefaultContentTemplate>
<div class="small py-2 px-3 text-muted">Search for Mouse, Table or Door...</div>
</DefaultContentTemplate>
</HxSearchBox>

<p>selectedItemTitle: @selectedItemTitle</p>
<p>textQueryTriggered: @textQueryTriggered</p>
<p>textQuery: @textQuery</p>

@code {
private string selectedItemTitle = string.Empty;
private string textQueryTriggered = string.Empty;
private string textQuery = string.Empty;
private void HandleItemSelected(SearchBoxItem item)
{
selectedItemTitle = item.Title;
}
private void HandleTextQueryTriggered(string text)
{
textQueryTriggered = text;
}
List<SearchBoxItem> Data { get; set; } = new()
{
new()
{
Title = "Table",
Subtitle = "$5000",
Icon = BootstrapIcon.Table
},
new()
{
Title = "Mouse",
Subtitle = "$40",
Icon = BootstrapIcon.Mouse
},
new()
{
Title = "Door",
Subtitle = "$100",
Icon = BootstrapIcon.DoorClosed
}
};

Task<SearchBoxDataProviderResult<SearchBoxItem>> ProvideSearchResults(SearchBoxDataProviderRequest request)
{
SearchBoxDataProviderResult<SearchBoxItem> result = new()
{
Data = Data.Where(i => i.Title.Contains(request.UserInput, StringComparison.OrdinalIgnoreCase)).ToArray()
};

return Task.FromResult(result);
}

record SearchBoxItem
{
public string Title { get; set; }
public string Subtitle { get; set; }
public BootstrapIcon Icon { get; set; }
}
}
Loading

0 comments on commit f94476a

Please sign in to comment.