@page "/table/row"
@inject IStringLocalizer<NavMenu> NavMenuLocalizer
@inject IStringLocalizer<TablesRow> Localizer
@inject IStringLocalizer<Foo> FooLocalizer
@inject ToastService ToastService

<h3>@Localizer["TablesRowTitle"] - @NavMenuLocalizer["TableRow"]</h3>

<h4>@Localizer["TablesRowDesc"]</h4>

<DemoBlock Title="@Localizer["RowNumberTitle"]"
           Introduction="@Localizer["RowNumberIntro"]"
           Name="LineNoText">
    <section ignore>@((MarkupString)Localizer["RowNumberP"].Value)</section>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="true" ShowLineNo="true" LineNoText="@Localizer["RowNumberText"]"
           ShowDefaultButtons="false" ClickToSelect="true"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["ClickToSelectTitle"]"
           Introduction="@Localizer["ClickToSelectIntro"]"
           Name="ClickToSelect">
    <section ignore>
        <p>@((MarkupString)Localizer["ClickToSelectP"].Value)</p>
        <p>@((MarkupString)Localizer["ClickToSelectP2"].Value)</p>
    </section>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="true"
           ShowDefaultButtons="false" ClickToSelect="true" OnClickRowCallback="@ClickRow"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
    </Table>

    <p>@((MarkupString)Localizer["ClickToSelectP3"].Value) @(CurrentItem?.Name ?? Localizer["ClickToSelectNoneText"])</p>
</DemoBlock>

<DemoBlock Title="@Localizer["DoubleClickToEditTitle"]"
           Introduction="@Localizer["DoubleClickToEditIntro"]"
           Name="DoubleClickToEdit">
    <section ignore>
        <p>@((MarkupString)Localizer["DoubleClickToEditP"].Value)</p>
        <p>@((MarkupString)Localizer["DoubleClickToEditP1"].Value)</p>
    </section>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="true" ShowDeleteButton="false"
           ClickToSelect="true" DoubleClickToEdit="true"
           OnQueryAsync="@OnQueryAsync" OnAddAsync="@OnAddAsync" OnSaveAsync="@OnSaveAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
        <EditTemplate>
            <div class="row g-3">
                <div class="col-12 col-sm-6">
                    <BootstrapInput @bind-Value="@context.Name" placeholder="@Localizer["PlaceHolder"].Value" maxlength="50">
                    </BootstrapInput>
                </div>
                <div class="col-12 col-sm-6">
                    <BootstrapInput @bind-Value="@context.Address" placeholder="@Localizer["PlaceHolder"].Value" maxlength="50">
                    </BootstrapInput>
                </div>
                <div class="col-12 col-sm-6">
                    <DateTimePicker @bind-Value="@context.DateTime">
                    </DateTimePicker>
                </div>
                <div class="col-12 col-sm-6">
                    <BootstrapInput @bind-Value="@context.Count">
                    </BootstrapInput>
                </div>
            </div>
        </EditTemplate>
    </Table>

</DemoBlock>

<DemoBlock Title="@Localizer["DoubleClickRowCallbackTitle"]"
           Introduction="@Localizer["DoubleClickRowCallbackIntro"]"
           Name="DoubleClickRowCallback">
    <section ignore>@Localizer["DoubleClickRowCallbackP"]</section>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="true"
           ShowDefaultButtons="false" OnDoubleClickRowCallback="@DoubleClickRowCallback"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["SetRowClassFormatterTitle"]"
           Introduction="@Localizer["SetRowClassFormatterIntro"]"
           Name="SetRowClassFormatter">
    <section ignore>
        <p>@((MarkupString)Localizer["SetRowClassFormatterP"].Value)</p>
        <Pre>.row-highlight {
    --bs-table-striped-bg: #409eff;
    --bs-table-bg: #409eff;
    --bs-table-hover-bg: #409eff;
    --bs-table-striped-color: #fff;
    --bs-table-color-state: #fff;
    --bs-table-hover-color: #fff;
}</Pre>
    </section>

    <Table TItem="Foo" SetRowClassFormatter="@SetRowClassFormatter"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="true"
           ShowDefaultButtons="false" OnDoubleClickRowCallback="@DoubleClickRowCallback"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["RowTemplateTitle"]"
           Introduction="@Localizer["RowTemplateIntro"]"
           Name="RowTemplate">
    <Table TItem="Foo" IsPagination="true" PageItemsSource="@PageItemsSource" class="table-row-template"
           IsStriped="true" IsBordered="true"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
        <RowTemplate>
            <MergeTableRow Context="@context"></MergeTableRow>
        </RowTemplate>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["RowContentTemplateTitle"]"
           Introduction="@Localizer["RowContentTemplateIntro"]"
           Name="RowContentTemplate">
    <section ignore>@((MarkupString)Localizer["RowContentTemplateDesc"].Value)</section>

    <Table TItem="Foo" IsPagination="true" PageItemsSource="@PageItemsSource" class="table-row-template"
           IsStriped="true" IsBordered="true"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
        <RowContentTemplate>
            <CustomTableRow Context="@context" OnValueChanged="UpdateRowValue"></CustomTableRow>
        </RowContentTemplate>
    </Table>
</DemoBlock>
