using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Rendering; using Microsoft.AspNetCore.Components.Web; namespace AntDesign { public abstract class TypographyBase : AntDomComponentBase { [Parameter] public bool Code { get; set; } = false; [Parameter] public bool Copyable { get; set; } = false; [Parameter] public TypographyCopyableConfig CopyConfig { get; set; } [Parameter] public bool Delete { get; set; } = false; [Parameter] public bool Disabled { get; set; } = false; [Parameter] public bool Editable { get; set; } = false; [Parameter] public TypographyEditableConfig EditConfig { get; set; } [Parameter] public bool Ellipsis { get; set; } = false; [Parameter] public TypographyEllipsisConfig EllipsisConfig { get; set; } [Parameter] public bool Mark { get; set; } = false; [Parameter] public bool Underline { get; set; } = false; [Parameter] public bool Strong { get; set; } = false; [Parameter] public Action OnChange { get; set; } [Parameter] public string Type { get; set; } = string.Empty; [Parameter] public RenderFragment ChildContent { get; set; } protected bool Editing => _editing; private bool _editing = false; protected abstract string HtmlType { get; } protected virtual bool IsKeyboard => false; private const string PrefixName = "ant-typography"; protected override void OnInitialized() { base.OnInitialized(); SetClassMap(); } private void SetClassMap() { ClassMapper .Add(PrefixName) .GetIf(() => $"{PrefixName}-{Type}", () => !string.IsNullOrEmpty(Type)) .GetIf(() => $"{PrefixName}-{HtmlType}", () => Editing) .If($"{PrefixName}-disabled", () => Disabled) .If($"{PrefixName}-edit-content", () => Editing) .If($"{PrefixName}-rtl", () => RTL); } private RenderFragment CopyIcon() { return builder => { builder.OpenElement(12, "div"); builder.AddAttribute(13, "onclick", Copy); builder.AddAttribute(14, "style", "border: 0px; background: transparent; padding: 0px; line-height: inherit; display: inline-block;"); builder.AddAttribute(15, "class", $"{PrefixName}-copy"); builder.AddAttribute(16, "tabindex", 0); builder.AddAttribute(17, "role", "button"); builder.OpenComponent(18); builder.AddAttribute(19, "Type", "copy"); builder.AddAttribute(20, "Theme", IconThemeType.Outline); builder.CloseComponent(); builder.CloseElement(); }; } private RenderFragment EditIcon() { return builder => { builder.OpenElement(21, "div"); builder.AddAttribute(22, "class", $"{PrefixName}-edit"); builder.AddAttribute(23, "role", "button"); builder.AddAttribute(24, "tabindex", 0); builder.AddAttribute(25, "aria-label", "edit"); builder.AddAttribute(26, "style", "border: 0px; background: transparent; padding: 0px; line-height: inherit; display: inline-block;"); builder.AddAttribute(27, "onclick", ToggleEditing); builder.OpenComponent(28); builder.AddAttribute(29, "Type", "edit"); builder.AddAttribute(30, "Theme", IconThemeType.Outline); builder.CloseComponent(); builder.CloseElement(); }; } private RenderFragment EditTextArea() { return builder => { builder.OpenComponent