1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2025-08-16 12:31:43 +02:00
Files
.config
.run
.workdir
Agent
Common
Docker
Server
Phantom.Server
Phantom.Server.Database
Phantom.Server.Database.Postgres
Phantom.Server.Rpc
Phantom.Server.Services
Phantom.Server.Web
Phantom.Server.Web.Bootstrap
Phantom.Server.Web.Components
Forms
Base
FormInputBase.cs
FormInputBaseDebounced.cs
ICustomFormField.cs
Fields
FormButtonSubmit.cs
FormLabel.razor
FormNumberInput.razor
FormNumberInputType.cs
FormSelectInput.razor
FormTextInput.razor
Graphics
Utils
Phantom.Server.Web.Components.csproj
_Imports.razor
Utils
.gitattributes
.gitignore
AddMigration.bat
AddMigration.sh
PhantomPanel.sln
global.json

43 lines
1.0 KiB
C#

using System.Linq.Expressions;
using Microsoft.AspNetCore.Components;
namespace Phantom.Server.Web.Components.Forms.Base;
public abstract class FormInputBase<TValue> : ComponentBase {
[Parameter, EditorRequired]
public string Id { get; set; } = null!;
[Parameter]
public string? Label { get; set; }
[Parameter]
public RenderFragment? LabelFragment { get; set; }
[Parameter]
public TValue? Value { get; set; }
[Parameter]
public EventCallback<TValue?> ValueChanged { get; set; }
[Parameter]
public Expression<Func<TValue?>>? ValueExpression { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
public IReadOnlyDictionary<string, object>? AdditionalAttributes { get; set; }
protected IReadOnlyDictionary<string, object> GetAttributes(string cssClass) {
Dictionary<string, object> result = new (2 + (AdditionalAttributes?.Count ?? 0)) {
["id"] = Id,
["class"] = cssClass
};
if (AdditionalAttributes != null) {
foreach (var (key, value) in AdditionalAttributes) {
result[key] = value;
}
}
return result;
}
}