- @command.Icon
+
+ @((MarkupString)command.Icon)
}
-
@command.Title
+
@command.Title
@if (!string.IsNullOrEmpty(command.Description))
{
-
@command.Description
+
@command.Description
}
@if (!string.IsNullOrEmpty(command.Shortcut))
@@ -46,7 +45,7 @@
@foreach (var key in command.Shortcut.Split('+'))
{
-
+
@key
}
@@ -57,12 +56,12 @@
}
else
{
-
-
+
@code {
@@ -136,6 +135,19 @@
_searchQuery = "";
await IsOpenChanged.InvokeAsync(IsOpen);
}
+
+ private async Task HandleOpenChanged(bool isOpen)
+ {
+ if (!isOpen)
+ {
+ await CloseCommand();
+ }
+ else
+ {
+ IsOpen = isOpen;
+ await IsOpenChanged.InvokeAsync(isOpen);
+ }
+ }
private async Task OnKeyDown(KeyboardEventArgs e)
{
@@ -157,3 +169,4 @@
}
}
}
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/DatePicker.razor b/NET9/BlazorInteractiveServer/Components/UI/DatePicker.razor
index 67b6237..26fc5a7 100644
--- a/NET9/BlazorInteractiveServer/Components/UI/DatePicker.razor
+++ b/NET9/BlazorInteractiveServer/Components/UI/DatePicker.razor
@@ -1,128 +1,111 @@
@namespace BlazorInteractiveServer.Components.UI
-
-
-
- @(SelectedDate?.ToString("MMM dd, yyyy") ?? Placeholder)
-
-
- @if (AllowClear && SelectedDate.HasValue)
- {
-
-
-
-
-
- }
-
-
-
-
-
+
+
+
+
+ @(Value?.ToString("MMM dd, yyyy") ?? Placeholder)
+
+
+ @if (AllowClear && Value.HasValue && !Disabled)
+ {
+
+ }
+
+
+
+
+
+
- @if (_isOpen)
+ @if (IsOpen)
{
-
-
-
-
-
-
-
-
@_currentMonth.ToString("MMMM yyyy")
-
-
-
-
-
-
-
-
Su
-
Mo
-
Tu
-
We
-
Th
-
Fr
-
Sa
- @foreach (var day in GetCalendarDays())
- {
- @if (day.HasValue)
+
+
+
+
+
+
+
+
+
+
@currentMonth.ToString("MMMM yyyy")
+
+
+
+
+
+
+
+
Su
+
Mo
+
Tu
+
We
+
Th
+
Fr
+
Sa
+
+
+ @for (int i = 0; i < GetDaysInMonth(); i++)
{
+ var day = i + 1;
+ var date = new DateTime(currentMonth.Year, currentMonth.Month, day);
+ var isSelected = Value?.Date == date;
SelectDate(day.Value))"
- class="@("h-8 w-8 text-sm rounded-md hover:bg-accent " + (day.Value.Date == SelectedDate?.Date ? "bg-primary text-primary-foreground" : ""))">
- @day.Value.Day
+ @onclick="@(() => SelectDate(date))"
+ class="@Shell.Cn("h-9 w-9 rounded-md text-sm transition-colors hover:bg-accent hover:text-accent-foreground", isSelected ? "bg-primary text-primary-foreground" : "")">
+ @day
}
- else
- {
-
- }
- }
+
}
+@if (IsOpen)
+{
+
+}
+
@code {
- [Parameter]
- public DateTime? SelectedDate { get; set; }
-
- [Parameter]
- public EventCallback
SelectedDateChanged { get; set; }
-
- [Parameter]
- public string Placeholder { get; set; } = "Pick a date";
-
- [Parameter]
- public bool AllowClear { get; set; } = true;
-
- [Parameter]
- public bool Disabled { get; set; }
-
- [Parameter]
- public string ClassName { get; set; } = "";
-
+ [Parameter] public DateTime? Value { get; set; }
+ [Parameter] public EventCallback ValueChanged { get; set; }
+ [Parameter] public string Placeholder { get; set; } = "Pick a date";
+ [Parameter] public bool Disabled { get; set; }
+ [Parameter] public bool AllowClear { get; set; } = true;
+ [Parameter] public string? Class { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary? AdditionalAttributes { get; set; }
- private bool _isOpen;
- private DateTime _currentMonth = DateTime.Now;
+ private bool IsOpen { get; set; }
+ private DateTime currentMonth = DateTime.Now;
- private void ToggleCalendar() => _isOpen = !_isOpen;
- private void PreviousMonth() => _currentMonth = _currentMonth.AddMonths(-1);
- private void NextMonth() => _currentMonth = _currentMonth.AddMonths(1);
+ private void Toggle() => IsOpen = !IsOpen;
+ private void Close() => IsOpen = false;
private async Task SelectDate(DateTime date)
{
- SelectedDate = date;
- _isOpen = false;
- await SelectedDateChanged.InvokeAsync(date);
+ Value = date;
+ await ValueChanged.InvokeAsync(date);
+ IsOpen = false;
}
-
- private async Task ClearDate()
+
+ private async Task Clear()
{
- SelectedDate = null;
- _isOpen = false;
- await SelectedDateChanged.InvokeAsync(null);
+ Value = null;
+ await ValueChanged.InvokeAsync(null);
}
- private List GetCalendarDays()
- {
- var days = new List();
- var firstDay = new DateTime(_currentMonth.Year, _currentMonth.Month, 1);
- var lastDay = firstDay.AddMonths(1).AddDays(-1);
- var startDayOfWeek = (int)firstDay.DayOfWeek;
-
- for (int i = 0; i < startDayOfWeek; i++) days.Add(null);
- for (int day = 1; day <= lastDay.Day; day++) days.Add(new DateTime(_currentMonth.Year, _currentMonth.Month, day));
-
- return days;
- }
+ private void PreviousMonth() => currentMonth = currentMonth.AddMonths(-1);
+ private void NextMonth() => currentMonth = currentMonth.AddMonths(1);
+ private int GetDaysInMonth() => DateTime.DaysInMonth(currentMonth.Year, currentMonth.Month);
}
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/DateRangePicker.razor b/NET9/BlazorInteractiveServer/Components/UI/DateRangePicker.razor
index 1f64938..0dd7c4c 100644
--- a/NET9/BlazorInteractiveServer/Components/UI/DateRangePicker.razor
+++ b/NET9/BlazorInteractiveServer/Components/UI/DateRangePicker.razor
@@ -1,10 +1,11 @@
@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
-
+
+ class="@Shell.Cn("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", Disabled ? "opacity-50 cursor-not-allowed" : "")">
@GetDisplayText()
@@ -70,31 +71,20 @@
}
+@if (_isOpen)
+{
+
_isOpen = false">
+}
+
@code {
- [Parameter]
- public DateTime? StartDate { get; set; }
-
- [Parameter]
- public EventCallback
StartDateChanged { get; set; }
-
- [Parameter]
- public DateTime? EndDate { get; set; }
-
- [Parameter]
- public EventCallback EndDateChanged { get; set; }
-
- [Parameter]
- public string Placeholder { get; set; } = "Pick a date range";
-
- [Parameter]
- public bool AllowClear { get; set; } = true;
-
- [Parameter]
- public bool Disabled { get; set; }
-
- [Parameter]
- public string ClassName { get; set; } = "";
-
+ [Parameter] public DateTime? StartDate { get; set; }
+ [Parameter] public EventCallback StartDateChanged { get; set; }
+ [Parameter] public DateTime? EndDate { get; set; }
+ [Parameter] public EventCallback EndDateChanged { get; set; }
+ [Parameter] public string Placeholder { get; set; } = "Pick a date range";
+ [Parameter] public bool AllowClear { get; set; } = true;
+ [Parameter] public bool Disabled { get; set; }
+ [Parameter] public string? Class { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary? AdditionalAttributes { get; set; }
@@ -193,3 +183,4 @@
return days;
}
}
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/Dialog.razor b/NET9/BlazorInteractiveServer/Components/UI/Dialog.razor
index ad5a378..a4c406d 100644
--- a/NET9/BlazorInteractiveServer/Components/UI/Dialog.razor
+++ b/NET9/BlazorInteractiveServer/Components/UI/Dialog.razor
@@ -1,65 +1,23 @@
@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
-@if (IsOpen)
-{
-
-
-
-
-
-
- @if (Title != null || Description != null)
- {
-
- @if (Title != null)
- {
-
- @Title
-
- }
- @if (Description != null)
- {
-
- @Description
-
- }
-
- }
-
-
- @ChildContent
-
-
- @if (Footer != null)
- {
-
- @Footer
-
- }
-
-
-
-
-
-
-
-
-
-}
+
+ @ChildContent
+
@code {
- [Parameter] public bool IsOpen { get; set; }
- [Parameter] public string? Title { get; set; }
- [Parameter] public string? Description { get; set; }
- [Parameter] public RenderFragment? Footer { get; set; }
+ [Parameter] public bool Open { get; set; }
+ [Parameter] public EventCallback OpenChanged { get; set; }
[Parameter] public RenderFragment? ChildContent { get; set; }
- [Parameter] public EventCallback OnClose { get; set; }
- private async Task Close()
+ public async Task SetOpen(bool value)
{
- IsOpen = false;
- await OnClose.InvokeAsync();
+ if (Open != value)
+ {
+ Open = value;
+ await OpenChanged.InvokeAsync(value);
+ StateHasChanged();
+ }
}
}
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/DialogClose.razor b/NET9/BlazorInteractiveServer/Components/UI/DialogClose.razor
new file mode 100644
index 0000000..76c7bdb
--- /dev/null
+++ b/NET9/BlazorInteractiveServer/Components/UI/DialogClose.razor
@@ -0,0 +1,23 @@
+@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
+
+
+ @ChildContent
+
+
+@code {
+ [CascadingParameter] public Dialog? Dialog { get; set; }
+ [Parameter] public RenderFragment? ChildContent { get; set; }
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary? AdditionalAttributes { get; set; }
+
+ private async Task Close()
+ {
+ if (Dialog != null)
+ {
+ await Dialog.SetOpen(false);
+ }
+ }
+}
+
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/DialogContent.razor b/NET9/BlazorInteractiveServer/Components/UI/DialogContent.razor
new file mode 100644
index 0000000..018c901
--- /dev/null
+++ b/NET9/BlazorInteractiveServer/Components/UI/DialogContent.razor
@@ -0,0 +1,32 @@
+@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
+
+@if (Dialog?.Open == true)
+{
+
+
+ @ChildContent
+
+
+ Close
+
+
+}
+
+@code {
+ [CascadingParameter] public Dialog? Dialog { get; set; }
+ [Parameter] public RenderFragment? ChildContent { get; set; }
+ [Parameter] public string? Class { get; set; }
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary? AdditionalAttributes { get; set; }
+
+ private async Task Close()
+ {
+ if (Dialog != null)
+ {
+ await Dialog.SetOpen(false);
+ }
+ }
+}
+
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/DialogDescription.razor b/NET9/BlazorInteractiveServer/Components/UI/DialogDescription.razor
new file mode 100644
index 0000000..5dfa39f
--- /dev/null
+++ b/NET9/BlazorInteractiveServer/Components/UI/DialogDescription.razor
@@ -0,0 +1,15 @@
+@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
+
+
+ @ChildContent
+
+
+@code {
+ [Parameter] public RenderFragment? ChildContent { get; set; }
+ [Parameter] public string? Class { get; set; }
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary? AdditionalAttributes { get; set; }
+}
+
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/DialogFooter.razor b/NET9/BlazorInteractiveServer/Components/UI/DialogFooter.razor
new file mode 100644
index 0000000..1dcd7d4
--- /dev/null
+++ b/NET9/BlazorInteractiveServer/Components/UI/DialogFooter.razor
@@ -0,0 +1,15 @@
+@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
+
+
+ @ChildContent
+
+
+@code {
+ [Parameter] public RenderFragment? ChildContent { get; set; }
+ [Parameter] public string? Class { get; set; }
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary? AdditionalAttributes { get; set; }
+}
+
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/DialogHeader.razor b/NET9/BlazorInteractiveServer/Components/UI/DialogHeader.razor
new file mode 100644
index 0000000..15e71cc
--- /dev/null
+++ b/NET9/BlazorInteractiveServer/Components/UI/DialogHeader.razor
@@ -0,0 +1,15 @@
+@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
+
+
+ @ChildContent
+
+
+@code {
+ [Parameter] public RenderFragment? ChildContent { get; set; }
+ [Parameter] public string? Class { get; set; }
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary? AdditionalAttributes { get; set; }
+}
+
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/DialogTitle.razor b/NET9/BlazorInteractiveServer/Components/UI/DialogTitle.razor
new file mode 100644
index 0000000..645a40a
--- /dev/null
+++ b/NET9/BlazorInteractiveServer/Components/UI/DialogTitle.razor
@@ -0,0 +1,15 @@
+@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
+
+
+ @ChildContent
+
+
+@code {
+ [Parameter] public RenderFragment? ChildContent { get; set; }
+ [Parameter] public string? Class { get; set; }
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary? AdditionalAttributes { get; set; }
+}
+
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/DialogTrigger.razor b/NET9/BlazorInteractiveServer/Components/UI/DialogTrigger.razor
new file mode 100644
index 0000000..2feee63
--- /dev/null
+++ b/NET9/BlazorInteractiveServer/Components/UI/DialogTrigger.razor
@@ -0,0 +1,23 @@
+@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
+
+
+ @ChildContent
+
+
+@code {
+ [CascadingParameter] public Dialog? Dialog { get; set; }
+ [Parameter] public RenderFragment? ChildContent { get; set; }
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary? AdditionalAttributes { get; set; }
+
+ private async Task Toggle()
+ {
+ if (Dialog != null)
+ {
+ await Dialog.SetOpen(!Dialog.Open);
+ }
+ }
+}
+
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/Drawer.razor b/NET9/BlazorInteractiveServer/Components/UI/Drawer.razor
new file mode 100644
index 0000000..7bd1f8e
--- /dev/null
+++ b/NET9/BlazorInteractiveServer/Components/UI/Drawer.razor
@@ -0,0 +1,50 @@
+@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
+
+@if (IsOpen)
+{
+
+
+
+
+
+
+ @if (!string.IsNullOrEmpty(Title))
+ {
+
@Title
+ }
+ @if (!string.IsNullOrEmpty(Description))
+ {
+
@Description
+ }
+
+
+ @ChildContent
+
+
+ Close
+
+
+}
+
+@code {
+ [Parameter] public bool IsOpen { get; set; }
+ [Parameter] public EventCallback IsOpenChanged { get; set; }
+ [Parameter] public string? Title { get; set; }
+ [Parameter] public string? Description { get; set; }
+ [Parameter] public DrawerSide Side { get; set; } = DrawerSide.Bottom;
+ [Parameter] public RenderFragment? ChildContent { get; set; }
+ [Parameter] public string? Class { get; set; }
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary? AdditionalAttributes { get; set; }
+
+ private string ComputedClass => DrawerVariants.Get(Side, Class);
+
+ private async Task Close()
+ {
+ IsOpen = false;
+ await IsOpenChanged.InvokeAsync(IsOpen);
+ }
+}
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/Dropdown.razor b/NET9/BlazorInteractiveServer/Components/UI/Dropdown.razor
index 7bbfd7b..d996260 100644
--- a/NET9/BlazorInteractiveServer/Components/UI/Dropdown.razor
+++ b/NET9/BlazorInteractiveServer/Components/UI/Dropdown.razor
@@ -1,37 +1,27 @@
@namespace BlazorInteractiveServer.Components.UI
-
+
+ class="inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 pl-4 pr-3 py-2">
@Trigger
@if (IsOpen)
{
-
@code {
- [Parameter]
- public RenderFragment? Trigger { get; set; }
-
- [Parameter]
- public RenderFragment? ChildContent { get; set; }
-
- [Parameter]
- public bool IsOpen { get; set; }
-
- [Parameter]
- public EventCallback
IsOpenChanged { get; set; }
-
- [Parameter]
- public string ClassName { get; set; } = "";
-
+ [Parameter] public RenderFragment? Trigger { get; set; }
+ [Parameter] public RenderFragment? ChildContent { get; set; }
+ [Parameter] public bool IsOpen { get; set; }
+ [Parameter] public EventCallback IsOpenChanged { get; set; }
+ [Parameter] public string? Class { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary? AdditionalAttributes { get; set; }
@@ -41,3 +31,4 @@
await IsOpenChanged.InvokeAsync(IsOpen);
}
}
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/EmptyState.razor b/NET9/BlazorInteractiveServer/Components/UI/EmptyState.razor
index 5b28c54..74a6340 100644
--- a/NET9/BlazorInteractiveServer/Components/UI/EmptyState.razor
+++ b/NET9/BlazorInteractiveServer/Components/UI/EmptyState.razor
@@ -1,7 +1,9 @@
-
+@namespace BlazorInteractiveServer.Components.UI
+
+
@if (!string.IsNullOrEmpty(Icon))
{
-
+
@((MarkupString)Icon)
}
@@ -37,5 +39,8 @@
[Parameter] public string? Description { get; set; }
[Parameter] public RenderFragment? Action { get; set; }
[Parameter] public RenderFragment? ChildContent { get; set; }
- [Parameter] public string Class { get; set; } = string.Empty;
+ [Parameter] public string? Class { get; set; }
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary
? AdditionalAttributes { get; set; }
}
+
diff --git a/NET9/BlazorInteractiveServer/Components/UI/Form.razor b/NET9/BlazorInteractiveServer/Components/UI/Form.razor
index 1d7e451..2dc9826 100644
--- a/NET9/BlazorInteractiveServer/Components/UI/Form.razor
+++ b/NET9/BlazorInteractiveServer/Components/UI/Form.razor
@@ -1,4 +1,5 @@
@namespace BlazorInteractiveServer.Components.UI
+@using BlazorInteractiveServer.Components
@using Microsoft.AspNetCore.Components.Forms