2026-10-03 12:01:42 +02:00
|
|
|
@typeparam TValue
|
|
|
|
|
@inherits DInputBase<TValue>
|
|
|
|
|
|
|
|
|
|
@* daisyUI Range: https://daisyui.com/components/range/ . TValue is numeric; Min and Max are always rendered, as daisyUI
|
|
|
|
|
requires. *@
|
2026-10-03 12:43:07 +02:00
|
|
|
<input @attributes="InputAttributes" type="range" class="@CssClassFull" name="@NameAttribute" min="@Format(Min)"
|
2026-10-03 12:01:42 +02:00
|
|
|
max="@Format(Max)" step="@(Step is null ? null : Format(Step.Value))" value="@CurrentValueAsString"
|
|
|
|
|
@oninput="OnInput" @onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)" />
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
[Parameter] public double Min { get; set; }
|
|
|
|
|
[Parameter] public double Max { get; set; } = 100;
|
|
|
|
|
[Parameter] public double? Step { get; set; }
|
|
|
|
|
[Parameter] public DColor Color { get; set; }
|
|
|
|
|
[Parameter] public DSize Size { get; set; }
|
|
|
|
|
[Parameter] public DDirection Direction { get; set; }
|
|
|
|
|
/// <summary>Update the bound value while dragging instead of on release.</summary>
|
|
|
|
|
[Parameter] public bool Immediate { get; set; }
|
|
|
|
|
|
|
|
|
|
string CssClassFull => Cx("range", IsInvalid ? "range-error" : ColorClass, SizeClass,
|
|
|
|
|
Direction == DDirection.Vertical ? "range-vertical" : null, CssClass);
|
|
|
|
|
|
|
|
|
|
string ColorClass => Color switch
|
|
|
|
|
{
|
|
|
|
|
DColor.Neutral => "range-neutral",
|
|
|
|
|
DColor.Primary => "range-primary",
|
|
|
|
|
DColor.Secondary => "range-secondary",
|
|
|
|
|
DColor.Accent => "range-accent",
|
|
|
|
|
DColor.Info => "range-info",
|
|
|
|
|
DColor.Success => "range-success",
|
|
|
|
|
DColor.Warning => "range-warning",
|
|
|
|
|
DColor.Error => "range-error",
|
|
|
|
|
_ => null
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
string SizeClass => Size switch
|
|
|
|
|
{
|
|
|
|
|
DSize.Xs => "range-xs",
|
|
|
|
|
DSize.Sm => "range-sm",
|
|
|
|
|
DSize.Lg => "range-lg",
|
|
|
|
|
DSize.Xl => "range-xl",
|
|
|
|
|
_ => null
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static string Format(double value) => value.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
|
|
|
|
|
|
|
|
|
void OnInput(ChangeEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Immediate)
|
|
|
|
|
CurrentValueAsString = e.Value?.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnChange(ChangeEventArgs e) => CurrentValueAsString = e.Value?.ToString();
|
|
|
|
|
}
|