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
@@ -1,5 +1,5 @@
<FluentTextInput Label="Example field"
TextFieldType="TextInputType.Password"
TextInputType="TextInputType.Password"
@bind-Value="@MyValue"
Immediate="true"
MessageCondition="@(i => i.When(() => MyValue.Length < 8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</EndTemplate>
</FluentTextInput>

<FluentTextInput Label="Email" TextFieldType="TextInputType.Email" @bind-Value="@Sometext2" Style="width: 300px;">
<FluentTextInput Label="Email" TextInputType="TextInputType.Email" @bind-Value="@Sometext2" Style="width: 300px;">
<StartTemplate>
<FluentIcon Value="@(new Icons.Regular.Size20.Mail())" />
</StartTemplate>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<FluentStack Orientation="Orientation.Vertical" VerticalGap="10">
<FluentTextInput Label="Text" Placeholder="Text" @bind-Value="@Value" TextInputType="TextInputType.Text" />
<FluentTextInput Label="Email" Placeholder="Email" @bind-Value="@Value" TextInputType="TextInputType.Email" />
<FluentTextInput Label="Password" Placeholder="Password" @bind-Value="@Value" TextInputType="TextInputType.Password" />
<FluentTextInput Label="Telephone" Placeholder="Telephone" @bind-Value="@Value" TextInputType="TextInputType.Telephone" />
<FluentTextInput Label="Url" Placeholder="Url" @bind-Value="@Value" TextInputType="TextInputType.Url" />
<FluentTextInput Label="Color" Width="50px" Placeholder="Color" @bind-Value="@Value" TextInputType="TextInputType.Color" />
<FluentTextInput Label="Search" Placeholder="Search" @bind-Value="@Value" TextInputType="TextInputType.Search" />
<FluentTextInput Label="Number" Placeholder="Number" @bind-Value="@Value" TextInputType="TextInputType.Number" />
</FluentStack>

<FluentLabel>Value = @Value</FluentLabel>

@code
{
string Value = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ You can also use these extra parameters to customize the masking behavior:
All these parameters must be defined when the component is first rendered.
You cannot modify them dynamically.

## TextInput types

You can set the `TextInputType` property to define the type of the text input. This relies on browser supplied support for the different types and can therefore vary between browsers.


{{ TextInputTypes }}

## API FluentTextInput

{{ API Type=FluentTextInput }}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<FluentTextInput Id="width"
@bind-Value="@_width"
Style="width: 100%;"
TextFieldType="TextInputType.Text"
InputMode="TextInputMode.Numeric"
Immediate="true"
ImmediateDelay="200"
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Components/TextInput/FluentTextInput.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
slot="@FluentSlot.FieldInput"
spellcheck="@Spellcheck"
control-size="@Size.ToAttributeValue()"
type="@TextFieldType.ToAttributeValue()"
type="@TextInputType.ToAttributeValue()"
value="@CurrentValueAsString"
@onfocusout="@FocusOutHandlerAsync"
@onchange="@ChangeHandlerAsync"
Expand Down
5 changes: 3 additions & 2 deletions src/Core/Components/TextInput/FluentTextInput.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ public FluentTextInput(LibraryConfiguration configuration) : base(configuration)
public string? Width { get; set; }

/// <summary>
/// Gets or sets the text filed type. See <see cref="Components.TextInputType"/>
/// Gets or sets the text input type. See <see cref="Components.TextInputType"/>
/// This relies on browser support for different input types and can therefore vary between browsers.
/// </summary>
[Parameter]
public TextInputType? TextFieldType { get; set; }
public TextInputType? TextInputType { get; set; }

/// <summary>
/// Gets or sets the size of the input. See <see cref="Components.TextInputSize"/>
Expand Down
20 changes: 19 additions & 1 deletion src/Core/Enums/TextInputType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,23 @@ public enum TextInputType
/// A text field that is used for URL input.
/// </summary>
[Description("url")]
Url
Url,

/// <summary>
/// A text field that is used for color input (hexadecimal color value).
/// </summary>
[Description("color")]
Color,

/// <summary>
/// A text field that is used to search for a value. (accessibility)
/// </summary>
[Description("search")]
Search,

/// <summary>
/// A text field that is used for number input.
/// </summary>
[Description("number")]
Number,
}
9 changes: 6 additions & 3 deletions tests/Core/Components/TextInput/FluentTextInputTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@
[InlineData(TextInputType.Password, "password")]
[InlineData(TextInputType.Telephone, "tel")]
[InlineData(TextInputType.Url, "url")]
public void FluentInputText_TextFieldType(TextInputType type, string expectedAttribute)
[InlineData(TextInputType.Color, "color")]
[InlineData(TextInputType.Search, "search")]
[InlineData(TextInputType.Number, "number")]
public void FluentInputText_TextInputType(TextInputType type, string expectedAttribute)
{
// Arrange && Act
using var context = new IdentifierContext(i => "myId");
var cut = Render(@<FluentTextInput TextFieldType="@type" />);
var cut = Render(@<FluentTextInput TextInputType="@type" />);

// Assert
cut.Find("fluent-text-input")
Expand All @@ -92,7 +95,7 @@
public void FluentInputText_Size(TextInputSize? size)
{
// Arrange && Act

var cut = Render(@<FluentTextInput Size="@size" />);

// Assert
Expand Down
Loading