mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-14 17:01:18 +08:00
d64388c0ab
* feat(module:select): add MaxTagTextLength, MaxTagCount & MaxTagPlaceHolder * feat(module:select): responsive maxTagCount using window.resize * docs(module:select): MaxTagCount functionality * fix docs Co-authored-by: ElderJames <shunjiey@hotmail.com>
189 lines
5.0 KiB
C#
189 lines
5.0 KiB
C#
using System;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign.Select.Internal
|
|
{
|
|
/// <summary>
|
|
/// The data model for a SelectOption that is used internally.
|
|
/// </summary>
|
|
/// <typeparam name="TItemValue"></typeparam>
|
|
/// <typeparam name="TItem"></typeparam>
|
|
public class SelectOptionItem<TItemValue, TItem>
|
|
{
|
|
public ElementReference Ref { get => ChildComponent.Ref; }
|
|
//public ForwardRef SelectedTagRefBack { get; set; } = new ForwardRef();
|
|
|
|
/// <summary>
|
|
/// ElementRef that will be used by <see cref="SelectContent.razor"/> only
|
|
/// for selected Mode=Multiple & MaxTagCount=Responsive
|
|
/// </summary>
|
|
public ElementReference SelectedTagRef { get; set; }
|
|
|
|
internal decimal Width { get; set; } //TODO: rename tp Width
|
|
|
|
public Guid InternalId { get; set; } = Guid.NewGuid();
|
|
|
|
private TItemValue _value;
|
|
public TItemValue Value
|
|
{
|
|
get => _value;
|
|
set
|
|
{
|
|
_value = value;
|
|
}
|
|
}
|
|
|
|
private TItem _item;
|
|
public TItem Item
|
|
{
|
|
get => _item;
|
|
set
|
|
{
|
|
_item = value;
|
|
}
|
|
}
|
|
|
|
private string _label = string.Empty;
|
|
|
|
public string Label
|
|
{
|
|
get => _label;
|
|
set
|
|
{
|
|
if (string.IsNullOrEmpty(value))
|
|
{
|
|
_label = value;
|
|
|
|
if (ChildComponent != null)
|
|
ChildComponent.InternalLabel = value;
|
|
}
|
|
else
|
|
{
|
|
if (!_label.Equals(value, StringComparison.InvariantCulture))
|
|
{
|
|
_label = value;
|
|
|
|
if (ChildComponent != null)
|
|
ChildComponent.InternalLabel = value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private string _groupName = string.Empty;
|
|
|
|
public string GroupName
|
|
{
|
|
get => _groupName;
|
|
set
|
|
{
|
|
if (string.IsNullOrEmpty(value))
|
|
{
|
|
_groupName = value;
|
|
|
|
if (ChildComponent != null)
|
|
ChildComponent.GroupName = value;
|
|
}
|
|
else
|
|
{
|
|
if (!_groupName.Equals(value, StringComparison.InvariantCulture))
|
|
{
|
|
_groupName = value;
|
|
|
|
if (ChildComponent != null)
|
|
ChildComponent.GroupName = value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool _isSelected;
|
|
public bool IsSelected
|
|
{
|
|
get => _isSelected;
|
|
set
|
|
{
|
|
if (_isSelected != value)
|
|
{
|
|
_isSelected = value;
|
|
|
|
if (ChildComponent != null)
|
|
ChildComponent.IsSelected = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool _isActive;
|
|
public bool IsActive
|
|
{
|
|
get => _isActive;
|
|
set
|
|
{
|
|
if (_isActive != value)
|
|
{
|
|
_isActive = value;
|
|
|
|
if (ChildComponent != null)
|
|
ChildComponent.IsActive = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool _isDisabled;
|
|
public bool IsDisabled
|
|
{
|
|
get => _isDisabled;
|
|
set
|
|
{
|
|
if (_isDisabled != value)
|
|
{
|
|
_isDisabled = value;
|
|
|
|
if (ChildComponent != null)
|
|
ChildComponent.IsDisabled = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool _isHidden;
|
|
public bool IsHidden
|
|
{
|
|
get => _isHidden;
|
|
set
|
|
{
|
|
if (_isHidden != value)
|
|
{
|
|
_isHidden = value;
|
|
|
|
if (ChildComponent != null)
|
|
ChildComponent.IsHidden = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public bool IsAddedTag { get; set; }
|
|
|
|
private SelectOption<TItemValue, TItem> _childComponent;
|
|
|
|
public SelectOption<TItemValue, TItem> ChildComponent
|
|
{
|
|
get => _childComponent;
|
|
set
|
|
{
|
|
if (value != null)
|
|
{
|
|
_childComponent = value;
|
|
_childComponent.Model = this;
|
|
_childComponent.IsActive = _isActive;
|
|
_childComponent.IsSelected = _isSelected;
|
|
_childComponent.IsHidden = _isHidden;
|
|
_childComponent.IsDisabled = _isDisabled;
|
|
_childComponent.InternalLabel = _label;
|
|
_childComponent.GroupName = _groupName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|