2020-11-27 13:13:26 +08:00
|
|
|
|
@using AntDesign
|
|
|
|
|
@namespace AntDesign.Select.Internal
|
|
|
|
|
@typeparam TItemValue
|
|
|
|
|
@typeparam TItem
|
2021-04-04 01:53:25 +08:00
|
|
|
|
|
2021-04-08 22:17:44 +08:00
|
|
|
|
@if (ParentSelect.SelectMode == SelectMode.Default)
|
|
|
|
|
{
|
|
|
|
|
<div class="@Prefix-selector" @ref="@Ref" style="@(ParentSelect.PrefixIcon is null?"":"padding-left: 4px;")">
|
|
|
|
|
@if (ParentSelect.PrefixIcon != null)
|
|
|
|
|
{
|
|
|
|
|
<span class="@Prefix-prefix" unselectable="on" aria-hidden="true" style="user-select: none;display:flex;align-items: center;padding-right: 4px;">
|
|
|
|
|
@ParentSelect.PrefixIcon
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
<span class="@Prefix-selection-search" style="@_inputWidth">
|
|
|
|
|
<input @ref="ParentSelect._inputRef"
|
|
|
|
|
@oninput="OnInput"
|
|
|
|
|
@onkeyup="OnKeyUp"
|
2021-04-15 14:19:26 +08:00
|
|
|
|
@onkeydown="OnKeyDown"
|
2021-04-08 22:17:44 +08:00
|
|
|
|
@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"/>
|
2021-04-04 01:53:25 +08:00
|
|
|
|
</span>
|
2021-02-14 17:42:44 +08:00
|
|
|
|
@if (ShowPlaceholder)
|
2021-04-04 01:53:25 +08:00
|
|
|
|
{
|
2021-04-08 22:17:44 +08:00
|
|
|
|
<span class="@Prefix-selection-placeholder">@Placeholder</span>
|
2021-02-04 23:40:47 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-04-08 22:17:44 +08:00
|
|
|
|
var selectedItem = ParentSelect.SelectedOptionItems.FirstOrDefault();
|
|
|
|
|
if (string.IsNullOrEmpty(SearchValue) && selectedItem != null)
|
2021-04-04 01:53:25 +08:00
|
|
|
|
{
|
2021-04-08 22:17:44 +08:00
|
|
|
|
@if (ParentLabelTemplate != null)
|
2020-09-09 22:12:12 +08:00
|
|
|
|
{
|
2021-04-08 22:17:44 +08:00
|
|
|
|
<CascadingValue Value="this" Name="SelectContent">
|
|
|
|
|
<CascadingValue Value="@selectedItem" Name="SelectOption">
|
|
|
|
|
@ParentLabelTemplate(selectedItem.Item)
|
2020-11-27 13:13:26 +08:00
|
|
|
|
</CascadingValue>
|
2021-04-08 22:17:44 +08:00
|
|
|
|
</CascadingValue>
|
2020-09-09 22:12:12 +08:00
|
|
|
|
}
|
2021-04-08 22:17:44 +08:00
|
|
|
|
else
|
2020-11-27 13:13:26 +08:00
|
|
|
|
{
|
2021-04-08 22:17:44 +08:00
|
|
|
|
<span class="@Prefix-selection-item">
|
|
|
|
|
@selectedItem.Label
|
2021-02-14 17:42:44 +08:00
|
|
|
|
</span>
|
2021-04-04 01:53:25 +08:00
|
|
|
|
}
|
2021-02-14 17:42:44 +08:00
|
|
|
|
}
|
2021-04-08 22:17:44 +08:00
|
|
|
|
}
|
2021-02-14 17:42:44 +08:00
|
|
|
|
</div>
|
2020-09-09 22:12:12 +08:00
|
|
|
|
|
2021-04-08 22:17:44 +08:00
|
|
|
|
@if (ParentSelect.SuffixIcon != null)
|
2020-09-09 22:12:12 +08:00
|
|
|
|
{
|
2021-01-21 17:20:10 +08:00
|
|
|
|
<span class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="@ParentSelect.OnArrowClick" @onclick:stopPropagation="true">
|
2020-09-09 22:12:12 +08:00
|
|
|
|
@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)
|
|
|
|
|
{
|
2021-01-21 17:20:10 +08:00
|
|
|
|
<span class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="@ParentSelect.OnArrowClick" @onclick:stopPropagation="true">
|
2020-11-27 13:13:26 +08:00
|
|
|
|
@if (ParentSelect.IsSearchEnabled && IsOverlayShow)
|
|
|
|
|
{
|
|
|
|
|
if (ShowSearchIcon)
|
|
|
|
|
{
|
|
|
|
|
<Icon Type="search"></Icon>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<Icon Type="down"></Icon>
|
|
|
|
|
}
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-01-21 17:20:10 +08:00
|
|
|
|
<span class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="@ParentSelect.OnArrowClick" @onclick:stopPropagation="true">
|
2020-11-27 13:13:26 +08:00
|
|
|
|
@if (ParentSelect.IsSearchEnabled && IsOverlayShow)
|
|
|
|
|
{
|
|
|
|
|
if (ShowSearchIcon)
|
|
|
|
|
{
|
|
|
|
|
<Icon Type="search"></Icon>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</span>
|
|
|
|
|
}
|
2021-04-04 01:53:25 +08:00
|
|
|
|
|
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>
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-08 22:17:44 +08:00
|
|
|
|
|
2020-09-09 22:12:12 +08:00
|
|
|
|
}
|
2021-04-08 22:17:44 +08:00
|
|
|
|
else //ParentSelect.SelectMode != SelectMode.Default
|
2021-04-13 13:12:18 +08:00
|
|
|
|
{
|
|
|
|
|
<div class="@Prefix-selector" @ref="@Ref" style="@(ParentSelect.PrefixIcon is null?"":"padding-left: 4px;")" >
|
|
|
|
|
<div class="@Prefix-selection-overflow" @ref="@_overflow">
|
2021-04-08 22:17:44 +08:00
|
|
|
|
@if (ParentSelect.PrefixIcon != null)
|
|
|
|
|
{
|
2021-04-13 13:12:18 +08:00
|
|
|
|
<div class="@Prefix-selection-overflow-item" style="opacity: 1;order:-100;">
|
|
|
|
|
<span @ref="@_prefixRef" class="@Prefix-prefix" unselectable="on" aria-hidden="true" style="user-select: none;display:flex;align-items: center;padding-right: 4px;min-height:28px;">
|
2021-04-08 22:17:44 +08:00
|
|
|
|
@ParentSelect.PrefixIcon
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
@if (!ShowPlaceholder)
|
|
|
|
|
{
|
2021-04-13 13:12:18 +08:00
|
|
|
|
var selectedItems = ParentSelect.SelectedOptionItems;
|
|
|
|
|
@if (ParentSelect.HasTagCount)
|
|
|
|
|
{
|
|
|
|
|
@for (int i = 0; i < Math.Min(ParentSelect.MaxTagCount.AsT0, selectedItems.Count); i++)
|
2021-04-08 22:17:44 +08:00
|
|
|
|
{
|
2021-04-13 13:12:18 +08:00
|
|
|
|
var selectedOption = selectedItems[i];
|
|
|
|
|
<div class="@Prefix-selection-overflow-item" style="@OverflowStyle(i)">
|
|
|
|
|
@if (ParentLabelTemplate != null)
|
|
|
|
|
{
|
|
|
|
|
<CascadingValue Value="this" Name="SelectContent">
|
|
|
|
|
<CascadingValue Value="@selectedOption" Name="SelectOption">
|
|
|
|
|
@ParentLabelTemplate(selectedOption.Item)
|
|
|
|
|
</CascadingValue>
|
2021-04-08 22:17:44 +08:00
|
|
|
|
</CascadingValue>
|
2021-04-13 13:12:18 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<span class="@Prefix-selection-item">
|
|
|
|
|
<span class="@Prefix-selection-item-content">@FormatLabel(selectedOption.Label)</span>
|
|
|
|
|
<span unselectable="on" aria-hidden="true" style="user-select: none;" class="@Prefix-selection-item-remove"
|
|
|
|
|
@onmousedown="()=> OnRemoveSelected.InvokeAsync(selectedOption)" onclick="event.stopPropagation()">
|
|
|
|
|
<Icon Type="close"></Icon>
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
2021-04-08 22:17:44 +08:00
|
|
|
|
}
|
2021-04-13 13:12:18 +08:00
|
|
|
|
@if (selectedItems.Count > ParentSelect.MaxTagCount.AsT0)
|
2021-04-08 22:17:44 +08:00
|
|
|
|
{
|
2021-04-13 13:12:18 +08:00
|
|
|
|
<div class="@Prefix-selection-overflow-item @Prefix-selection-overflow-item-rest" style="opacity: 1;">
|
|
|
|
|
@if (ParentMaxTagPlaceholerTemplate != null)
|
|
|
|
|
{
|
|
|
|
|
<CascadingValue Value="this" Name="SelectContent">
|
|
|
|
|
@ParentMaxTagPlaceholerTemplate(selectedItems.Skip(ParentSelect.MaxTagCount.AsT0).Select(i => i.Item))
|
|
|
|
|
</CascadingValue>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
2021-04-08 22:17:44 +08:00
|
|
|
|
<span class="@Prefix-selection-item">
|
2021-04-13 13:12:18 +08:00
|
|
|
|
<span class="@Prefix-selection-item-content">+ @(selectedItems.Count - ParentSelect.MaxTagCount.AsT0)@Ellipse</span>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (ParentSelect.IsResponsive)
|
|
|
|
|
{
|
|
|
|
|
@for (int i = 0; i < selectedItems.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var selectedOption = selectedItems[i];
|
|
|
|
|
<div class="@Prefix-selection-overflow-item" @key="@selectedOption.InternalId" @ref="@selectedOption.SelectedTagRef" style="@OverflowStyle(i)">
|
|
|
|
|
@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">@FormatLabel(selectedOption.Label)</span>
|
2021-04-08 22:17:44 +08:00
|
|
|
|
<span unselectable="on" aria-hidden="true" style="user-select: none;" class="@Prefix-selection-item-remove"
|
2021-04-13 13:12:18 +08:00
|
|
|
|
@onmousedown="()=> OnRemoveSelected.InvokeAsync(selectedOption)" onclick="event.stopPropagation()">
|
2021-04-08 22:17:44 +08:00
|
|
|
|
<Icon Type="close"></Icon>
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
2021-04-13 13:12:18 +08:00
|
|
|
|
}
|
2021-04-08 22:17:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
}
|
2021-04-13 13:12:18 +08:00
|
|
|
|
@if (selectedItems.Count > _calculatedMaxCount)
|
|
|
|
|
{
|
|
|
|
|
<div class="@Prefix-selection-overflow-item @Prefix-selection-overflow-item-rest" @key="@_internalId" @ref="@_aggregateTag" style="opacity 1; order: @(_calculatedMaxCount-1);">
|
|
|
|
|
@if (ParentMaxTagPlaceholerTemplate != null)
|
|
|
|
|
{
|
|
|
|
|
<CascadingValue Value="this" Name="SelectContent">
|
|
|
|
|
@ParentMaxTagPlaceholerTemplate(selectedItems.Skip(_calculatedMaxCount).Select(i => i.Item))
|
|
|
|
|
</CascadingValue>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<span class="@Prefix-selection-item">
|
|
|
|
|
<span class="@Prefix-selection-item-content">+ @(selectedItems.Count-_calculatedMaxCount)@Ellipse</span>
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string firstAfterPrefix = $"max-width: {GetFirstItemMaxWidth()}%;";
|
|
|
|
|
@foreach (var selectedOption in selectedItems)
|
|
|
|
|
{
|
|
|
|
|
<div class="@Prefix-selection-overflow-item" style="opacity: 1;@firstAfterPrefix">
|
|
|
|
|
@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">@FormatLabel(selectedOption.Label)</span>
|
|
|
|
|
<span unselectable="on" aria-hidden="true" style="user-select: none;" class="@Prefix-selection-item-remove"
|
|
|
|
|
@onmousedown="()=> OnRemoveSelected.InvokeAsync(selectedOption)" onclick="event.stopPropagation()">
|
|
|
|
|
<Icon Type="close"></Icon>
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
firstAfterPrefix = "max-width: 98%;";
|
|
|
|
|
}
|
2021-04-08 22:17:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-13 13:12:18 +08:00
|
|
|
|
<div class="@Prefix-selection-overflow-item @Prefix-selection-overflow-item-suffix" style="opacity: 1; order: @(ParentSelect.IsResponsive?_calculatedMaxCount-1:1)">
|
2021-04-08 22:17:44 +08:00
|
|
|
|
<div class="@Prefix-selection-search" style="@_inputWidth">
|
|
|
|
|
<input @ref="ParentSelect._inputRef"
|
|
|
|
|
@oninput="OnInput"
|
|
|
|
|
@onkeyup="OnKeyUp"
|
2021-04-15 14:19:26 +08:00
|
|
|
|
@onkeydown="OnKeyDown"
|
2021-04-08 22:17:44 +08:00
|
|
|
|
@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"/>
|
|
|
|
|
<span class="@Prefix-selection-search-mirror" aria-hidden="true"> </span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@if (ShowPlaceholder)
|
|
|
|
|
{
|
|
|
|
|
<span class="@Prefix-selection-placeholder" style="@(ParentSelect.PrefixIcon != null?"margin-left: 7px;":"")">@Placeholder</span>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2021-02-04 23:40:47 +08:00
|
|
|
|
@if (ParentSelect.SuffixIcon != null)
|
|
|
|
|
{
|
2021-04-13 13:12:18 +08:00
|
|
|
|
<span @ref="@_suffixRef" class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="@ParentSelect.OnArrowClick" @onclick:stopPropagation="true">
|
2021-02-04 23:40:47 +08:00
|
|
|
|
@ParentSelect.SuffixIcon
|
|
|
|
|
</span>
|
|
|
|
|
}
|
2021-04-04 01:53:25 +08:00
|
|
|
|
else if (ParentSelect.Loading)
|
|
|
|
|
{
|
2021-04-13 13:12:18 +08:00
|
|
|
|
<span @ref="@_suffixRef" class="ant-select-arrow ant-select-arrow-loading" unselectable="on" aria-hidden="true" style="user-select: none;">
|
2021-04-04 01:53:25 +08:00
|
|
|
|
<Icon Type="loading"></Icon>
|
|
|
|
|
</span>
|
|
|
|
|
}
|
2020-12-03 12:28:02 +08:00
|
|
|
|
@if (!ParentSelect.Disabled && ParentSelect.AllowClear && ParentSelect.HasValue)
|
2020-10-25 14:59:10 +08:00
|
|
|
|
{
|
2021-04-13 13:12:18 +08:00
|
|
|
|
<span @ref="@_suffixRef" class="ant-select-clear" unselectable="on" aria-hidden="true" style="user-select: none;" @onclick="OnClearClickAsync" @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
|
|
|
|
}
|