protected override void SetClasses() { base.SetClasses(); //ant-input-password-large ant-input-affix-wrapper ant-input-affix-wrapper-lg ClassMapper .If($"{PrefixCls}-password-large", () => Size == InputSize.Large) .If($"{PrefixCls}-password-small", () => Size == InputSize.Small); AffixWrapperClass = string.Join(" ", AffixWrapperClass, $"{PrefixCls}-password"); if (VisibilityToggle) { Suffix = new RenderFragment((builder) => { int i = 0; builder.OpenElement(i++, "span"); builder.AddAttribute(i++, "class", $"{PrefixCls}-suffix"); builder.OpenComponent <AntIcon>(i++); builder.AddAttribute(i++, "class", $"{PrefixCls}-password-icon"); builder.AddAttribute(i++, "type", _eyeIcon); builder.AddAttribute(i++, "onclick", CallbackFactory.Create(this, ToggleVisibility)); builder.CloseComponent(); builder.CloseElement(); }); } }
protected override void OnInitialized() { base.OnInitialized(); if (EnterButton.IsT0 && !EnterButton.AsT0) { Suffix = builder => { var i = 0; builder.OpenComponent <Icon>(i++); builder.AddAttribute(i++, "Class", $"{PrefixCls}-search-icon"); if (Loading) { builder.AddAttribute(i++, "Type", "loading"); } else { builder.AddAttribute(i++, "Type", "search"); } builder.AddAttribute(i++, "OnClick", CallbackFactory.Create <MouseEventArgs>(this, HandleSearch)); builder.CloseComponent(); }; } else { AddOnAfter = builder => { builder.OpenComponent <Button>(_sequence++); builder.AddAttribute(_sequence++, "Class", $"{PrefixCls}-search-button"); builder.AddAttribute(_sequence++, "Type", "primary"); builder.AddAttribute(_sequence++, "Size", Size); if (Loading) { builder.AddAttribute(_sequence++, "Loading", true); } else { builder.AddAttribute(_sequence++, "OnClick", CallbackFactory.Create <MouseEventArgs>(this, HandleSearch)); } EnterButton.Switch(boolean => { if (boolean) { builder.AddAttribute(_sequence++, "Icon", "search"); } }, str => { builder.AddAttribute(_sequence++, "ChildContent", new RenderFragment((b) => { b.AddContent(_sequence++, str); })); }); builder.CloseComponent(); }; } }
protected override void OnInitialized() { base.OnInitialized(); if (EnterButton.Value == null) { Suffix = new RenderFragment((builder) => { builder.OpenComponent <Icon>(35); builder.AddAttribute(36, "class", $"{PrefixCls}-search-icon"); builder.AddAttribute(37, "type", "search"); builder.AddAttribute(38, "onclick", CallbackFactory.Create <MouseEventArgs>(this, HandleSearch)); builder.CloseComponent(); }); } else { AddOnAfter = new RenderFragment((builder) => { builder.OpenComponent <Button>(_sequence++); builder.AddAttribute(_sequence++, "class", $"{PrefixCls}-search-button"); builder.AddAttribute(_sequence++, "type", "primary"); builder.AddAttribute(_sequence++, "size", Size); if (_isSearching) { builder.AddAttribute(_sequence++, "loading", true); } else { var e = new EventCallbackFactory().Create(this, HandleSearch); builder.AddAttribute(_sequence++, "onclick", e); } EnterButton.Switch(boolean => { if (boolean) { builder.AddAttribute(_sequence++, "icon", "search"); } }, str => { builder.AddAttribute(_sequence++, "ChildContent", new RenderFragment((b) => { b.AddContent(_sequence++, str); })); }); builder.CloseComponent(); }); } }
protected override void SetClasses() { base.SetClasses(); //ant-input-password-large ant-input-affix-wrapper ant-input-affix-wrapper-lg ClassMapper .If($"{PrefixCls}-password-large", () => Size == InputSize.Large) .If($"{PrefixCls}-password-small", () => Size == InputSize.Small) .If($"{PrefixCls}-password-rtl", () => RTL); AffixWrapperClass = string.Join(" ", AffixWrapperClass, $"{PrefixCls}-password"); if (VisibilityToggle) { Suffix = new RenderFragment((builder) => { int i = 0; builder.OpenElement(i++, "span"); builder.AddAttribute(i++, "class", $"{PrefixCls}-suffix"); builder.OpenComponent <Icon>(i++); builder.AddAttribute(i++, "class", $"{PrefixCls}-password-icon"); builder.AddAttribute(i++, "type", _eyeIcon); builder.AddAttribute(i++, "onclick", CallbackFactory.Create <MouseEventArgs>(this, async args => { var element = await JsInvokeAsync <HtmlElement>(JSInteropConstants.GetDomInfo, Ref); IsFocused = true; await this.FocusAsync(Ref); ToggleVisibility(args); if (element.SelectionStart != 0) { await Js.SetSelectionStartAsync(Ref, element.SelectionStart); } })); builder.CloseComponent(); builder.CloseElement(); }); } }
protected override void OnInitialized() { base.OnInitialized(); if (EnterButton.IsT0 && !EnterButton.AsT0) { if (ClassicSearchIcon) { Suffix = builder => { builder.OpenComponent <Icon>(1); builder.AddAttribute(2, "Class", $"{PrefixCls}-search-icon"); if (Loading) { builder.AddAttribute(3, "Type", "loading"); } else { builder.AddAttribute(4, "Type", "search"); } builder.AddAttribute(5, "OnClick", CallbackFactory.Create <MouseEventArgs>(this, HandleSearch)); builder.CloseComponent(); }; } else { AddOnAfter = builder => { builder.OpenComponent <Button>(6); builder.AddAttribute(7, "Class", $"{PrefixCls}-search-button"); builder.AddAttribute(8, "Type", "default"); builder.AddAttribute(9, "Size", Size); builder.AddAttribute(10, "Loading", Loading); if (!Loading) { builder.AddAttribute(12, "OnClick", CallbackFactory.Create <MouseEventArgs>(this, HandleSearch)); } builder.AddAttribute(13, "Icon", "search"); builder.CloseComponent(); }; } } else { AddOnAfter = builder => { builder.OpenComponent <Button>(11); builder.AddAttribute(12, "Class", $"{PrefixCls}-search-button"); builder.AddAttribute(13, "Type", "primary"); builder.AddAttribute(14, "Size", Size); builder.AddAttribute(15, "Loading", Loading); if (!Loading) { builder.AddAttribute(16, "OnClick", CallbackFactory.Create <MouseEventArgs>(this, HandleSearch)); } EnterButton.Switch(boolean => { if (boolean) { builder.AddAttribute(17, "Icon", "search"); } }, str => { builder.AddAttribute(18, "ChildContent", new RenderFragment((b) => { b.AddContent(19, str); })); }); builder.CloseComponent(); }; } }