2020-09-09 22:12:12 +08:00
|
|
|
@using AntDesign.Internal
|
2020-11-27 13:13:26 +08:00
|
|
|
@using AntDesign.Select.Internal
|
|
|
|
@namespace AntDesign
|
2021-09-08 19:00:05 +08:00
|
|
|
@inherits SelectBase<TItemValue, TItem>
|
2020-11-27 13:13:26 +08:00
|
|
|
@typeparam TItemValue
|
|
|
|
@typeparam TItem
|
2020-06-14 18:54:14 +08:00
|
|
|
|
2021-10-29 22:48:18 +08:00
|
|
|
<CascadingValue Value="this" IsFixed="@(!IsGroupingEnabled)">
|
2021-09-08 19:00:05 +08:00
|
|
|
<CascadingValue Value=@("ant-select-dropdown") Name="PrefixCls" IsFixed>
|
2020-09-09 22:12:12 +08:00
|
|
|
<OverlayTrigger @ref="@_dropDown"
|
|
|
|
Visible="Open"
|
|
|
|
Disabled="Disabled"
|
2021-09-10 19:06:50 +08:00
|
|
|
Trigger="new[] { Trigger.Click }"
|
|
|
|
HiddenMode
|
|
|
|
BoundaryAdjustMode="@BoundaryAdjustMode"
|
2020-11-27 13:13:26 +08:00
|
|
|
OnMouseEnter="@(() => { OnMouseEnter?.Invoke(); })"
|
|
|
|
OnMouseLeave="@(() => { OnMouseLeave?.Invoke(); })"
|
|
|
|
OnVisibleChange="@OnOverlayVisibleChangeAsync"
|
2020-09-17 10:37:47 +08:00
|
|
|
PopupContainerSelector="@PopupContainerSelector"
|
2021-03-12 15:46:48 +08:00
|
|
|
OverlayEnterCls="ant-slide-up-enter ant-slide-up-enter-active ant-slide-up"
|
|
|
|
OverlayLeaveCls="ant-slide-up-leave ant-slide-up-leave-active ant-slide-up">
|
2020-09-09 22:12:12 +08:00
|
|
|
<Overlay>
|
|
|
|
<div style="@_dropdownStyle">
|
2020-11-27 13:13:26 +08:00
|
|
|
@if (SelectOptions != null)
|
|
|
|
{
|
2021-09-10 19:06:50 +08:00
|
|
|
<div class="" style="max-height: @PopupContainerMaxHeight; overflow-y: auto;" @ref="_scrollableSelectDiv">
|
2020-11-27 13:13:26 +08:00
|
|
|
<div>
|
2023-08-19 22:04:11 +08:00
|
|
|
<div class="" role="listbox" style="@ListboxStyle">
|
2021-02-04 23:40:47 +08:00
|
|
|
@if (CustomTagSelectOptionItem != null)
|
|
|
|
{
|
|
|
|
<CascadingValue Value="@ItemTemplate" Name="ItemTemplate">
|
|
|
|
<CascadingValue Value="@CustomTagSelectOptionItem" Name="Model">
|
|
|
|
<SelectOption
|
|
|
|
@key="@CustomTagSelectOptionItem.InternalId"
|
|
|
|
TItemValue="TItemValue"
|
|
|
|
TItem="TItem">
|
|
|
|
</SelectOption>
|
|
|
|
</CascadingValue>
|
|
|
|
</CascadingValue>
|
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
@SelectOptions
|
2021-02-04 23:40:47 +08:00
|
|
|
@if (AddedTags != null)
|
|
|
|
{
|
|
|
|
foreach (var selectOption in AddedTags)
|
|
|
|
{
|
|
|
|
<CascadingValue Value="@ItemTemplate" Name="ItemTemplate">
|
|
|
|
<CascadingValue Value="@selectOption" Name="Model">
|
|
|
|
<SelectOption
|
|
|
|
@key="@selectOption.InternalId"
|
|
|
|
TItemValue="TItemValue"
|
|
|
|
TItem="TItem">
|
|
|
|
</SelectOption>
|
|
|
|
</CascadingValue>
|
|
|
|
</CascadingValue>
|
|
|
|
}
|
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
2023-03-11 13:04:56 +08:00
|
|
|
else if (SelectOptions == null && !AllOptionsHidden())
|
2020-11-27 13:13:26 +08:00
|
|
|
{
|
2022-03-02 16:27:42 +08:00
|
|
|
<div class="" style="max-height: @PopupContainerMaxHeight; overflow-y: auto;" @ref="_scrollableSelectDiv">
|
2020-11-27 13:13:26 +08:00
|
|
|
<div>
|
2023-08-19 22:04:11 +08:00
|
|
|
<div class="" role="listbox" style="@ListboxStyle">
|
2020-11-27 13:13:26 +08:00
|
|
|
@{
|
|
|
|
@if (!IsGroupingEnabled)
|
|
|
|
{
|
2022-09-01 17:50:27 +08:00
|
|
|
@selectOptionsRender((this, SortedSelectOptionItems, ItemTemplate))
|
2020-11-27 13:13:26 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<CascadingValue Value="@ItemTemplate" Name="ItemTemplate">
|
|
|
|
<SelectOptionGroup TItemValue="TItemValue" TItem="TItem"></SelectOptionGroup>
|
|
|
|
</CascadingValue>
|
|
|
|
}
|
2020-06-14 18:54:14 +08:00
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
</div>
|
2020-06-14 18:54:14 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-27 13:13:26 +08:00
|
|
|
}
|
|
|
|
@if (AllOptionsHidden())
|
2020-09-09 22:12:12 +08:00
|
|
|
{
|
|
|
|
<div role="listbox" id="@(Id)_list" class="@ClassPrefix-item-empty">
|
|
|
|
@if (NotFoundContent != null)
|
|
|
|
{
|
|
|
|
@NotFoundContent
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-27 13:13:26 +08:00
|
|
|
<Empty Simple Small/>
|
2020-09-09 22:12:12 +08:00
|
|
|
}
|
|
|
|
</div>
|
2020-11-27 13:13:26 +08:00
|
|
|
}
|
2020-09-19 09:15:16 +08:00
|
|
|
|
2020-09-09 22:12:12 +08:00
|
|
|
@if (DropdownRender != null)
|
2020-06-14 18:54:14 +08:00
|
|
|
{
|
2020-11-27 13:13:26 +08:00
|
|
|
@DropdownRender(default)
|
2020-06-14 18:54:14 +08:00
|
|
|
}
|
2020-11-27 13:13:26 +08:00
|
|
|
</div>
|
2020-09-09 22:12:12 +08:00
|
|
|
</Overlay>
|
2021-01-21 17:20:10 +08:00
|
|
|
<Unbound>
|
2021-04-04 01:53:25 +08:00
|
|
|
<CascadingValue Value="this" Name=@("ParentSelect") IsFixed>
|
2020-11-27 13:13:26 +08:00
|
|
|
<CascadingValue Value="@LabelTemplate" Name="ParentLabelTemplate">
|
2021-04-13 13:12:18 +08:00
|
|
|
<CascadingValue Value="@MaxTagPlaceholder" Name="ParentMaxTagPlaceholerTemplate">
|
|
|
|
<CascadingValue Value="@ShowSearchIcon" Name="ShowSearchIcon">
|
|
|
|
<CascadingValue Value="@ShowArrowIcon" Name="ShowArrowIcon">
|
2023-12-23 11:23:16 +08:00
|
|
|
<SelectContent Prefix="@ClassPrefix"
|
2021-04-13 13:12:18 +08:00
|
|
|
RefBack="@context"
|
|
|
|
@ref="_selectContent"
|
|
|
|
TItemValue="TItemValue"
|
|
|
|
TItem="TItem"
|
|
|
|
SearchValue="@_searchValue"
|
2023-12-23 11:23:16 +08:00
|
|
|
SearchDebounceMilliseconds="@SearchDebounceMilliseconds"
|
2021-04-13 13:12:18 +08:00
|
|
|
IsOverlayShow="@_dropDown.IsOverlayShow()"
|
2023-12-23 11:23:16 +08:00
|
|
|
MaxTagCount="@_maxTagCountAsInt"
|
2021-04-13 13:12:18 +08:00
|
|
|
OnInput="@OnInputAsync"
|
|
|
|
OnKeyUp="@OnKeyUpAsync"
|
|
|
|
OnKeyDown="@OnKeyDownAsync"
|
|
|
|
OnFocus="@OnInputFocusAsync"
|
|
|
|
OnBlur="@OnInputBlurAsync"
|
2022-02-13 22:45:08 +08:00
|
|
|
OnClearClick="@OnInputClearClickAsync"
|
2021-04-13 13:12:18 +08:00
|
|
|
OnRemoveSelected="@OnRemoveSelectedAsync"
|
2023-12-25 23:18:39 +08:00
|
|
|
Placeholder="@Placeholder" />
|
2021-04-13 13:12:18 +08:00
|
|
|
</CascadingValue>
|
2020-11-27 13:13:26 +08:00
|
|
|
</CascadingValue>
|
|
|
|
</CascadingValue>
|
|
|
|
</CascadingValue>
|
2020-09-09 22:12:12 +08:00
|
|
|
</CascadingValue>
|
2021-01-21 17:20:10 +08:00
|
|
|
</Unbound>
|
2020-09-09 22:12:12 +08:00
|
|
|
</OverlayTrigger>
|
|
|
|
</CascadingValue>
|
2020-06-14 18:54:14 +08:00
|
|
|
</CascadingValue>
|
2022-09-01 17:50:27 +08:00
|
|
|
|
|
|
|
@code
|
|
|
|
{
|
|
|
|
static RenderFragment<(Select<TItemValue, TItem> select, IEnumerable<SelectOptionItem<TItemValue, TItem>> selectOptionItems, RenderFragment<TItem> itemTemplate)> selectOptionsRender = ctx =>
|
|
|
|
@<Template>
|
|
|
|
@{ #if NET5_0_OR_GREATER }
|
|
|
|
@if(ctx.select.EnableVirtualization)
|
|
|
|
{
|
|
|
|
<Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize
|
|
|
|
Items=@(ctx.selectOptionItems is ICollection<SelectOptionItem<TItemValue, TItem>> optionsCollection ? optionsCollection : ctx.selectOptionItems.ToList())
|
|
|
|
ChildContent="optionRender(ctx.itemTemplate)"/>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
<ForeachLoop
|
|
|
|
Items=@(ctx.selectOptionItems is ICollection<SelectOptionItem<TItemValue, TItem>> optionsCollection ? optionsCollection : ctx.selectOptionItems.ToList())
|
|
|
|
ChildContent="optionRender(ctx.itemTemplate)"/>
|
|
|
|
#if NET5_0_OR_GREATER
|
|
|
|
}
|
|
|
|
@{ #endif }
|
|
|
|
</Template>;
|
|
|
|
|
|
|
|
static Func<RenderFragment<TItem>, RenderFragment<SelectOptionItem<TItemValue, TItem>>> optionRender =
|
|
|
|
itemTemplate => option =>
|
|
|
|
@<CascadingValue Value=@itemTemplate Name="ItemTemplate">
|
|
|
|
<CascadingValue Value="@option.InternalId" Name="InternalId">
|
|
|
|
<SelectOption @key="@option.InternalId"
|
|
|
|
TItemValue="TItemValue"
|
|
|
|
TItem="TItem">
|
|
|
|
</SelectOption>
|
|
|
|
</CascadingValue>
|
|
|
|
</CascadingValue>;
|
|
|
|
}
|