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

[2.0] API refactor: extension components #5878

Draft
wants to merge 21 commits into
base: next-2.0
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ dotnet_style_readonly_field = true:suggestion
# Parameter preferences
dotnet_code_quality_unused_parameters = all:suggestion

# Namespaces
dotnet_style_namespace_match_folder = false

#### C# Coding Conventions ####

# var preferences
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<SelectList Data="@dataGridRef.DisplayGroupedData"
TItem="GroupContext<Employee>" TValue="string"
TextField="x=> x.Key" ValueField="x=> x.Key"
@bind-SelectedValue="_selectedGroupKey"></SelectList>
@bind-Value="_selectedGroupKey"></SelectList>
</FieldLabel>
<FieldBody>
<Button Color="Color.Primary" Clicked="@(() => dataGridRef.ExpandGroups(_selectedGroupKey))">Expand Selected Group</Button>
Expand All @@ -41,7 +41,7 @@
<SelectList Data="@dataGridRef.DisplayGroupedData?.SelectMany(x=> x.NestedGroup)?.GroupBy(x=> x.Key)?.Select(x=> x.First())"
TItem="GroupContext<Employee>" TValue="string"
TextField="x=> x.Key" ValueField="x=> x.Key"
@bind-SelectedValue="_selectedNestedGroupKey"></SelectList>
@bind-Value="_selectedNestedGroupKey"></SelectList>
</FieldLabel>
<FieldBody>
<Button Color="Color.Primary" Clicked="@(() => dataGridRef.ExpandGroups(_selectedNestedGroupKey))">Expand Selected Group</Button>
Expand Down
68 changes: 59 additions & 9 deletions Demos/Blazorise.Demo/Pages/Tests/DropdownListPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Column ColumnSize="ColumnSize.IsFull.OnMobile.IsHalf.OnTablet">
<Card Margin="Margin.Is4.OnY">
<CardHeader>
<CardTitle>Dropdown List</CardTitle>
<CardTitle>Dropdown List: Single Value</CardTitle>
</CardHeader>
<CardBody>
<Field Horizontal JustifyContent="JustifyContent.End">
Expand All @@ -16,10 +16,9 @@
TextField="@(( item ) => item.Name)"
ValueField="@((item) => item.Iso)"
DisabledItem="@(item => item.Name == "Armenia")"
@bind-SelectedValue="@selectedDropValue"
@bind-Value="@selectedDropValue"
Color="Color.Primary"
MaxMenuHeight="200px"
DropdownToggleSize="Size.Large">
MaxMenuHeight="200px">
Select item
</DropdownList>
</FieldBody>
Expand All @@ -32,23 +31,73 @@
</CardBody>
</Card>
</Column>
</Row>

<Row>
<Column ColumnSize="ColumnSize.IsFull.OnMobile.IsHalf.OnTablet">
<Card Margin="Margin.Is4.OnY">
<CardHeader>
<CardTitle>Dropdown List : Checkbox</CardTitle>
<CardTitle>Dropdown List: Generic List</CardTitle>
</CardHeader>
<CardBody>
<Button Color="Color.Primary" Clicked="@(()=>selectedDropValues = null)">
Clear
</Button>
<Button Color="Color.Primary" Clicked="@(()=>selectedDropValues = new List<string> {"CA"})">
Change
</Button>
</CardBody>
<CardBody>
<Field Horizontal JustifyContent="JustifyContent.End">
<FieldLabel ColumnSize="ColumnSize.Is2">Select Value</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is10">
<DropdownList TItem="Country"
TValue="string"
TValue="IReadOnlyList<string>"
Data="@Countries"
TextField="@(( item ) => item.Name)"
ValueField="@((item) => item.Iso)"
DisabledItem="@(item => item.Name == "Armenia")"
@bind-Value="@selectedDropValues"
SelectionMode="DropdownListSelectionMode.Checkbox"
Color="Color.Primary"
MaxMenuHeight="200px">
Select items
</DropdownList>
</FieldBody>
</Field>
<Field Horizontal JustifyContent="JustifyContent.End">
<FieldBody ColumnSize="ColumnSize.Is10.Is2.WithOffset">
Selected values: @(selectedDropValues is not null ? string.Join( ',', selectedDropValues ) : "")
</FieldBody>
</Field>
</CardBody>
</Card>
</Column>

<Column ColumnSize="ColumnSize.IsFull.OnMobile.IsHalf.OnTablet">
<Card Margin="Margin.Is4.OnY">
<CardHeader>
<CardTitle>Dropdown List: Array</CardTitle>
</CardHeader>
<CardBody>
<Button Color="Color.Primary" Clicked="@(()=>selectedDropValues2 = null)">
Clear
</Button>
<Button Color="Color.Primary" Clicked="@(()=>selectedDropValues2 = new string[]{"CA"})">
Change
</Button>
</CardBody>
<CardBody>
<Field Horizontal JustifyContent="JustifyContent.End">
<FieldLabel ColumnSize="ColumnSize.Is2">Select Value</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is10">
<DropdownList TItem="Country"
TValue="string[]"
Data="@Countries"
TextField="@(( item ) => item.Name)"
ValueField="@((item) => item.Iso)"
DisabledItem="@(item => item.Name == "Armenia")"
@bind-SelectedValues="@selectedDropValues"
@bind-Value="@selectedDropValues2"
SelectionMode="DropdownListSelectionMode.Checkbox"
Color="Color.Primary"
MaxMenuHeight="200px">
Expand All @@ -58,7 +107,7 @@
</Field>
<Field Horizontal JustifyContent="JustifyContent.End">
<FieldBody ColumnSize="ColumnSize.Is10.Is2.WithOffset">
Selected values: @(selectedDropValues is not null ? string.Join( ',', selectedDropValues ) : "");
Selected values: @(selectedDropValues2 is not null ? string.Join( ',', selectedDropValues2 ) : "")
</FieldBody>
</Field>
</CardBody>
Expand All @@ -72,7 +121,8 @@
public IEnumerable<Country> Countries;

private string selectedDropValue { get; set; } = "AF";
private IReadOnlyList<string> selectedDropValues { get; set; } = new[] { "AM", "AF" };
private IReadOnlyList<string> selectedDropValues { get; set; } = new List<string> { "AM", "AF" };
private string[] selectedDropValues2 { get; set; } = new[] { "AM", "AF" };

protected override async Task OnInitializedAsync()
{
Expand Down
6 changes: 3 additions & 3 deletions Demos/Blazorise.Demo/Pages/Tests/SelectListPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Data="@Countries"
TextField="@(( item ) => item.Name)"
ValueField="@((item) => item.Iso)"
@bind-SelectedValue="@selectedListValue"
@bind-Value="@selectedListValue"
DefaultItemText="Choose your country" />
</FieldBody>
</Field>
Expand All @@ -38,12 +38,12 @@
<FieldLabel ColumnSize="ColumnSize.Is2">Select Value</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is10">
<SelectList TItem="Country"
TValue="string"
TValue="IReadOnlyList<string>"
Data="@Countries"
TextField="@(( item ) => item.Name)"
ValueField="@((item) => item.Iso)"
Multiple
@bind-SelectedValues="@selectedListValues"
@bind-Value="@selectedListValues"
DefaultItemText="Choose your country(s)" />
</FieldBody>
</Field>
Expand Down
20 changes: 9 additions & 11 deletions Documentation/Blazorise.Docs/Models/Snippets.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3807,7 +3807,7 @@ private static string GetColor( int number )
</SelectGroup>
</Select>";

public const string MultipleSelectExample = @"<Select TValue=""int"" Multiple>
public const string MultipleSelectExample = @"<Select TValue=""int[]"" Multiple>
<SelectItem Value=""1"">One</SelectItem>
<SelectItem Value=""2"">Two</SelectItem>
<SelectItem Value=""3"">Three</SelectItem>
Expand Down Expand Up @@ -9524,11 +9524,11 @@ protected override async Task OnInitializedAsync()
}
}";

public const string DropdownListCheckboxExample = @"<DropdownList TItem=""Country"" TValue=""string""
public const string DropdownListCheckboxExample = @"<DropdownList TItem=""Country"" TValue=""IReadOnlyList<string>""
Data=""@Countries""
TextField=""@((item)=>item.Name)""
ValueField=""@((item)=>item.Iso)""
@bind-SelectedValues=""@selectedDropValues""
@bind-Value=""@selectedDropValues""
SelectionMode=""DropdownListSelectionMode.Checkbox""
Color=""Color.Primary""
MaxMenuHeight=""200px"">
Expand All @@ -9546,7 +9546,7 @@ Select item
</FieldBody>
</Field>

@code{
@code {
[Inject]
public CountryData CountryData { get; set; }
public IEnumerable<Country> Countries;
Expand All @@ -9558,14 +9558,13 @@ protected override async Task OnInitializedAsync()
}

private IReadOnlyList<string> selectedDropValues { get; set; } = new[] { ""AM"", ""AF"" };

}";

public const string DropdownListExample = @"<DropdownList TItem=""Country"" TValue=""string""
Data=""@Countries""
TextField=""@((item)=>item.Name)""
ValueField=""@((item)=>item.Iso)""
@bind-SelectedValue=""@selectedDropValue""
@bind-Value=""@selectedDropValue""
Color=""Color.Primary""
MaxMenuHeight=""200px"">
Select item
Expand All @@ -9580,7 +9579,7 @@ Select item
</FieldBody>
</Field>

@code{
@code {
[Inject]
public CountryData CountryData { get; set; }
public IEnumerable<Country> Countries;
Expand All @@ -9592,7 +9591,6 @@ protected override async Task OnInitializedAsync()
}

string selectedDropValue { get; set; } = ""CN"";

}";

public const string BasicFluentValidationExample = @"@using Blazorise.FluentValidation
Expand Down Expand Up @@ -10357,7 +10355,7 @@ public async Task OnSave()
Data=""@IndexedCountries""
TextField=""@((item)=>item.Name)""
ValueField=""@((item)=>item.Id)""
@bind-SelectedValue=""@selectedListValue""
@bind-Value=""@selectedListValue""
DefaultItemText=""Choose your country"" />

@code {
Expand All @@ -10374,12 +10372,12 @@ public class MyCountryModel
}";

public const string SelectListMultipleExample = @"<SelectList TItem=""MyFruitModel""
TValue=""int""
TValue=""IReadOnlyList<int>""
Data=""@IndexedFruits""
TextField=""@((item)=>item.Name)""
ValueField=""@((item)=>item.Id)""
Multiple
@bind-SelectedValues=""@selectedListValues""
@bind-Value=""@selectedListValues""
DefaultItemText=""Choose your fruit"" />

@code {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="blazorise-codeblock">
<div class="html"><pre>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">Select</span> <span class="htmlAttributeName">TValue</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">int</span><span class="quot">&quot;</span> <span class="htmlAttributeName">Multiple</span><span class="htmlTagDelimiter">&gt;</span>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">Select</span> <span class="htmlAttributeName">TValue</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">int[]</span><span class="quot">&quot;</span> <span class="htmlAttributeName">Multiple</span><span class="htmlTagDelimiter">&gt;</span>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">SelectItem</span> <span class="htmlAttributeName">Value</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">1</span><span class="quot">&quot;</span><span class="htmlTagDelimiter">&gt;</span>One<span class="htmlTagDelimiter">&lt;/</span><span class="htmlElementName">SelectItem</span><span class="htmlTagDelimiter">&gt;</span>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">SelectItem</span> <span class="htmlAttributeName">Value</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">2</span><span class="quot">&quot;</span><span class="htmlTagDelimiter">&gt;</span>Two<span class="htmlTagDelimiter">&lt;/</span><span class="htmlElementName">SelectItem</span><span class="htmlTagDelimiter">&gt;</span>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">SelectItem</span> <span class="htmlAttributeName">Value</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">3</span><span class="quot">&quot;</span><span class="htmlTagDelimiter">&gt;</span>Three<span class="htmlTagDelimiter">&lt;/</span><span class="htmlElementName">SelectItem</span><span class="htmlTagDelimiter">&gt;</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@namespace Blazorise.Docs.Docs.Examples

<Select TValue="int" Multiple>
<Select TValue="int[]" Multiple>
<SelectItem Value="1">One</SelectItem>
<SelectItem Value="2">Two</SelectItem>
<SelectItem Value="3">Three</SelectItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

<DocsPageSection>
<DocsPageSectionHeader Title="Multiple">
Add the <Code>Multiple</Code> attribute to allow more than one option to be selected.
By changing the enumerable type on the <Code>TValue</Code>, and by enabling the <Code>Multiple</Code> parameter, you will be able to select more than one option.
</DocsPageSectionHeader>
<DocsPageSectionContent Outlined FullWidth>
<MultipleSelectExample />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="blazorise-codeblock">
<div class="html"><pre>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">DropdownList</span> <span class="htmlAttributeName">TItem</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">Country</span><span class="quot">&quot;</span> <span class="htmlAttributeName">TValue</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">string</span><span class="quot">&quot;</span>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">DropdownList</span> <span class="htmlAttributeName">TItem</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">Country</span><span class="quot">&quot;</span> <span class="htmlAttributeName">TValue</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">IReadOnlyList&lt;string&gt;</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">Data</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="sharpVariable"><span class="atSign">&#64;</span>Countries</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">TextField</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue"><span class="atSign">&#64;</span>((item)=&gt;item.Name)</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">ValueField</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue"><span class="atSign">&#64;</span>((item)=&gt;item.Iso)</span><span class="quot">&quot;</span>
<span class="htmlAttributeName"><span class="atSign">&#64;</span>bind-SelectedValues</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="sharpVariable"><span class="atSign">&#64;</span>selectedDropValues</span><span class="quot">&quot;</span>
<span class="htmlAttributeName"><span class="atSign">&#64;</span>bind-Value</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="sharpVariable"><span class="atSign">&#64;</span>selectedDropValues</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">SelectionMode</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="enum">DropdownListSelectionMode</span><span class="enumValue">.Checkbox</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">Color</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="enum">Color</span><span class="enumValue">.Primary</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">MaxMenuHeight</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">200px</span><span class="quot">&quot;</span><span class="htmlTagDelimiter">&gt;</span>
Expand All @@ -23,7 +23,7 @@
<span class="htmlTagDelimiter">&lt;/</span><span class="htmlElementName">Field</span><span class="htmlTagDelimiter">&gt;</span>
</pre></div>
<div class="csharp"><pre>
<span class="atSign">&#64;</span>code{
<span class="atSign">&#64;</span>code {
[Inject]
<span class="keyword">public</span> CountryData CountryData { <span class="keyword">get</span>; <span class="keyword">set</span>; }
<span class="keyword">public</span> IEnumerable&lt;Country&gt; Countries;
Expand All @@ -35,7 +35,6 @@
}

<span class="keyword">private</span> IReadOnlyList&lt;<span class="keyword">string</span>&gt; selectedDropValues { <span class="keyword">get</span>; <span class="keyword">set</span>; } = <span class="keyword">new</span>[] { <span class="string">&quot;AM&quot;</span>, <span class="string">&quot;AF&quot;</span> };

}
</pre></div>
</div>
Loading
Loading