Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,103 @@
ForId="@FieldId">
<InputContent>
<CascadingValue Name="Standalone" Value="false" IsFixed="true">
<MudInputExtended T="string"
@ref="InputReference"
@attributes="UserAttributes"
InputType="@_passwordInput"
Lines="@Lines"
Style="@Style"
Variant="@Variant"
TextUpdateSuppression="@TextUpdateSuppression"
Value="@Text"
ValueChanged="(s) => SetTextAsync(s)"
Placeholder="@Placeholder"
Disabled=@Disabled
DisableUnderLine="@DisableUnderLine"
ReadOnly="@ReadOnly"
MaxLength="@MaxLength"
AdornmentAriaLabel="@AdornmentAriaLabel"
Error="@Error"
ErrorId="@ErrorId"
Immediate="@Immediate"
Margin="@Margin"
OnBlur="@OnBlurredAsync"
OnKeyDown="@InvokeKeyDown"
OnInternalInputChanged="OnChange"
OnKeyPress="@InvokeKeyPress"
OnKeyUp="@InvokeKeyUp"
KeyDownPreventDefault="KeyDownPreventDefault"
KeyPressPreventDefault="KeyPressPreventDefault"
KeyUpPreventDefault="KeyUpPreventDefault"
HideSpinButtons="true"
Clearable="@Clearable"
OnClearButtonClick="@OnClearButtonClick"
Pattern="@Pattern">
<AdornmentEnd>
@if (CustomAdornment != null)
{
@CustomAdornment
}
else
{
<MudIconButton Icon="@_passwordIcon" Color="@AdornmentColor" Size="@IconSize" OnClick="AdornmentClick" tabindex="@(AdornmentTabStop ? 0 : -1)"></MudIconButton>
}
</AdornmentEnd>

</MudInputExtended>
@if (AdornmentStart != null)
{
<MudInputExtended T="string"
@ref="InputReference"
@attributes="UserAttributes"
InputType="@_passwordInput"
Lines="@Lines"
Style="@Style"
Variant="@Variant"
TextUpdateSuppression="@TextUpdateSuppression"
Value="@Text"
ValueChanged="(s) => SetTextAsync(s)"
Placeholder="@Placeholder"
Disabled=@Disabled
DisableUnderLine="@DisableUnderLine"
ReadOnly="@ReadOnly"
MaxLength="@MaxLength"
Adornment="@Adornment"
AdornmentAriaLabel="@AdornmentAriaLabel"
Error="@Error"
ErrorId="@ErrorId"
Immediate="@Immediate"
Margin="@Margin"
OnBlur="@OnBlurredAsync"
OnKeyDown="@InvokeKeyDown"
OnInternalInputChanged="OnChange"
OnKeyPress="@InvokeKeyPress"
OnKeyUp="@InvokeKeyUp"
KeyDownPreventDefault="KeyDownPreventDefault"
KeyPressPreventDefault="KeyPressPreventDefault"
KeyUpPreventDefault="KeyUpPreventDefault"
HideSpinButtons="true"
Clearable="@Clearable"
OnClearButtonClick="@OnClearButtonClick"
Pattern="@Pattern">
<AdornmentStart>
@AdornmentStart
</AdornmentStart>
<AdornmentEnd>
@if (CustomAdornment != null)
{
@CustomAdornment
}
else
{
<MudIconButton Icon="@_passwordIcon" Color="@AdornmentColor" Size="@IconSize" OnClick="AdornmentClick" tabindex="@(AdornmentTabStop ? 0 : -1)"></MudIconButton>
}
</AdornmentEnd>
</MudInputExtended>
}
else
{
<MudInputExtended T="string"
@ref="InputReference"
@attributes="UserAttributes"
InputType="@_passwordInput"
Lines="@Lines"
Style="@Style"
Variant="@Variant"
TextUpdateSuppression="@TextUpdateSuppression"
Value="@Text"
ValueChanged="(s) => SetTextAsync(s)"
Placeholder="@Placeholder"
Disabled=@Disabled
DisableUnderLine="@DisableUnderLine"
ReadOnly="@ReadOnly"
MaxLength="@MaxLength"
Adornment="@Adornment"
AdornmentAriaLabel="@AdornmentAriaLabel"
Error="@Error"
ErrorId="@ErrorId"
Immediate="@Immediate"
Margin="@Margin"
OnBlur="@OnBlurredAsync"
OnKeyDown="@InvokeKeyDown"
OnInternalInputChanged="OnChange"
OnKeyPress="@InvokeKeyPress"
OnKeyUp="@InvokeKeyUp"
KeyDownPreventDefault="KeyDownPreventDefault"
KeyPressPreventDefault="KeyPressPreventDefault"
KeyUpPreventDefault="KeyUpPreventDefault"
HideSpinButtons="true"
Clearable="@Clearable"
OnClearButtonClick="@OnClearButtonClick"
Pattern="@Pattern">
<AdornmentEnd>
@if (CustomAdornment != null)
{
@CustomAdornment
}
else
{
<MudIconButton Icon="@_passwordIcon" Color="@AdornmentColor" Size="@IconSize" OnClick="AdornmentClick" tabindex="@(AdornmentTabStop ? 0 : -1)"></MudIconButton>
}
</AdornmentEnd>
</MudInputExtended>
}
</CascadingValue>
</InputContent>
</MudInputControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public partial class MudPasswordField<T> : MudDebouncedInput<T>
/// </summary>
[Parameter] public EventCallback<MouseEventArgs> OnClearButtonClick { get; set; }

/// <summary>
/// RenderFragment for start adornment.
/// </summary>
[Parameter] public RenderFragment AdornmentStart { get; set; }

/// <summary>
/// RenderFragment for end adornment.
/// </summary>
Expand Down
21 changes: 18 additions & 3 deletions ComponentViewer.Docs/Pages/Examples/PasswordFieldExample1.razor
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
<MudGrid>
<MudItem xs="12" sm="8" Class="d-flex align-center">
<MudPasswordField @bind-Value="@_password" @bind-PasswordMode="@_passwordMode" Variant="Variant.Outlined" IconSize="_size" />
@if (_adornmentStart)
{
<MudPasswordField @bind-Value="@_password" @bind-PasswordMode="@_passwordMode" Variant="Variant.Outlined" IconSize="_size">
<AdornmentStart>
<MudIcon Icon="@Icons.Material.Filled.Key"/>
</AdornmentStart>
</MudPasswordField>
}
else
{
<MudPasswordField @bind-Value="@_password" @bind-PasswordMode="@_passwordMode" Variant="Variant.Outlined" IconSize="_size" />
}
</MudItem>

<MudItem xs="12" sm="4">
<MudSwitchM3 @bind-Checked="_passwordMode" Color="Color.Secondary">Password Mode</MudSwitchM3>
<MudSelectExtended @bind-Value="_size" ItemCollection="Enum.GetValues<Size>()" Label="Icon Size" Variant="Variant.Outlined" />
<MudStack>
<MudSwitchM3 @bind-Checked="_passwordMode" Color="Color.Secondary">Password Mode</MudSwitchM3>
<MudSwitchM3 @bind-Checked="_adornmentStart" Color="Color.Secondary">Adornment Start</MudSwitchM3>
<MudSelectExtended @bind-Value="_size" ItemCollection="Enum.GetValues<Size>()" Label="Icon Size" Variant="Variant.Outlined"/>
</MudStack>
</MudItem>
</MudGrid>

@code{
string _password = "asdf";
bool _passwordMode;
bool _adornmentStart;
Size _size = Size.Medium;
}