Ported from the owner's b2b.next and adapted from MudBlazor to the daisyUI
components:
- LocalizableComponentBase provides CascadingState, Navigation, Toast,
IsLoading/IsDefaultDisabled, WhenOnline/StartOnlinePolling, and after-render
jobs that actually run.
- CascadingState starts with initialised state and polls the online status
with a PeriodicTimer. It reports errors through ILoggingService plus a toast,
and disposes what it holds.
- New pieces:
- ToastService + ToastHost, the snackbar, with AddResponseError/Success/
Warning/Exception in SUtility;
- ErrorViewer, which shows the validation messages plus AdditionalError(s);
- LoggingService, which writes to the console and the IndexedDB client log.
- HttpService is rebuilt and registered:
- auth levels Get/Post/Delete, *Anon and *TotallyAnon;
- retry with backoff;
- classified failures (FailureCodes) instead of exceptions;
- HTTP 410 on cancel;
- the "default" client.
ReadWebResult and DefaultReadFromJsonAsync read its responses.
- ClientJsonContext is source-generated, and SUtility.DefaultSerializer and
Blazored.LocalStorage use it.
- WebResult gains a C# 14 IsInvalid extension property.
The code follows the imported rules:
- Every service and async helper takes a CancellationToken last.
- Primary constructors replace constructor-plus-fields.
- MessagesService and IStorage return Task<WebResult> / Task<List<T>>.
MessagesService is still mock, building its results in memory; the seed
feed and thread moved to Faker.
- Index and ExpandMessage follow the page pattern: an offline guard with
WhenOnline, LoadData, and early returns with toasts on the results they used
to ignore. ExpandMessage reloads on route change and shows "not found"
instead of a null message.
- Model and state collections are [], and the fake identity defaults moved
out of the models.
- Components:
- no ?. chains over initialised state;
- [Inject] instead of @inject;
- IsDefaultDisabled on the actions;
- autocomplete on every text input;
- Localizer[key, args] instead of string.Format;
- the localizer no longer leaks its inner _pLocalizer.
- Settings → General gains a language picker (English/Italiano), and
SetDefaultCulture limits the culture to those two.
Bugs fixed along the way:
- A compose with untouched (null) content passed the empty check.
- File errors were joined with <br/> and rendered as markup.
- ClientLogs.ErrorMessage() threw on warnings.
- CoalescingStringLocalizer[key, args] showed a raw "{0}" for missing keys.
- AppStatusService exposed a call to a JS function that doesn't exist.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
77 lines
2.0 KiB
Plaintext
77 lines
2.0 KiB
Plaintext
@inherits DComponentBase
|
|
|
|
@* daisyUI Tab: https://daisyui.com/components/tab/ . Each DTab child registers itself through the cascading value;
|
|
DTabs renders the tab buttons and the active tab's content. The active tab is an index (@bind-Active). *@
|
|
<CascadingValue Value="this" IsFixed="true">
|
|
@ChildContent
|
|
</CascadingValue>
|
|
|
|
<div @attributes="AdditionalAttributes" role="tablist" class="@CssClass">
|
|
@for (var i = 0; i < tabs.Count; i++)
|
|
{
|
|
var index = i;
|
|
var tab = tabs[i];
|
|
<button type="button" role="tab" aria-selected="@(index == Active ? "true" : "false")" disabled="@tab.Disabled"
|
|
class="@Cx("tab", index == Active ? "tab-active" : null, tab.Disabled ? "tab-disabled" : null, tab.Class)"
|
|
@onclick="() => Select(index)">
|
|
@tab.Header
|
|
</button>
|
|
}
|
|
</div>
|
|
|
|
@if (Active >= 0 && Active < tabs.Count)
|
|
{
|
|
<div role="tabpanel" class="@ContentClass">
|
|
@tabs[Active].ChildContent
|
|
</div>
|
|
}
|
|
|
|
@code {
|
|
[Parameter] public RenderFragment ChildContent { get; set; }
|
|
[Parameter] public int Active { get; set; }
|
|
[Parameter] public EventCallback<int> ActiveChanged { get; set; }
|
|
[Parameter] public DTabsVariant Variant { get; set; }
|
|
[Parameter] public DSize Size { get; set; }
|
|
[Parameter] public bool Bottom { get; set; }
|
|
[Parameter] public string ContentClass { get; set; } = "pt-4";
|
|
|
|
readonly List<DTab> tabs = [];
|
|
|
|
string CssClass => Cx("tabs", VariantClass, SizeClass, Bottom ? "tabs-bottom" : null, Class);
|
|
|
|
string VariantClass => Variant switch
|
|
{
|
|
DTabsVariant.Box => "tabs-box",
|
|
DTabsVariant.Border => "tabs-border",
|
|
DTabsVariant.Lift => "tabs-lift",
|
|
_ => null
|
|
};
|
|
|
|
string SizeClass => Size switch
|
|
{
|
|
DSize.Xs => "tabs-xs",
|
|
DSize.Sm => "tabs-sm",
|
|
DSize.Lg => "tabs-lg",
|
|
DSize.Xl => "tabs-xl",
|
|
_ => null
|
|
};
|
|
|
|
internal void Add(DTab tab)
|
|
{
|
|
tabs.Add(tab);
|
|
StateHasChanged();
|
|
}
|
|
|
|
internal void Remove(DTab tab)
|
|
{
|
|
tabs.Remove(tab);
|
|
StateHasChanged();
|
|
}
|
|
|
|
async Task Select(int index)
|
|
{
|
|
Active = index;
|
|
await ActiveChanged.InvokeAsync(index);
|
|
}
|
|
}
|