53 lines
1.4 KiB
Plaintext
53 lines
1.4 KiB
Plaintext
@using MudBlazor
|
|
|
|
<MudDialog>
|
|
<TitleContent>
|
|
<MudText Typo="Typo.h6">Create New Folder</MudText>
|
|
</TitleContent>
|
|
<DialogContent>
|
|
<MudTextField @bind-Value="FolderName"
|
|
Label="Folder Name"
|
|
Placeholder="Enter folder name"
|
|
Required="true"
|
|
RequiredError="Folder name is required"
|
|
Variant="Variant.Outlined"
|
|
FullWidth="true"
|
|
@onkeydown="HandleKeyDown" />
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<MudButton OnClick="Cancel">Cancel</MudButton>
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="Submit">Create</MudButton>
|
|
</DialogActions>
|
|
</MudDialog>
|
|
|
|
@code {
|
|
[CascadingParameter] IMudDialogInstance Dialog { get; set; } = null!;
|
|
|
|
private string FolderName { get; set; } = string.Empty;
|
|
|
|
private void Cancel() => Dialog.Cancel();
|
|
|
|
private void Submit()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(FolderName))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Dialog.Close(DialogResult.Ok(FolderName.Trim()));
|
|
}
|
|
|
|
private void HandleKeyDown(KeyboardEventArgs e)
|
|
{
|
|
if (e.Key == "Enter")
|
|
{
|
|
Submit();
|
|
}
|
|
else if (e.Key == "Escape")
|
|
{
|
|
Cancel();
|
|
}
|
|
}
|
|
}
|
|
|