Components/Daisy/ wraps all 69 components in daisyUI's llms.txt, grouped by daisyUI's categories (Actions, DataDisplay, Navigation, Feedback, DataInput, Layout, Mockup), with part components where daisyUI has repeating parts (DTab, DMenuItem, DTimelineItem, ...). - Each enum maps to whole literal class names in a switch, so Tailwind's scanner generates them. Nothing is concatenated. - Value-holding fields derive from DInputBase<TValue>, Blazor's InputBase, so @bind-Value and EditForm validation work. Invalid fields get the component's *-error class. - Open and active state lives in C# (@bind-IsOpen, @bind-Active) and is rendered with daisyUI's *-open modifiers. DDropdown adds an outside-click layer and Escape. No component uses JS interop. - The one exception is DCalendar, which wraps the Cally web component, vendored as wwwroot/vendor/cally.js (0.9.2, MIT). /styleguide (not linked) renders every component in all its colours, sizes and states, with a theme and hue picker that previews without saving. neo.css follows what the styleguide showed: - select keeps daisyUI's arrow; - skeleton-text isn't sunk; - the phone mockup and dock are raised; - active menu items and OTP digits are inset; - a joined accordion is raised as one block. The primary, secondary and accent colours are deeper, so they still read as text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
59 lines
1.9 KiB
Plaintext
59 lines
1.9 KiB
Plaintext
@inherits DInputBase<string>
|
|
|
|
@* daisyUI OTP: https://daisyui.com/components/otp/ . The otp class is on the label; Length (4 to 6) sets the number of
|
|
digit boxes, maxlength and pattern together. required is on by default because daisyUI styles the complete code
|
|
through :valid; required="false" removes it. *@
|
|
<label class="@CssClassFull">
|
|
@for (var i = 0; i < Digits; i++)
|
|
{
|
|
<span></span>
|
|
}
|
|
<input type="text" autocomplete="one-time-code" inputmode="numeric" required @attributes="InputAttributes"
|
|
maxlength="@Digits" pattern="@($"[0-9]{{{Digits}}}")" name="@NameAttributeValue" value="@CurrentValueAsString"
|
|
@oninput="OnInput" @onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)" />
|
|
</label>
|
|
|
|
@code {
|
|
[Parameter] public int Length { get; set; } = 6;
|
|
[Parameter] public DColor Color { get; set; }
|
|
[Parameter] public DSize Size { get; set; }
|
|
/// <summary>Joins the digit boxes into one field (otp-joined).</summary>
|
|
[Parameter] public bool Joined { get; set; }
|
|
/// <summary>Update the bound value on every keystroke instead of on change.</summary>
|
|
[Parameter] public bool Immediate { get; set; }
|
|
|
|
int Digits => Math.Clamp(Length, 4, 6);
|
|
|
|
string CssClassFull => Cx("otp", IsInvalid ? "otp-error" : ColorClass, SizeClass, Joined ? "otp-joined" : null, CssClass);
|
|
|
|
string ColorClass => Color switch
|
|
{
|
|
DColor.Neutral => "otp-neutral",
|
|
DColor.Primary => "otp-primary",
|
|
DColor.Secondary => "otp-secondary",
|
|
DColor.Accent => "otp-accent",
|
|
DColor.Info => "otp-info",
|
|
DColor.Success => "otp-success",
|
|
DColor.Warning => "otp-warning",
|
|
DColor.Error => "otp-error",
|
|
_ => null
|
|
};
|
|
|
|
string SizeClass => Size switch
|
|
{
|
|
DSize.Xs => "otp-xs",
|
|
DSize.Sm => "otp-sm",
|
|
DSize.Lg => "otp-lg",
|
|
DSize.Xl => "otp-xl",
|
|
_ => null
|
|
};
|
|
|
|
void OnInput(ChangeEventArgs e)
|
|
{
|
|
if (Immediate)
|
|
CurrentValueAsString = e.Value?.ToString();
|
|
}
|
|
|
|
void OnChange(ChangeEventArgs e) => CurrentValueAsString = e.Value?.ToString();
|
|
}
|