Skip to content

Commit

Permalink
SelectInput component code commented for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
gvreddy04 committed Dec 13, 2024
1 parent 0457f93 commit 0fa906f
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal override IEnumerable<NavItem> GetNavItems()
new (){ Id = "403", Text = "Number Input", Href = RouteConstants.Demos_NumberInput_Documentation, IconName = IconName.InputCursor, ParentId = "4" },
new (){ Id = "403", Text = "Radio Input", Href = RouteConstants.Demos_RadioInput_Documentation, IconName = IconName.RecordCircle, ParentId = "4" },
new (){ Id = "404", Text = "Range Input", Href = RouteConstants.Demos_RangeInput_Documentation, IconName = IconName.Sliders, ParentId = "4" },
new (){ Id = "404", Text = "Select Input", Href = RouteConstants.Demos_SelectInput_Documentation, IconName = IconName.MenuButtonWideFill, ParentId = "4" },
//new (){ Id = "404", Text = "Select Input", Href = RouteConstants.Demos_SelectInput_Documentation, IconName = IconName.MenuButtonWideFill, ParentId = "4" },
new (){ Id = "405", Text = "Switch", Href = RouteConstants.Demos_Switch_Documentation, IconName = IconName.ToggleOn, ParentId = "4" },
new (){ Id = "406", Text = "Text Input", Href = RouteConstants.Demos_TextInput_Documentation, IconName = IconName.InputCursorText, ParentId = "4" },
new (){ Id = "407", Text = "Text Area Input", Href = RouteConstants.Demos_TextAreaInput_Documentation, IconName = IconName.InputCursorText, ParentId = "4" },
Expand Down
8 changes: 4 additions & 4 deletions BlazorBootstrap.Demo.RCL/Components/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.CodeSlash" class="me-2" /> Script Loader</h4>
</a>
</div>
<div class="col-sm-4 mb-2">
@* <div class="col-sm-4 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="@RouteConstants.Demos_SelectInput_Documentation">
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.MenuButtonWideFill" class="me-2" /> Select Input <Badge Color="BadgeColor.Danger">New</Badge></h4>
</a>
</div>
</div> *@
<div class="col-sm-4 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="/sidebar">
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.LayoutSidebarInset" class="me-2" /> Sidebar</h4>
Expand Down Expand Up @@ -309,11 +309,11 @@
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.Sliders" class="me-2" /> Range Input</h4>
</a>
</div>
<div class="col-sm-4 mb-2">
@* <div class="col-sm-4 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="@RouteConstants.Demos_SelectInput_Documentation">
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.MenuButtonWideFill" class="me-2" /> Select Input <Badge Color="BadgeColor.Danger">New</Badge></h4>
</a>
</div>
</div> *@
<div class="col-sm-4 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="/form/switch">
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.ToggleOn" class="me-2" /> Switch</h4>
Expand Down
4 changes: 2 additions & 2 deletions blazorbootstrap/Components/Form/SelectInput/SelectInput.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@namespace BlazorBootstrap
@* @namespace BlazorBootstrap
@inherits BlazorBootstrapComponentBase
<input @ref="@Element"
Expand All @@ -12,4 +12,4 @@
maxlength="@MaxLength"
autocomplete="@autoComplete"
@attributes="@AdditionalAttributes"
@onchange="OnChange" />
@onchange="OnChange" /> *@
232 changes: 116 additions & 116 deletions blazorbootstrap/Components/Form/SelectInput/SelectInput.razor.cs
Original file line number Diff line number Diff line change
@@ -1,116 +1,116 @@
namespace BlazorBootstrap;

public partial class SelectInput : BlazorBootstrapComponentBase
{
#region Fields and Constants

private FieldIdentifier fieldIdentifier;

#endregion

#region Methods

protected override void OnInitialized()
{
AdditionalAttributes ??= new Dictionary<string, object>();

fieldIdentifier = FieldIdentifier.Create(ValueExpression);

base.OnInitialized();
}

/// <summary>
/// Disables number input.
/// </summary>
public void Disable() => Disabled = true;

/// <summary>
/// Enables number input.
/// </summary>
public void Enable() => Disabled = false;

private async Task OnChange(ChangeEventArgs e)
{
var oldValue = Value;
var newValue = e.Value?.ToString() ?? string.Empty; // object

await ValueChanged.InvokeAsync(newValue);

EditContext?.NotifyFieldChanged(fieldIdentifier);
}

#endregion

#region Properties, Indexers

protected override string? ClassNames =>
BuildClassNames(
Class,
(BootstrapClass.FormControl, true),
(TextAlignment.ToTextAlignmentClass(), TextAlignment != Alignment.None)
);

private string autoComplete => AutoComplete ? "true" : "false";

/// <summary>
/// If <see langword="true" />, NumberInput can complete the values automatically by the browser.
/// </summary>
/// <remarks>
/// Default value is false.
/// </remarks>
[Parameter]
public bool AutoComplete { get; set; }

/// <summary>
/// Gets or sets the disabled state.
/// </summary>
/// <remarks>
/// Default value is false.
/// </remarks>
[Parameter]
public bool Disabled { get; set; }

[CascadingParameter] private EditContext EditContext { get; set; } = default!;

private string fieldCssClasses => EditContext?.FieldCssClass(fieldIdentifier) ?? "";

/// <summary>
/// Gets or sets the maximum length of the input.
/// </summary>
[Parameter]
public int? MaxLength { get; set; }

/// <summary>
/// Gets or sets the placeholder.
/// </summary>
/// <remarks>
/// Default value is null.
/// </remarks>
[Parameter]
public string? Placeholder { get; set; }

/// <summary>
/// Gets or sets the text alignment.
/// </summary>
/// <remarks>
/// Default value is <see cref="Alignment.None" />.
/// </remarks>
[Parameter]
public Alignment TextAlignment { get; set; } = Alignment.None;

/// <summary>
/// Gets or sets the value.
/// </summary>
[Parameter]
public string Value { get; set; } = default!;

/// <summary>
/// This event fired on every user keystroke that changes the NumberInput value.
/// </summary>
[Parameter]
public EventCallback<string> ValueChanged { get; set; }

[Parameter] public Expression<Func<string>> ValueExpression { get; set; } = default!;

#endregion
}
//namespace BlazorBootstrap;

//public partial class SelectInput : BlazorBootstrapComponentBase
//{
// #region Fields and Constants

// private FieldIdentifier fieldIdentifier;

// #endregion

// #region Methods

// protected override void OnInitialized()
// {
// AdditionalAttributes ??= new Dictionary<string, object>();

// fieldIdentifier = FieldIdentifier.Create(ValueExpression);

// base.OnInitialized();
// }

// /// <summary>
// /// Disables number input.
// /// </summary>
// public void Disable() => Disabled = true;

// /// <summary>
// /// Enables number input.
// /// </summary>
// public void Enable() => Disabled = false;

// private async Task OnChange(ChangeEventArgs e)
// {
// var oldValue = Value;
// var newValue = e.Value?.ToString() ?? string.Empty; // object

// await ValueChanged.InvokeAsync(newValue);

// EditContext?.NotifyFieldChanged(fieldIdentifier);
// }

// #endregion

// #region Properties, Indexers

// protected override string? ClassNames =>
// BuildClassNames(
// Class,
// (BootstrapClass.FormControl, true),
// (TextAlignment.ToTextAlignmentClass(), TextAlignment != Alignment.None)
// );

// private string autoComplete => AutoComplete ? "true" : "false";

// /// <summary>
// /// If <see langword="true" />, NumberInput can complete the values automatically by the browser.
// /// </summary>
// /// <remarks>
// /// Default value is false.
// /// </remarks>
// [Parameter]
// public bool AutoComplete { get; set; }

// /// <summary>
// /// Gets or sets the disabled state.
// /// </summary>
// /// <remarks>
// /// Default value is false.
// /// </remarks>
// [Parameter]
// public bool Disabled { get; set; }

// [CascadingParameter] private EditContext EditContext { get; set; } = default!;

// private string fieldCssClasses => EditContext?.FieldCssClass(fieldIdentifier) ?? "";

// /// <summary>
// /// Gets or sets the maximum length of the input.
// /// </summary>
// [Parameter]
// public int? MaxLength { get; set; }

// /// <summary>
// /// Gets or sets the placeholder.
// /// </summary>
// /// <remarks>
// /// Default value is null.
// /// </remarks>
// [Parameter]
// public string? Placeholder { get; set; }

// /// <summary>
// /// Gets or sets the text alignment.
// /// </summary>
// /// <remarks>
// /// Default value is <see cref="Alignment.None" />.
// /// </remarks>
// [Parameter]
// public Alignment TextAlignment { get; set; } = Alignment.None;

// /// <summary>
// /// Gets or sets the value.
// /// </summary>
// [Parameter]
// public string Value { get; set; } = default!;

// /// <summary>
// /// This event fired on every user keystroke that changes the NumberInput value.
// /// </summary>
// [Parameter]
// public EventCallback<string> ValueChanged { get; set; }

// [Parameter] public Expression<Func<string>> ValueExpression { get; set; } = default!;

// #endregion
//}

0 comments on commit 0fa906f

Please sign in to comment.