2020-11-27 13:13:26 +08:00
|
|
|
|
@using AntDesign
|
|
|
|
|
@namespace AntDesign.Select.Internal
|
|
|
|
|
@typeparam TItemValue
|
|
|
|
|
@typeparam TItem
|
|
|
|
|
|
|
|
|
|
<div class="@Prefix-selector">
|
|
|
|
|
|
|
|
|
|
@if (ShowPlaceholder)
|
|
|
|
|
{
|
|
|
|
|
<span class="@Prefix-selection-placeholder">@Placeholder</span>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@if (ParentSelect.SelectMode == SelectMode.Default)
|
2020-09-09 22:12:12 +08:00
|
|
|
|
{
|
2020-11-27 13:13:26 +08:00
|
|
|
|
var selectedItem = ParentSelect.SelectOptionItems.FirstOrDefault(x => x.IsSelected);
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(SearchValue) && selectedItem != null)
|
|
|
|
|
{
|
|
|
|
|
@if (ParentLabelTemplate != null)
|
2020-09-09 22:12:12 +08:00
|
|
|
|
{
|
2020-11-27 13:13:26 +08:00
|
|
|
|
<CascadingValue Value="this" Name="SelectContent">
|
|
|
|
|
<CascadingValue Value="@selectedItem" Name="SelectOption">
|
|
|
|
|
@ParentLabelTemplate(selectedItem.Item)
|
|
|
|
|
</CascadingValue>
|
|
|
|
|
</CascadingValue>
|
2020-09-09 22:12:12 +08:00
|
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
|
else
|
2020-09-09 22:12:12 +08:00
|
|
|
|
{
|
2020-11-27 13:13:26 +08:00
|
|
|
|
<span class="@Prefix-selection-item">
|
|
|
|
|
<span class="@Prefix-selection-item-content">
|
|
|
|
|
@selectedItem.Label
|
|
|
|
|
</span>
|
2020-10-25 14:59:10 +08:00
|
|
|
|
</span>
|
2020-09-09 22:12:12 +08:00
|
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
|
}
|
2020-09-09 22:12:12 +08:00
|
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
|
else
|
2020-09-09 22:12:12 +08:00
|
|
|
|
{
|
2020-11-27 13:13:26 +08:00
|
|
|
|
var selectedItems = ParentSelect.SortedSelectOptionItems.Where(x => x.IsSelected);
|
2020-09-09 22:12:12 +08:00
|
|
|
|
|
2020-11-27 13:13:26 +08:00
|
|
|
|
@foreach (var selectedOption in selectedItems)
|
|
|
|
|
{
|
|
|
|
|
@if (ParentLabelTemplate != null)
|
|
|
|
|
{
|
|
|
|
|
<CascadingValue Value="this" Name="SelectContent">
|
|
|
|
|
<CascadingValue Value="@selectedOption" Name="SelectOption">
|
|
|
|
|
@ParentLabelTemplate(selectedOption.Item)
|
|
|
|
|
</CascadingValue>
|
|
|
|
|
</CascadingValue>
|
2020-09-09 22:12:12 +08:00
|
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
|
else
|
2020-09-09 22:12:12 +08:00
|
|
|
|
{
|
2020-11-27 13:13:26 +08:00
|
|
|
|
<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>
|
2020-09-09 22:12:12 +08:00
|
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
|
}
|
2020-09-09 22:12:12 +08:00
|
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<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"
|
|
|
|
|
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>
|
2020-09-09 22:12:12 +08:00
|
|
|
|
|
2020-11-27 13:13:26 +08:00
|
|
|
|
@if (ParentSelect.SelectMode == SelectMode.Default)
|
2020-09-09 22:12:12 +08:00
|
|
|
|
{
|
|
|
|
|
if (ParentSelect.SuffixIcon != null)
|
|
|
|
|
{
|
|
|
|
|
<span class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;">
|
|
|
|
|
@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
|
|
|
|
|
{
|
2020-11-27 13:13:26 +08:00
|
|
|
|
if (ShowArrowIcon)
|
|
|
|
|
{
|
|
|
|
|
<span class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;">
|
|
|
|
|
@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;">
|
|
|
|
|
@if (ParentSelect.IsSearchEnabled && IsOverlayShow)
|
|
|
|
|
{
|
|
|
|
|
if (ShowSearchIcon)
|
|
|
|
|
{
|
|
|
|
|
<Icon Type="search"></Icon>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 12:28:02 +08:00
|
|
|
|
@if (!ParentSelect.Disabled && ParentSelect.AllowClear && ParentSelect.HasValue)
|
2020-09-09 22:12:12 +08:00
|
|
|
|
{
|
2020-11-27 13:13:26 +08:00
|
|
|
|
<span class="ant-select-clear" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="OnClearClick" @onclick:stopPropagation="true">
|
2020-11-28 10:02:35 +08:00
|
|
|
|
<Icon Type="close-circle" Theme="fill"></Icon>
|
2020-09-09 22:12:12 +08:00
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
|
else
|
2020-10-25 14:59:10 +08:00
|
|
|
|
{
|
2020-12-03 12:28:02 +08:00
|
|
|
|
@if (!ParentSelect.Disabled && ParentSelect.AllowClear && ParentSelect.HasValue)
|
2020-10-25 14:59:10 +08:00
|
|
|
|
{
|
2020-11-27 13:13:26 +08:00
|
|
|
|
<span class="ant-select-clear" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="OnClearClick" @onclick:stopPropagation="true">
|
2020-11-28 10:02:35 +08:00
|
|
|
|
<Icon Type="close-circle" Theme="fill"></Icon>
|
2020-10-25 14:59:10 +08:00
|
|
|
|
</span>
|
|
|
|
|
}
|
2020-09-09 22:12:12 +08:00
|
|
|
|
}
|