mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-11-29 10:38:18 +08:00
fix(module: cascader): style and class properties (#1269)
This commit is contained in:
parent
e5225afb05
commit
10b3346c4f
@ -3,7 +3,6 @@
|
||||
@inherits AntInputComponentBase<string>
|
||||
|
||||
<CascadingValue Value=@("ant-cascader-menus") Name="PrefixCls">
|
||||
<div class="@ClassMapper.Class" style="@Style" id="@Id" tabindex="-1" @ref="Ref">
|
||||
<OverlayTrigger Visible="@(ToggleState && _nodelist != null && _nodelist.Any())"
|
||||
ComplexAutoCloseAndVisible="true"
|
||||
Trigger="new[] { TriggerType.Click }"
|
||||
@ -11,9 +10,9 @@
|
||||
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">
|
||||
<Unbound>
|
||||
<span @ref="context.Current" class="ant-cascader-picker @_pickerSizeClass" tabindex="1" @onclick="InputOnToggle" @onblur="CascaderOnBlur" @onmouseover="InputOnMouseOver" @onmouseout="InputOnMouseOut">
|
||||
<span @ref="context.Current" style="@Style" id="@Id" class="@ClassMapper.Class" tabindex="1" @onclick="InputOnToggle" @onblur="CascaderOnBlur" @onmouseover="InputOnMouseOver" @onmouseout="InputOnMouseOut">
|
||||
<span class="ant-cascader-picker-label"></span>
|
||||
<input autocomplete="off" tabindex="-1" placeholder="@PlaceHolder" class="ant-input ant-cascader-input @_inputSizeClass" readonly="@Readonly" type="text" value="@_displayText">
|
||||
<input autocomplete="off" tabindex="-1" placeholder="@PlaceHolder" class="@_inputClassMapper.Class" readonly="@Readonly" type="text" value="@_displayText">
|
||||
@if (string.IsNullOrWhiteSpace(Value) || !ShowClearIcon)
|
||||
{
|
||||
<Icon Type="down" Class="@($"ant-cascader-picker-arrow {(ToggleState ? "ant-cascader-picker-arrow-expand" : string.Empty)}")" />
|
||||
@ -73,5 +72,4 @@
|
||||
</div>
|
||||
</Overlay>
|
||||
</OverlayTrigger>
|
||||
</div>
|
||||
</CascadingValue>
|
@ -77,7 +77,7 @@ namespace AntDesign
|
||||
else if (_nodelist.Count != 0) _nodelist.Clear();
|
||||
_nodelist.AddRange(value);
|
||||
|
||||
_optionsNeedInitialize = true;
|
||||
ProcessParentAndDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,9 +98,6 @@ namespace AntDesign
|
||||
/// </summary>
|
||||
internal List<CascaderNode> _renderNodes = new List<CascaderNode>();
|
||||
|
||||
private string _pickerSizeClass = string.Empty;
|
||||
private string _inputSizeClass = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 浮层 展开/折叠状态
|
||||
/// </summary>
|
||||
@ -117,36 +114,28 @@ namespace AntDesign
|
||||
/// </summary>
|
||||
private SelectedTypeEnum SelectedType { get; set; }
|
||||
|
||||
private ClassMapper _inputClassMapper = new ClassMapper();
|
||||
private string _displayText;
|
||||
private bool _optionsNeedInitialize;
|
||||
|
||||
private static Hashtable _sizeMap = new Hashtable()
|
||||
{
|
||||
["large"] = "lg",
|
||||
["small"] = "sm"
|
||||
};
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
base.OnParametersSet();
|
||||
ClassMapper.Add("ant-cascader-picker")
|
||||
.GetIf(() => $"ant-cascader-picker-{Size}", () => _sizeMap.ContainsKey(Size))
|
||||
.GetIf(() => $"ant-input-{_sizeMap[Size]}", () => _sizeMap.ContainsKey(Size))
|
||||
;
|
||||
|
||||
Hashtable sizeMap = new Hashtable()
|
||||
{
|
||||
["large"] = "lg",
|
||||
["small"] = "sm"
|
||||
};
|
||||
|
||||
if (sizeMap.ContainsKey(Size))
|
||||
{
|
||||
_pickerSizeClass = $"ant-cascader-picker-{Size}";
|
||||
_inputSizeClass = $"ant-input-{sizeMap[Size]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_pickerSizeClass = "";
|
||||
_inputSizeClass = "";
|
||||
}
|
||||
|
||||
ProcessParentAndDefault();
|
||||
_inputClassMapper
|
||||
.Add("ant-input")
|
||||
.Add("ant-cascader-input")
|
||||
.GetIf(() => $"ant-input-{_sizeMap[Size]}", () => _sizeMap.ContainsKey(Size));
|
||||
}
|
||||
|
||||
protected override void OnValueChange(string value)
|
||||
@ -310,13 +299,8 @@ namespace AntDesign
|
||||
/// </summary>
|
||||
private void ProcessParentAndDefault()
|
||||
{
|
||||
if (_optionsNeedInitialize)
|
||||
{
|
||||
_optionsNeedInitialize = false;
|
||||
|
||||
InitCascaderNodeState(_nodelist, null, 0);
|
||||
SetDefaultValue(Value ?? DefaultValue);
|
||||
}
|
||||
InitCascaderNodeState(_nodelist, null, 0);
|
||||
SetDefaultValue(Value ?? DefaultValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user