mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 17:31:42 +08:00
ea061850ec
* fix(module:select): multiple select & tags & tokenization fix performance optimizations add PrefixIcon keep focus on selected item * fix(module:select): on clear button make first active * docs(module:select): reflect changes
199 lines
7.9 KiB
C#
199 lines
7.9 KiB
C#
@using AntDesign
|
|
@namespace AntDesign.Select.Internal
|
|
@typeparam TItemValue
|
|
@typeparam TItem
|
|
|
|
<div class="@Prefix-selector" @ref="@Ref" style="@(ParentSelect.PrefixIcon is null?"":"padding-left: 4px;")">
|
|
@if (ShowPlaceholder)
|
|
{
|
|
@if (@ParentSelect.PrefixIcon != null)
|
|
{
|
|
<span>
|
|
<span class="@Prefix-prefix" unselectable="on" aria-hidden="true" style="user-select: none;" >
|
|
@ParentSelect.PrefixIcon
|
|
</span>
|
|
<span class="@Prefix-selection-placeholder" style="position: relative; left: 0px;">@Placeholder</span>
|
|
</span>
|
|
}
|
|
else
|
|
{
|
|
|
|
<span class="@Prefix-selection-placeholder">@Placeholder</span>
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
@if (ParentSelect.SelectMode == SelectMode.Default)
|
|
{
|
|
var selectedItem = ParentSelect.SelectedOptionItems.FirstOrDefault();
|
|
|
|
if (string.IsNullOrEmpty(SearchValue) && selectedItem != null)
|
|
{
|
|
@if (ParentLabelTemplate != null)
|
|
{
|
|
<CascadingValue Value="this" Name="SelectContent">
|
|
<CascadingValue Value="@selectedItem" Name="SelectOption">
|
|
@if (@ParentSelect.PrefixIcon != null)
|
|
{
|
|
<span>
|
|
<span class="@Prefix-prefix" unselectable="on" aria-hidden="true" style="user-select: none;" >
|
|
@ParentSelect.PrefixIcon
|
|
</span>
|
|
@ParentLabelTemplate(selectedItem.Item)
|
|
</span>
|
|
}
|
|
else
|
|
{
|
|
@ParentLabelTemplate(selectedItem.Item)
|
|
}
|
|
</CascadingValue>
|
|
</CascadingValue>
|
|
}
|
|
else
|
|
{
|
|
@if (@ParentSelect.PrefixIcon != null)
|
|
{
|
|
<span>
|
|
<span class="@Prefix-prefix" unselectable="on" aria-hidden="true" style="user-select: none;" >
|
|
@ParentSelect.PrefixIcon
|
|
</span>
|
|
<span class="@Prefix-selection-item">
|
|
<span class="@Prefix-selection-item-content">@selectedItem.Label</span>
|
|
</span>
|
|
</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="@Prefix-selection-item">
|
|
<span class="@Prefix-selection-item-content">@selectedItem.Label</span>
|
|
</span>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var selectedItems = ParentSelect.SelectedOptionItems;
|
|
|
|
@foreach (var selectedOption in selectedItems)
|
|
{
|
|
@if (ParentLabelTemplate != null)
|
|
{
|
|
<CascadingValue Value="this" Name="SelectContent">
|
|
<CascadingValue Value="@selectedOption" Name="SelectOption">
|
|
@ParentLabelTemplate(selectedOption.Item)
|
|
</CascadingValue>
|
|
</CascadingValue>
|
|
}
|
|
else
|
|
{
|
|
<span class="@Prefix-selection-item">
|
|
<span class="@Prefix-selection-item-content">@selectedOption.Label</span>
|
|
<span unselectable="on" aria-hidden="true" style="user-select: none;" class="@Prefix-selection-item-remove"
|
|
@onclick="()=> OnRemoveSelected.InvokeAsync(selectedOption)" @onclick:stopPropagation="true">
|
|
<Icon Type="close"></Icon>
|
|
</span>
|
|
</span>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
<span class="@Prefix-selection-search" style="@_inputWidth">
|
|
<input @ref="ParentSelect._inputRef"
|
|
@oninput="OnInput"
|
|
@onkeyup="OnKeyUp"
|
|
@onkeydown="OnKeyDown"
|
|
@onfocus="OnFocus"
|
|
@onblur="OnBlur"
|
|
@attributes=@AdditonalAttributes()
|
|
@onkeypress="@OnKeyPressEventHandler"
|
|
@onkeypress:preventDefault="@_suppressInput"
|
|
@onkeypress:stopPropagation="true"
|
|
@bind-value="@SearchValue"
|
|
id="@ParentSelect.Id"
|
|
role="combobox"
|
|
class="@Prefix-selection-search-input"
|
|
autocomplete="off"
|
|
aria-owns="@(ParentSelect.Id)_list"
|
|
aria-expanded="@IsOverlayShow"
|
|
aria-autocomplete="list"
|
|
aria-controls="@(ParentSelect.Id)_list"
|
|
style="@_inputStyle"/>
|
|
|
|
@if (ParentSelect.SelectMode != SelectMode.Default)
|
|
{
|
|
<span class="@Prefix-selection-search-mirror" aria-hidden="true"> </span>
|
|
}
|
|
</span>
|
|
</div>
|
|
|
|
@if (ParentSelect.SelectMode == SelectMode.Default)
|
|
{
|
|
if (ParentSelect.SuffixIcon != null)
|
|
{
|
|
<span class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="@ParentSelect.OnArrowClick" @onclick:stopPropagation="true">
|
|
@ParentSelect.SuffixIcon
|
|
</span>
|
|
}
|
|
else if (ParentSelect.Loading)
|
|
{
|
|
<span class="ant-select-arrow ant-select-arrow-loading" unselectable="on" aria-hidden="true" style="user-select: none;">
|
|
<Icon Type="loading"></Icon>
|
|
</span>
|
|
}
|
|
else
|
|
{
|
|
if (ShowArrowIcon)
|
|
{
|
|
<span class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="@ParentSelect.OnArrowClick" @onclick:stopPropagation="true">
|
|
@if (ParentSelect.IsSearchEnabled && IsOverlayShow)
|
|
{
|
|
if (ShowSearchIcon)
|
|
{
|
|
<Icon Type="search"></Icon>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<Icon Type="down"></Icon>
|
|
}
|
|
</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="@ParentSelect.OnArrowClick" @onclick:stopPropagation="true">
|
|
@if (ParentSelect.IsSearchEnabled && IsOverlayShow)
|
|
{
|
|
if (ShowSearchIcon)
|
|
{
|
|
<Icon Type="search"></Icon>
|
|
}
|
|
}
|
|
</span>
|
|
}
|
|
|
|
@if (!ParentSelect.Disabled && ParentSelect.AllowClear && ParentSelect.HasValue)
|
|
{
|
|
<span class="ant-select-clear" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="OnClearClick" @onclick:stopPropagation="true">
|
|
<Icon Type="close-circle" Theme="fill"></Icon>
|
|
</span>
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
@if (ParentSelect.SuffixIcon != null)
|
|
{
|
|
<span class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="@ParentSelect.OnArrowClick" @onclick:stopPropagation="true">
|
|
@ParentSelect.SuffixIcon
|
|
</span>
|
|
}
|
|
@if (!ParentSelect.Disabled && ParentSelect.AllowClear && ParentSelect.HasValue)
|
|
{
|
|
<span class="ant-select-clear" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="OnClearClick" @onclick:stopPropagation="true">
|
|
<Icon Type="close-circle" Theme="fill"></Icon>
|
|
</span>
|
|
}
|
|
} |