-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into HxDropdownToggleButton-Add-AutoClose-Param…
…eter-to-control-the-closing-behavior-#600
- Loading branch information
Showing
139 changed files
with
6,402 additions
and
5,629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" /> 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
Oops, something went wrong.