@namespace Connected.Components
@inherits UIComponent
@typeparam T

<th scope="col" class="@_classname" style="@_style" colspan="@Column?.HeaderColSpan" @attributes="@CustomAttributes">
    @if (null != Column && Column.filterable)
    {
        @if (Column.FilterTemplate != null)
        {
            @Column.FilterTemplate(Column.filterContext) 
        }
        else
        {
            <Stack Row="true">
                @if (dataType == typeof(string) && !(_operator ?? "").EndsWith("empty"))
                {
                    <TextField T="string" Value="@_valueString" ValueChanged="@StringValueChanged" FullWidth="true" Placeholder="Filter value" Margin="@Margin.Dense" Immediate="true" />
                }
                else if (isNumber && !(_operator ?? "").EndsWith("empty"))
                {
                    <NumericField T="double?" Culture="@Column.Culture" Value="@_valueNumber" ValueChanged="@NumberValueChanged" FullWidth="true" Placeholder="Filter value" Margin="@Margin.Dense" Immediate="true"></NumericField>
                }
                else if (isEnum)
                {
                    <Select T="Enum" Value="@_valueEnum" ValueChanged="@EnumValueChanged" FullWidth="true" Dense="true" Margin="@Margin.Dense">
                        <SelectItem T="Enum" Value="@(null)"></SelectItem>
                        @foreach (var item in Enum.GetValues(dataType))
                        {
                            <SelectItem T="Enum" Value="@((Enum)item)">@item</SelectItem>
                        }
                    </Select>
                }
                else if (dataType == typeof(bool))
                {
                    <Select T="bool?" Value="@_valueBool" ValueChanged="@BoolValueChanged" FullWidth="true" Dense="true" Margin="@Margin.Dense">
                        <SelectItem T="bool?" Value="@(null)"></SelectItem>
                        <SelectItem T="bool?" Value="@(true)">true</SelectItem>
                        <SelectItem T="bool?" Value="@(false)">false</SelectItem>
                    </Select>
                }
                else if (dataType == typeof(DateTime) && !(_operator ?? "").EndsWith("empty"))
                {
                    <Grid Spacing="0">
                        <Item xs="7">
                            <DatePicker Date="@_valueDate" DateChanged="@DateValueChanged" Margin="@Margin.Dense" />
                        </Item>
                        <Item xs="5">
                            <TimePicker Time="@_valueTime" TimeChanged="@TimeValueChanged" Margin="@Margin.Dense" />
                        </Item>
                    </Grid>
                }
                <Menu Icon="@Icons.Material.Filled.FilterAlt" Size="@Size.Small" Dense="true">
                    @foreach (var o in operators)
                    {
                        if (!string.IsNullOrWhiteSpace(o))
                        {
                            <MenuItem Style="@chosenOperatorStyle(o)" OnClick="@(() => ChangeOperator(o))">@o</MenuItem>
                        }
                    }
                </Menu>
            <GlyphButton Class="align-self-center" Icon="@Icons.Material.Filled.FilterAltOff" Size="@Size.Small" Clicked="@ClearFilter"></GlyphButton>
            </Stack>
        }
    }
</th>
