You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
5.6 KiB
145 lines
5.6 KiB
@namespace Connected.Components
|
|
@typeparam T
|
|
@inherits InputBase<T>
|
|
|
|
<div class="@Classname" style="@Style">
|
|
@if (Adornment == Adornment.Start)
|
|
{
|
|
<InputAdornment Class="@AdornmentClassname"
|
|
Icon="@AdornmentIcon"
|
|
Color="@AdornmentColor"
|
|
Size="@IconSize"
|
|
Text="@AdornmentText"
|
|
Edge="@Edge.Start"
|
|
AdornmentClick="@OnAdornmentClick"
|
|
AriaLabel="@AdornmentAriaLabel"
|
|
/>
|
|
}
|
|
|
|
@if (Lines > 1)
|
|
{
|
|
<textarea class="@InputClassname"
|
|
@ref="ElementReference"
|
|
rows="@Lines"
|
|
@attributes="UserAttributes"
|
|
type="@InputTypeString"
|
|
placeholder="@Placeholder"
|
|
disabled=@Disabled
|
|
readonly="@ReadOnly"
|
|
inputmode="@InputMode.ToString()"
|
|
@oninput="OnInput"
|
|
@onchange="OnChange"
|
|
@onblur="@OnBlurred"
|
|
@onkeydown="@InvokeKeyDown"
|
|
@onkeypress="@InvokeKeyPress"
|
|
@onkeyup="@InvokeKeyUp"
|
|
@onpaste="@OnPaste"
|
|
value="@_internalText"
|
|
maxlength="@MaxLength"
|
|
@onkeydown:preventDefault="@KeyDownPreventDefault"
|
|
@onkeypress:preventDefault="@KeyPressPreventDefault"
|
|
@onkeyup:preventDefault="@KeyUpPreventDefault"
|
|
@onmousewheel="@OnMouseWheel"
|
|
@onwheel="@OnMouseWheel"
|
|
aria-invalid="@Error.ToString().ToLower()"
|
|
aria-describedby="@ErrorId"
|
|
>
|
|
@Text
|
|
</textarea>
|
|
@*Note: double mouse wheel handlers needed for Firefox because it doesn't know onmousewheel*@
|
|
@*note: the value="@_internalText" is absolutely essential here. the inner html @Text is needed by tests checking it*@
|
|
}
|
|
else
|
|
{
|
|
<input class="@InputClassname"
|
|
@ref="ElementReference"
|
|
@attributes="UserAttributes"
|
|
type="@InputTypeString"
|
|
value="@_internalText"
|
|
@oninput="OnInput"
|
|
@onchange="OnChange"
|
|
placeholder="@Placeholder"
|
|
disabled=@Disabled
|
|
readonly="@ReadOnly"
|
|
@onblur="@OnBlurred"
|
|
inputmode="@InputMode.ToString()"
|
|
pattern="@Pattern"
|
|
@onkeydown="@InvokeKeyDown"
|
|
@onkeypress="@InvokeKeyPress"
|
|
@onkeyup="@InvokeKeyUp"
|
|
maxlength="@MaxLength"
|
|
@onkeydown:preventDefault="KeyDownPreventDefault"
|
|
@onkeypress:preventDefault="@KeyPressPreventDefault"
|
|
@onkeyup:preventDefault="@KeyUpPreventDefault"
|
|
@onmousewheel="@OnMouseWheel"
|
|
@onwheel="@OnMouseWheel"
|
|
aria-invalid="@Error.ToString().ToLower()"
|
|
aria-describedby="@ErrorId"
|
|
/>
|
|
@*Note: double mouse wheel handlers needed for Firefox because it doesn't know onmousewheel*@
|
|
|
|
@if (Disabled) {
|
|
@*Note: this div must always be there to avoid crashes in WASM, but it is hidden most of the time except if ChildContent should be shown.
|
|
In Disabled state the tabindex attribute must NOT be set at all or else it will get focus on click
|
|
*@
|
|
<div class="@InputClassname"
|
|
style="@("display:"+(InputType == InputType.Hidden && ChildContent != null ? "inline" : "none"))"
|
|
@onblur="@OnBlurred" @ref="@_elementReference1"
|
|
>
|
|
@ChildContent
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
@*Note: this div must always be there to avoid crashes in WASM, but it is hidden most of the time except if ChildContent should be shown.*@
|
|
<div class="@InputClassname"
|
|
style="@("display:"+(InputType == InputType.Hidden && ChildContent != null ? "inline" : "none"))"
|
|
tabindex="@(InputType == InputType.Hidden && ChildContent != null ? 0 : -1)"
|
|
@onblur="@OnBlurred" @ref="@_elementReference1"
|
|
>
|
|
@ChildContent
|
|
</div>
|
|
}
|
|
}
|
|
|
|
@if (_showClearable && !Disabled)
|
|
{
|
|
<IconButton Class="@ClearButtonClassname"
|
|
Color="@ThemeColor.Default"
|
|
Icon="@ClearIcon"
|
|
Size="@Size.Small"
|
|
OnClick="@ClearButtonClickHandlerAsync"
|
|
tabindex="-1"
|
|
/>
|
|
}
|
|
|
|
@if (Adornment == Adornment.End)
|
|
{
|
|
<InputAdornment Class="@AdornmentClassname"
|
|
Icon="@AdornmentIcon"
|
|
Color="@AdornmentColor"
|
|
Size="@IconSize"
|
|
Text="@AdornmentText"
|
|
Edge="@Edge.End"
|
|
AdornmentClick="@OnAdornmentClick"
|
|
AriaLabel="@AdornmentAriaLabel"
|
|
/>
|
|
}
|
|
|
|
@if (Variant == Variant.Outlined)
|
|
{
|
|
<div class="mud-input-outlined-border"></div>
|
|
}
|
|
|
|
@if (!HideSpinButtons)
|
|
{
|
|
<div class="mud-input-numeric-spin">
|
|
<Button Variant="Variant.Text" @onclick="OnIncrement" Disabled="@(Disabled || ReadOnly)" tabindex="-1">
|
|
<Icon Icon="@NumericUpIcon" Size="@GetButtonSize()" />
|
|
</Button>
|
|
<Button Variant="Variant.Text" @onclick="OnDecrement" Disabled="@(Disabled || ReadOnly)" tabindex="-1">
|
|
<Icon Icon="@NumericDownIcon" Size="@GetButtonSize()" />
|
|
</Button>
|
|
</div>
|
|
}
|
|
</div> |