@namespace Connected.Components
@typeparam T
@inherits DebouncedInput<T>

@using System.Globalization;

<CascadingValue Name="SubscribeToParentForm" Value="@SubscribeToParentForm" IsFixed="true">
    <InputControl id="@_elementId"
                     Label="@Label"
                     Variant="@Variant"
                     HelperText="@HelperText"
                     HelperTextOnFocus="@HelperTextOnFocus"
                     FullWidth="@FullWidth"
                     Class="@Classname"
                     Error="@HasErrors"
                     ErrorText="@GetErrorText()"
                     Disabled="@Disabled"
                     Margin="@Margin"
                     Required="@Required"
                     CounterText="@GetCounterText()"
                     ForId="@FieldId">
        <InputContent>
            <CascadingValue Name="SubscribeToParentForm" Value="false" IsFixed="true">
                <Input T="string"
                          @ref="@_elementReference"
                          @attributes="@CustomAttributes"
                          InputType="@InputType.Text"
                          Variant="@Variant"
                          TextUpdateSuppression="@TextUpdateSuppression"
                          Value="@Text"
                          ValueChanged="@OnInputValueChanged"
                          Placeholder="@Placeholder"
                          Disabled="@Disabled"
                          DisableUnderLine="@DisableUnderLine"
                          ReadOnly="@ReadOnly"
                          Adornment="@Adornment"
                          AdornmentText="@AdornmentText"
                          AdornmentIcon="@AdornmentIcon"
                          AdornmentColor="@AdornmentColor"
                          IconSize="@IconSize"
                          Error="@HasError"
                          Immediate="@(Immediate)"
                          Margin="@Margin"
                          MaxLength="@MaxLength"
                          HideSpinButtons="@HideSpinButtons"
                          min="@(_minHasValue ? FormatParam(_min) : null)"
                          max="@(_maxHasValue ? FormatParam(_max) : null)"
                          step="@(_stepHasValue ? FormatParam(_step) : null)"
                          InputMode="@InputMode"
                          Pattern="@((Pattern ?? "[0-9]").TrimEnd('*')+"*")"
                          OnAdornmentClick="@OnAdornmentClick"
                          OnBlur="@OnBlurred"
                          OnKeyDown="@HandleKeydown"
                          OnKeyUp="@HandleKeyUp"
                          OnIncrement="@Increment"
                          OnDecrement="@Decrement"
                          OnMouseWheel="@OnMouseWheel"
                          Clearable="@Clearable" />
            </CascadingValue>
        </InputContent>
    </InputControl>
</CascadingValue>
