Add D-prefixed Blazor wrappers for every daisyUI 5 component

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
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-10-03 12:01:42 +02:00
1 parent 8e03d12a3e
commit 90e4b9200c
127 files changed
+6962 -17

No files matched your search

@@ -0,0 +1,40 @@
@inherits DInputBase<DateOnly?>
@using System.Globalization
@* daisyUI Calendar (Cally): https://daisyui.com/components/calendar/ . Wraps the <calendar-date> web component from
wwwroot/vendor/cally.js; value, min and max are yyyy-MM-dd, and Blazor reads the element's value on its change
event. Other Cally attributes (locale, first-day-of-week, months) pass through. *@
<calendar-date @attributes="InputAttributes" class="@Cx("cally", CssClass)" value="@CurrentValueAsString" min="@Format(Min)"
max="@Format(Max)" @onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)">
<svg aria-label="@PreviousText" class="fill-current size-4" slot="previous" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.75 19.5 8.25 12l7.5-7.5"></path></svg>
<svg aria-label="@NextText" class="fill-current size-4" slot="next" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m8.25 4.5 7.5 7.5-7.5 7.5"></path></svg>
<calendar-month></calendar-month>
</calendar-date>
@code {
[Parameter] public DateOnly? Min { get; set; }
[Parameter] public DateOnly? Max { get; set; }
[Parameter] public string PreviousText { get; set; } = "Previous";
[Parameter] public string NextText { get; set; } = "Next";
static string Format(DateOnly? date) => date?.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
protected override string FormatValueAsString(DateOnly? value) => Format(value);
protected override bool TryParseValueFromString(string value, out DateOnly? result, out string validationErrorMessage)
{
validationErrorMessage = null;
result = null;
if (string.IsNullOrEmpty(value))
return true;
if (DateOnly.TryParseExact(value, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var date))
{
result = date;
return true;
}
validationErrorMessage = $"The {DisplayName ?? FieldIdentifier.FieldName} field is not a valid date.";
return false;
}
void OnChange(ChangeEventArgs e) => CurrentValueAsString = e.Value?.ToString();
}
@@ -0,0 +1,50 @@
@inherits DInputBase<bool>
@* daisyUI Checkbox: https://daisyui.com/components/checkbox/ . With LabelText the checkbox sits in a <label class="label">
followed by the text, as in daisyUI's fieldset examples. *@
@if (LabelText is null)
{
@Checkbox
}
else
{
<label class="label">
@Checkbox
@LabelText
</label>
}
@code {
[Parameter] public DColor Color { get; set; }
[Parameter] public DSize Size { get; set; }
[Parameter] public string LabelText { get; set; }
string CssClassFull => Cx("checkbox", IsInvalid ? "checkbox-error" : ColorClass, SizeClass, CssClass);
RenderFragment Checkbox => @<input @attributes="InputAttributes" type="checkbox" class="@CssClassFull" name="@NameAttributeValue"
checked="@CurrentValue" @onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)" />;
string ColorClass => Color switch
{
DColor.Neutral => "checkbox-neutral",
DColor.Primary => "checkbox-primary",
DColor.Secondary => "checkbox-secondary",
DColor.Accent => "checkbox-accent",
DColor.Info => "checkbox-info",
DColor.Success => "checkbox-success",
DColor.Warning => "checkbox-warning",
DColor.Error => "checkbox-error",
_ => null
};
string SizeClass => Size switch
{
DSize.Xs => "checkbox-xs",
DSize.Sm => "checkbox-sm",
DSize.Lg => "checkbox-lg",
DSize.Xl => "checkbox-xl",
_ => null
};
void OnChange(ChangeEventArgs e) => CurrentValue = e.Value is true;
}
@@ -0,0 +1,21 @@
@inherits DComponentBase
@* daisyUI Fieldset: https://daisyui.com/components/fieldset/ . Legend becomes the fieldset-legend, Description the
trailing p.label; disabled on the fieldset disables every field in it. *@
<fieldset @attributes="AdditionalAttributes" class="@Cx("fieldset", Class)">
@if (Legend is not null)
{
<legend class="fieldset-legend">@Legend</legend>
}
@ChildContent
@if (Description is not null)
{
<p class="label">@Description</p>
}
</fieldset>
@code {
[Parameter] public RenderFragment Legend { get; set; }
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public RenderFragment Description { get; set; }
}
@@ -0,0 +1,39 @@
@inherits DComponentBase
@* daisyUI File input: https://daisyui.com/components/file-input/ . Blazor's InputFile with the file-input classes;
read the files in OnChange (e.File / e.GetMultipleFiles()). *@
<InputFile @attributes="AdditionalAttributes" class="@CssClass" OnChange="OnChange" multiple="@Multiple" accept="@Accept" />
@code {
[Parameter] public EventCallback<InputFileChangeEventArgs> OnChange { get; set; }
[Parameter] public bool Multiple { get; set; }
/// <summary>The accept attribute: file types, e.g. "image/*,.pdf".</summary>
[Parameter] public string Accept { get; set; }
[Parameter] public DColor Color { get; set; }
[Parameter] public DSize Size { get; set; }
[Parameter] public bool Ghost { get; set; }
string CssClass => Cx("file-input", ColorClass, SizeClass, Ghost ? "file-input-ghost" : null, Class);
string ColorClass => Color switch
{
DColor.Neutral => "file-input-neutral",
DColor.Primary => "file-input-primary",
DColor.Secondary => "file-input-secondary",
DColor.Accent => "file-input-accent",
DColor.Info => "file-input-info",
DColor.Success => "file-input-success",
DColor.Warning => "file-input-warning",
DColor.Error => "file-input-error",
_ => null
};
string SizeClass => Size switch
{
DSize.Xs => "file-input-xs",
DSize.Sm => "file-input-sm",
DSize.Lg => "file-input-lg",
DSize.Xl => "file-input-xl",
_ => null
};
}
+43
View File
@@ -0,0 +1,43 @@
@typeparam TValue
@inherits DInputBase<TValue>
@* daisyUI Filter: https://daisyui.com/components/filter/ . The <div> form of the filter: a native form reset would
not tell Blazor, and a <form> can't nest in an EditForm. Each option is a radio button checked while Value equals
it; the filter-reset radio sets Value back to default, so with no default among the options nothing is selected. *@
<div @attributes="InputAttributes" class="@Cx("filter", CssClass)">
<input type="radio" name="@GroupName" class="@Cx("btn", "filter-reset", SizeClass)" aria-label="@ResetText"
disabled="@Disabled" @onchange="() => CurrentValue = default" />
@if (Options is not null)
{
foreach (var option in Options)
{
<input type="radio" name="@GroupName" class="@Cx("btn", SizeClass)" aria-label="@(TextOf?.Invoke(option) ?? option?.ToString())"
checked="@IsSelected(option)" disabled="@Disabled"
@onchange="() => CurrentValue = option" />
}
}
</div>
@code {
[Parameter] public IEnumerable<TValue> Options { get; set; }
/// <summary>An option's button text; ToString() when null.</summary>
[Parameter] public Func<TValue, string> TextOf { get; set; }
[Parameter] public string ResetText { get; set; } = "×";
[Parameter] public DSize Size { get; set; }
[Parameter] public bool Disabled { get; set; }
readonly string uid = "d" + Guid.NewGuid().ToString("N")[..8];
string GroupName => string.IsNullOrEmpty(NameAttributeValue) ? uid : NameAttributeValue;
bool IsSelected(TValue option) => EqualityComparer<TValue>.Default.Equals(CurrentValue, option);
string SizeClass => Size switch
{
DSize.Xs => "btn-xs",
DSize.Sm => "btn-sm",
DSize.Lg => "btn-lg",
DSize.Xl => "btn-xl",
_ => null
};
}
+65
View File
@@ -0,0 +1,65 @@
@typeparam TValue
@inherits DInputBase<TValue>
@* daisyUI Input: https://daisyui.com/components/input/ . With Prefix or Suffix (icons, labels, kbd) the input class
moves to a wrapping <label>, as daisyUI requires when the field holds more than one element. *@
@if (Prefix is null && Suffix is null)
{
<input @attributes="InputAttributes" type="@Type" class="@CssClassFull" name="@NameAttributeValue"
value="@CurrentValueAsString" @oninput="OnInput" @onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)" />
}
else
{
<label class="@CssClassFull">
@Prefix
<input @attributes="InputAttributes" type="@Type" class="grow" name="@NameAttributeValue"
value="@CurrentValueAsString" @oninput="OnInput" @onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)" />
@Suffix
</label>
}
@code {
[Parameter] public string Type { get; set; } = "text";
[Parameter] public DColor Color { get; set; }
[Parameter] public DSize Size { get; set; }
[Parameter] public bool Ghost { get; set; }
/// <summary>Update the bound value on every keystroke instead of on change.</summary>
[Parameter] public bool Immediate { get; set; }
[Parameter] public RenderFragment Prefix { get; set; }
[Parameter] public RenderFragment Suffix { get; set; }
/// <summary>Adds daisyUI's validator class: error/success colors and a following DValidatorHint.</summary>
[Parameter] public bool Validator { get; set; }
string CssClassFull => Cx("input", IsInvalid ? "input-error" : ColorClass, SizeClass, Ghost ? "input-ghost" : null,
Validator ? "validator" : null, CssClass);
string ColorClass => Color switch
{
DColor.Neutral => "input-neutral",
DColor.Primary => "input-primary",
DColor.Secondary => "input-secondary",
DColor.Accent => "input-accent",
DColor.Info => "input-info",
DColor.Success => "input-success",
DColor.Warning => "input-warning",
DColor.Error => "input-error",
_ => null
};
string SizeClass => Size switch
{
DSize.Xs => "input-xs",
DSize.Sm => "input-sm",
DSize.Lg => "input-lg",
DSize.Xl => "input-xl",
_ => null
};
void OnInput(ChangeEventArgs e)
{
if (Immediate)
CurrentValueAsString = e.Value?.ToString();
}
void OnChange(ChangeEventArgs e) => CurrentValueAsString = e.Value?.ToString();
}
+22
View File
@@ -0,0 +1,22 @@
@inherits DComponentBase
@* daisyUI Label: https://daisyui.com/components/label/ . By default a span.label holding ChildContent, for a DInput or
DSelect Prefix/Suffix or a fieldset. Floating renders label.floating-label around the field in ChildContent, with
Text as the label that floats above it once the field has focus or a value. *@
@if (Floating)
{
<label @attributes="AdditionalAttributes" class="@Cx("floating-label", Class)">
@ChildContent
<span>@Text</span>
</label>
}
else
{
<span @attributes="AdditionalAttributes" class="@Cx("label", Class)">@(Text)@ChildContent</span>
}
@code {
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public string Text { get; set; }
[Parameter] public bool Floating { get; set; }
}
+58
View File
@@ -0,0 +1,58 @@
@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();
}
+60
View File
@@ -0,0 +1,60 @@
@typeparam TValue
@inherits DComponentBase
@* One radio of a DRadioGroup: checked while the group's value equals Value; choosing it sets the group's value. With
LabelText it sits in a label.label followed by the text. *@
@if (LabelText is null)
{
@Radio
}
else
{
<label class="label">
@Radio
@LabelText
</label>
}
@code {
[CascadingParameter] DRadioGroup<TValue> Group { get; set; }
[Parameter] public TValue Value { get; set; }
[Parameter] public DColor Color { get; set; }
[Parameter] public DSize Size { get; set; }
[Parameter] public bool Disabled { get; set; }
[Parameter] public string LabelText { get; set; }
RenderFragment Radio =>
@<input @attributes="AdditionalAttributes" type="radio" class="@CssClass" name="@Group.GroupName"
checked="@Group.IsSelected(Value)" disabled="@Disabled" @onchange="() => Group.Select(Value)"
aria-invalid="@(Group.GroupInvalid ? "true" : null)" />;
string CssClass => Cx("radio", Group.GroupInvalid ? "radio-error" : ColorClass, SizeClass, Class);
string ColorClass => Color switch
{
DColor.Neutral => "radio-neutral",
DColor.Primary => "radio-primary",
DColor.Secondary => "radio-secondary",
DColor.Accent => "radio-accent",
DColor.Info => "radio-info",
DColor.Success => "radio-success",
DColor.Warning => "radio-warning",
DColor.Error => "radio-error",
_ => null
};
string SizeClass => Size switch
{
DSize.Xs => "radio-xs",
DSize.Sm => "radio-sm",
DSize.Lg => "radio-lg",
DSize.Xl => "radio-xl",
_ => null
};
protected override void OnInitialized()
{
if (Group is null)
throw new InvalidOperationException("DRadio must be inside a DRadioGroup of the same TValue.");
}
}
@@ -0,0 +1,33 @@
@typeparam TValue
@inherits DInputBase<TValue>
@attribute [CascadingTypeParameter(nameof(TValue))]
@* daisyUI Radio: https://daisyui.com/components/radio/ . The group holds the bound value and cascades itself (not
fixed, so every DRadio re-renders with it); its radios share one name, the name attribute or a per-instance id.
It adds a div role="radiogroup" only when given attributes (a class, an aria-label). *@
<CascadingValue Value="this">
@if (AdditionalAttributes is null || AdditionalAttributes.Count == 0)
{
@ChildContent
}
else
{
<div @attributes="InputAttributes" role="radiogroup" class="@CssClass">
@ChildContent
</div>
}
</CascadingValue>
@code {
[Parameter] public RenderFragment ChildContent { get; set; }
readonly string uid = "d" + Guid.NewGuid().ToString("N")[..8];
internal string GroupName => string.IsNullOrEmpty(NameAttributeValue) ? uid : NameAttributeValue;
internal bool GroupInvalid => IsInvalid;
internal bool IsSelected(TValue value) => EqualityComparer<TValue>.Default.Equals(CurrentValue, value);
internal void Select(TValue value) => CurrentValue = value;
}
+54
View File
@@ -0,0 +1,54 @@
@typeparam TValue
@inherits DInputBase<TValue>
@* daisyUI Range: https://daisyui.com/components/range/ . TValue is numeric; Min and Max are always rendered, as daisyUI
requires. *@
<input @attributes="InputAttributes" type="range" class="@CssClassFull" name="@NameAttributeValue" min="@Format(Min)"
max="@Format(Max)" step="@(Step is null ? null : Format(Step.Value))" value="@CurrentValueAsString"
@oninput="OnInput" @onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)" />
@code {
[Parameter] public double Min { get; set; }
[Parameter] public double Max { get; set; } = 100;
[Parameter] public double? Step { get; set; }
[Parameter] public DColor Color { get; set; }
[Parameter] public DSize Size { get; set; }
[Parameter] public DDirection Direction { get; set; }
/// <summary>Update the bound value while dragging instead of on release.</summary>
[Parameter] public bool Immediate { get; set; }
string CssClassFull => Cx("range", IsInvalid ? "range-error" : ColorClass, SizeClass,
Direction == DDirection.Vertical ? "range-vertical" : null, CssClass);
string ColorClass => Color switch
{
DColor.Neutral => "range-neutral",
DColor.Primary => "range-primary",
DColor.Secondary => "range-secondary",
DColor.Accent => "range-accent",
DColor.Info => "range-info",
DColor.Success => "range-success",
DColor.Warning => "range-warning",
DColor.Error => "range-error",
_ => null
};
string SizeClass => Size switch
{
DSize.Xs => "range-xs",
DSize.Sm => "range-sm",
DSize.Lg => "range-lg",
DSize.Xl => "range-xl",
_ => null
};
static string Format(double value) => value.ToString(System.Globalization.CultureInfo.InvariantCulture);
void OnInput(ChangeEventArgs e)
{
if (Immediate)
CurrentValueAsString = e.Value?.ToString();
}
void OnChange(ChangeEventArgs e) => CurrentValueAsString = e.Value?.ToString();
}
+85
View File
@@ -0,0 +1,85 @@
@inherits DInputBase<int>
@* daisyUI Rating: https://daisyui.com/components/rating/ . A radio per item, sharing a per-instance name; Value is the
number of the checked item, 0 for none. With Half every item is two half radios and Value counts halves (3 = 1.5
stars). Static renders the read-only <div> version, marking the current item with aria-current. *@
<div @attributes="InputAttributes" class="@CssClassFull">
@if (Static)
{
for (var i = 1; i <= Items; i++)
{
<div class="@ItemCss(i)" aria-label="@ItemText(i)" aria-current="@(i == CurrentValue ? "true" : null)"></div>
}
}
else
{
if (Clearable)
{
<input type="radio" name="@GroupName" class="rating-hidden" aria-label="@ClearText" checked="@(CurrentValue == 0)"
disabled="@Disabled" @onchange="() => CurrentValue = 0" />
}
for (var i = 1; i <= Items; i++)
{
var item = i;
<input type="radio" name="@GroupName" class="@ItemCss(item)" aria-label="@ItemText(item)" checked="@(item == CurrentValue)"
disabled="@Disabled" @onchange="() => CurrentValue = item" aria-invalid="@(IsInvalid ? "true" : null)" />
}
}
</div>
@code {
[Parameter] public int Count { get; set; } = 5;
[Parameter] public DRatingMask Mask { get; set; }
[Parameter] public bool Half { get; set; }
[Parameter] public DSize Size { get; set; }
/// <summary>Adds the hidden first radio (rating-hidden) that clears the rating to 0.</summary>
[Parameter] public bool Clearable { get; set; }
/// <summary>Read-only rating: <div> items instead of radios.</summary>
[Parameter] public bool Static { get; set; }
[Parameter] public bool Disabled { get; set; }
/// <summary>Classes for every item, e.g. a color: bg-orange-400.</summary>
[Parameter] public string ItemClass { get; set; }
/// <summary>The unit in each item's aria-label ("2 star").</summary>
[Parameter] public string UnitText { get; set; } = "star";
[Parameter] public string ClearText { get; set; } = "clear";
readonly string uid = "d" + Guid.NewGuid().ToString("N")[..8];
string GroupName => string.IsNullOrEmpty(NameAttributeValue) ? uid : NameAttributeValue;
int Items => Half ? Count * 2 : Count;
string CssClassFull => Cx("rating", Half ? "rating-half" : null, SizeClass, CssClass);
string ItemCss(int item) => Cx("mask", MaskClass, Half ? (item % 2 == 1 ? "mask-half-1" : "mask-half-2") : null, ItemClass);
string ItemText(int item) =>
$"{(Half ? item / 2.0 : item).ToString(System.Globalization.CultureInfo.InvariantCulture)} {UnitText}";
string MaskClass => Mask switch
{
DRatingMask.Star2 => "mask-star-2",
DRatingMask.Heart => "mask-heart",
DRatingMask.Squircle => "mask-squircle",
DRatingMask.Hexagon => "mask-hexagon",
DRatingMask.Hexagon2 => "mask-hexagon-2",
DRatingMask.Decagon => "mask-decagon",
DRatingMask.Pentagon => "mask-pentagon",
DRatingMask.Diamond => "mask-diamond",
DRatingMask.Circle => "mask-circle",
DRatingMask.Triangle => "mask-triangle",
DRatingMask.Triangle2 => "mask-triangle-2",
DRatingMask.Triangle3 => "mask-triangle-3",
DRatingMask.Triangle4 => "mask-triangle-4",
_ => "mask-star"
};
string SizeClass => Size switch
{
DSize.Xs => "rating-xs",
DSize.Sm => "rating-sm",
DSize.Lg => "rating-lg",
DSize.Xl => "rating-xl",
_ => null
};
}
@@ -0,0 +1,20 @@
namespace decePubClient.Components.Daisy.DataInput;
/// <summary>The mask shape of a DRating's items. A rating always needs one, so the default Star is mask-star.</summary>
public enum DRatingMask
{
Star,
Star2,
Heart,
Squircle,
Hexagon,
Hexagon2,
Decagon,
Pentagon,
Diamond,
Circle,
Triangle,
Triangle2,
Triangle3,
Triangle4
}
+59
View File
@@ -0,0 +1,59 @@
@typeparam TValue
@inherits DInputBase<TValue>
@* daisyUI Select: https://daisyui.com/components/select/ . The options are ChildContent (<option value="...">);
enums bind by name. With Prefix (an icon or a span.label) the select class moves to a wrapping <label>. *@
@if (Prefix is null)
{
<select @attributes="InputAttributes" class="@CssClassFull" name="@NameAttributeValue" value="@CurrentValueAsString"
@onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)">
@ChildContent
</select>
}
else
{
<label class="@CssClassFull">
@Prefix
<select @attributes="InputAttributes" name="@NameAttributeValue" value="@CurrentValueAsString" @onchange="OnChange"
aria-invalid="@(IsInvalid ? "true" : null)">
@ChildContent
</select>
</label>
}
@code {
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public RenderFragment Prefix { get; set; }
[Parameter] public DColor Color { get; set; }
[Parameter] public DSize Size { get; set; }
[Parameter] public bool Ghost { get; set; }
/// <summary>Adds daisyUI's validator class: error/success colors and a following DValidatorHint.</summary>
[Parameter] public bool Validator { get; set; }
string CssClassFull => Cx("select", IsInvalid ? "select-error" : ColorClass, SizeClass, Ghost ? "select-ghost" : null,
Validator ? "validator" : null, CssClass);
string ColorClass => Color switch
{
DColor.Neutral => "select-neutral",
DColor.Primary => "select-primary",
DColor.Secondary => "select-secondary",
DColor.Accent => "select-accent",
DColor.Info => "select-info",
DColor.Success => "select-success",
DColor.Warning => "select-warning",
DColor.Error => "select-error",
_ => null
};
string SizeClass => Size switch
{
DSize.Xs => "select-xs",
DSize.Sm => "select-sm",
DSize.Lg => "select-lg",
DSize.Xl => "select-xl",
_ => null
};
void OnChange(ChangeEventArgs e) => CurrentValueAsString = e.Value?.ToString();
}
@@ -0,0 +1,50 @@
@typeparam TValue
@inherits DInputBase<TValue>
@* daisyUI Textarea: https://daisyui.com/components/textarea/ . Blazor sets the textarea's value property, so the bound
value is the content; rows, placeholder and the like pass through. *@
<textarea @attributes="InputAttributes" class="@CssClassFull" name="@NameAttributeValue" value="@CurrentValueAsString"
@oninput="OnInput" @onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)"></textarea>
@code {
[Parameter] public DColor Color { get; set; }
[Parameter] public DSize Size { get; set; }
[Parameter] public bool Ghost { get; set; }
/// <summary>Update the bound value on every keystroke instead of on change.</summary>
[Parameter] public bool Immediate { get; set; }
/// <summary>Adds daisyUI's validator class: error/success colors and a following DValidatorHint.</summary>
[Parameter] public bool Validator { get; set; }
string CssClassFull => Cx("textarea", IsInvalid ? "textarea-error" : ColorClass, SizeClass, Ghost ? "textarea-ghost" : null,
Validator ? "validator" : null, CssClass);
string ColorClass => Color switch
{
DColor.Neutral => "textarea-neutral",
DColor.Primary => "textarea-primary",
DColor.Secondary => "textarea-secondary",
DColor.Accent => "textarea-accent",
DColor.Info => "textarea-info",
DColor.Success => "textarea-success",
DColor.Warning => "textarea-warning",
DColor.Error => "textarea-error",
_ => null
};
string SizeClass => Size switch
{
DSize.Xs => "textarea-xs",
DSize.Sm => "textarea-sm",
DSize.Lg => "textarea-lg",
DSize.Xl => "textarea-xl",
_ => null
};
void OnInput(ChangeEventArgs e)
{
if (Immediate)
CurrentValueAsString = e.Value?.ToString();
}
void OnChange(ChangeEventArgs e) => CurrentValueAsString = e.Value?.ToString();
}
+101
View File
@@ -0,0 +1,101 @@
@inherits DInputBase<bool>
@* daisyUI Toggle: https://daisyui.com/components/toggle/ . With CheckedIcon/UncheckedIcon the toggle class moves to a
wrapper around the checkbox and the two icons (each must be a single element: daisyUI shows the wrapper's 2nd child
while unchecked and its 3rd while checked). daisyUI colors such a wrapper only through aria-checked, which a label
may not carry, so its color is a has-checked: variable instead. With LabelText all of it sits in a label.label. *@
@if (!HasIcons && LabelText is null)
{
@Checkbox(Cx("toggle", IsInvalid ? "toggle-error" : ColorClass, SizeClass, CssClass))
}
else if (!HasIcons)
{
<label class="label">
@Checkbox(Cx("toggle", IsInvalid ? "toggle-error" : ColorClass, SizeClass, CssClass))
@LabelText
</label>
}
else if (LabelText is null)
{
<label class="@WrapperClass">@IconParts</label>
}
else
{
<label class="label">
<span class="@WrapperClass">@IconParts</span>
@LabelText
</label>
}
@code {
[Parameter] public DColor Color { get; set; }
[Parameter] public DSize Size { get; set; }
[Parameter] public string LabelText { get; set; }
[Parameter] public RenderFragment CheckedIcon { get; set; }
[Parameter] public RenderFragment UncheckedIcon { get; set; }
bool HasIcons => CheckedIcon is not null || UncheckedIcon is not null;
string WrapperClass => Cx("toggle", IsInvalid ? "has-checked:[--input-color:var(--color-error)]" : WrapperColorClass, SizeClass, CssClass);
RenderFragment Checkbox(string cssClass) =>
@<input @attributes="InputAttributes" type="checkbox" class="@cssClass" name="@NameAttributeValue" checked="@CurrentValue"
@onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)" />;
RenderFragment IconParts => @<text>
@Checkbox(null)
@if (UncheckedIcon is null)
{
<span></span>
}
else
{
@UncheckedIcon
}
@if (CheckedIcon is null)
{
<span></span>
}
else
{
@CheckedIcon
}
</text>;
string ColorClass => Color switch
{
DColor.Neutral => "toggle-neutral",
DColor.Primary => "toggle-primary",
DColor.Secondary => "toggle-secondary",
DColor.Accent => "toggle-accent",
DColor.Info => "toggle-info",
DColor.Success => "toggle-success",
DColor.Warning => "toggle-warning",
DColor.Error => "toggle-error",
_ => null
};
string WrapperColorClass => Color switch
{
DColor.Neutral => "has-checked:[--input-color:var(--color-neutral)]",
DColor.Primary => "has-checked:[--input-color:var(--color-primary)]",
DColor.Secondary => "has-checked:[--input-color:var(--color-secondary)]",
DColor.Accent => "has-checked:[--input-color:var(--color-accent)]",
DColor.Info => "has-checked:[--input-color:var(--color-info)]",
DColor.Success => "has-checked:[--input-color:var(--color-success)]",
DColor.Warning => "has-checked:[--input-color:var(--color-warning)]",
DColor.Error => "has-checked:[--input-color:var(--color-error)]",
_ => null
};
string SizeClass => Size switch
{
DSize.Xs => "toggle-xs",
DSize.Sm => "toggle-sm",
DSize.Lg => "toggle-lg",
DSize.Xl => "toggle-xl",
_ => null
};
void OnChange(ChangeEventArgs e) => CurrentValue = e.Value is true;
}
@@ -0,0 +1,12 @@
@inherits DComponentBase
@* daisyUI Validator: https://daisyui.com/components/validator/ . Place it right after a field with Validator set (a
following sibling): it shows, in the error color, while that field is :user-invalid or aria-invalid (failed
EditForm validation). *@
<p @attributes="AdditionalAttributes" class="@Cx("validator-hint", Compact ? "hidden" : null, Class)">@ChildContent</p>
@code {
[Parameter] public RenderFragment ChildContent { get; set; }
/// <summary>Takes no space while the field is valid (daisyUI's validator-hint hidden) instead of keeping its line.</summary>
[Parameter] public bool Compact { get; set; }
}