示例#1
0
        protected BaseMatInputTextComponent()
        {
            OnFocusEvent    = new MatEventCallback <FocusEventArgs>(this, () => OnFocus);
            OnFocusOutEvent = new MatEventCallback <FocusEventArgs>(this, () => OnFocusOut);

            ClassMapper
            .Add("mat-text-field")
            .Add("mdc-text-field")
            .Get(() => this.FieldClass)
            .If("mdc-text-field--filled", () => !this.Outlined)
            // .Add("_mdc-text-field--upgraded")
            .If("mdc-text-field--with-leading-icon", () => this.Icon != null && !this.IconTrailing)
            .If("mdc-text-field--with-trailing-icon", () => this.Icon != null && this.IconTrailing)
            .If("mdc-text-field--box", () => !this.FullWidth && this.Box)
            .If("mdc-text-field--dense", () => Dense)
            .If("mdc-text-field--outlined", () => !this.FullWidth && this.Outlined)
            .If("mdc-text-field--disabled", () => this.Disabled)
            .If("mdc-text-field--fullwidth", () => this.FullWidth)
            .If("mdc-text-field--fullwidth-with-leading-icon",
                () => this.FullWidth && this.Icon != null && !this.IconTrailing)
            .If("mdc-text-field--fullwidth-with-trailing-icon",
                () => this.FullWidth && this.Icon != null && this.IconTrailing)
            .If("mdc-text-field--textarea", () => this.TextArea);

            bool TextOrPlaceHolderVisible()
            {
                return(!string.IsNullOrEmpty(CurrentValueAsString) ||
                       (!string.IsNullOrWhiteSpace(PlaceHolder) && FullWidth));
            }

            LabelClassMapper
            .Add("mdc-floating-label")
            .If("mat-floating-label--float-above-outlined",
                () => Outlined && TextOrPlaceHolderVisible())
            .If("mdc-floating-label--float-above", () => TextOrPlaceHolderVisible());

            InputClassMapper
            .Get(() => this.InputClass)
            .Add("mat-text-field-input")
            .Add("mdc-text-field__input")
            // .If("_mdc-text-field--upgraded", () => !string.IsNullOrEmpty(CurrentValueAsString))
            .If("mat-hide-clearbutton", () => this.HideClearButton);

            CallAfterRender(async() => { await JsInvokeAsync <object>("matBlazor.matTextField.init", Ref); });
        }
示例#2
0
 protected BaseMatComponent()
 {
     ClassMapper.Get(() => this.Class);
 }