ant-design-blazor/components/slider/Slider.razor
agolub-s 8e60219b35
feat(module: datepicker): add mask to DatePickerBase for input value constraint (#3120)
* Add support multiple date formats for DatePickerBase

* Fix test

* Extend docs

* Fix merge

* Revert "Add support multiple date formats for DatePickerBase"

This reverts commit 9021dcdd

* Refactoring. Add mask property for DatePickerBase. For input value constraint.

* Some fixes

* Refactoring

* Add value converter for MaskInput

* Some fix

* fix Chinese

* Refactoring

* Fix tests

* Fix tests

* clean up

* Fix tests

* Pass mask to RangePicker

* Fix AvatarTests

* Fix merge

* Stage

* Stabilized tests

---------

Co-authored-by: James Yeung <shunjiey@hotmail.com>
2023-10-05 17:24:16 +08:00

78 lines
5.2 KiB
C#

@namespace AntDesign
@typeparam TValue
@inherits AntInputComponentBase<TValue>
@using Microsoft.AspNetCore.Components.Web
@using System.Globalization
<div class="@ClassMapper.Class" style="user-select:none;@Style" id="@Id" @ref="Ref"
@onmousedown="(e) => OnMouseDown(e)">
<div class="ant-slider-rail">
</div>
@if (Included)
{
<div class="ant-slider-track @(Range ? "ant-slider-track-1" : string.Empty)" style="@_trackStyle">
</div>
}
<div class="ant-slider-step">
@if (Marks != null)
{
@foreach (SliderMark mark in Marks)
{
<span class="ant-slider-dot @(IsActiveMark(mark.Key) ? "ant-slider-dot-active" : string.Empty)" style=@($"{(Vertical ? "bottom" : "left")}: {SetMarkPosition(mark.Key)};")></span>
}
}
</div>
@if (Range)
{
@if (HasTooltip)
{
<Tooltip Title="@TipFormatter(_leftValue)" Style="display: inline;" Visible="_tooltipLeftVisible" ArrowPointAtCenter="true" OverlayClassName="ant-slider-tooltip" Placement="@TooltipPlacement" @ref="_toolTipLeft">
<Unbound>
<div tabindex="0" class="ant-slider-handle ant-slider-handle-1" role="slider" aria-disabled="@Disabled.ToString()" aria-valuenow=@(Math.Round(LeftValue, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemin=@(Math.Round(Min, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemax=@(Math.Round(Max, 2).ToString(CultureInfo.InvariantCulture)) style="@_leftHandleStyle" @ref="@context.Current" @onmousedown="(e) => OnMouseDownEdge(e, false)">
</div>
</Unbound>
</Tooltip>
<Tooltip Title="@TipFormatter(_rightValue)" Style="display: inline;" Visible="_tooltipRightVisible" ArrowPointAtCenter="true" OverlayClassName="ant-slider-tooltip" Placement="@TooltipPlacement" @ref="_toolTipRight">
<Unbound>
<div tabindex="0" class="ant-slider-handle ant-slider-handle-2" role="slider" aria-disabled="@Disabled.ToString()" aria-valuenow=@(Math.Round(RightValue, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemin=@(Math.Round(Min, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemax=@(Math.Round(Max, 2).ToString(CultureInfo.InvariantCulture)) style="@_rightHandleStyle" @ref="@context.Current" @onmousedown="(e) => OnMouseDownEdge(e, true)">
</div>
</Unbound>
</Tooltip>
}
else
{
<div tabindex="0" class="ant-slider-handle ant-slider-handle-1" role="slider" aria-disabled="@Disabled.ToString()" aria-valuenow=@(Math.Round(LeftValue, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemin=@(Math.Round(Min, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemax=@(Math.Round(Max, 2).ToString(CultureInfo.InvariantCulture)) style="@_leftHandleStyle" @ref="_leftHandle" @onmousedown="(e) => OnMouseDownEdge(e, false)">
</div>
<div tabindex="0" class="ant-slider-handle ant-slider-handle-2" role="slider" aria-disabled="@Disabled.ToString()" aria-valuenow=@(Math.Round(RightValue, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemin=@(Math.Round(Min, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemax=@(Math.Round(Max, 2).ToString(CultureInfo.InvariantCulture)) style="@_rightHandleStyle" @ref="_rightHandle" @onmousedown="(e) => OnMouseDownEdge(e, true)">
</div>
}
}
else
{
@if (HasTooltip)
{
<Tooltip Title="@TipFormatter(_rightValue)" Style="display: inline;" Visible="_tooltipRightVisible" ArrowPointAtCenter="true" OverlayClassName="ant-slider-tooltip" Placement="@TooltipPlacement" @ref="_toolTipRight">
<Unbound>
<div tabindex="0" class="ant-slider-handle" role="slider" aria-disabled="@Disabled.ToString()" aria-valuenow=@(Math.Round(RightValue, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemin=@(Math.Round(Min, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemax=@(Math.Round(Max, 2).ToString(CultureInfo.InvariantCulture)) style="@_rightHandleStyle" @ref="@context.Current" @onmousedown="(e)=>OnMouseDownEdge(e, true)">
</div>
</Unbound>
</Tooltip>
}
else
{
<div tabindex="0" class="ant-slider-handle" role="slider" aria-disabled="@Disabled.ToString()" aria-valuenow=@(Math.Round(RightValue, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemin=@(Math.Round(Min, 2).ToString(CultureInfo.InvariantCulture)) aria-valuemax=@(Math.Round(Max, 2).ToString(CultureInfo.InvariantCulture)) style="@_rightHandleStyle" @ref="_rightHandle" @onmousedown="(e)=>OnMouseDownEdge(e, true)">
</div>
}
}
<div class="ant-slider-mark">
@if (Marks != null)
{
@foreach (SliderMark mark in Marks)
{
<span class="ant-slider-mark-text @(IsActiveMark(mark.Key) ? "ant-slider-mark-text-active" : string.Empty)" style=@($"{(Vertical ? "bottom" : "left")}: {SetMarkPosition(mark.Key)}; {(Vertical ? "margin-bottom: -50%;" : "transform: translateX(-50%);")}" + mark.Style)>@mark.Value</span>
}
}
</div>
</div>