// Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ConditionalCssClasses
            .AddIf("mdc-card--outlined", () => CascadingDefaults.AppliedStyle(CardStyle) == MBCardStyle.Outlined);
        }
Exemple #2
0
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ConditionalCssClasses
            .AddIf(DensityInfo.CssClassName, () => DensityInfo.ApplyCssClass)
            .AddIf(FieldClass, () => !string.IsNullOrWhiteSpace(FieldClass))
            .AddIf("mdc-text-field--filled", () => AppliedInputStyle == MBTextInputStyle.Filled)
            .AddIf("mdc-text-field--outlined", () => AppliedInputStyle == MBTextInputStyle.Outlined)
            .AddIf("mdc-text-field--no-label", () => !ShowLabel)
            .AddIf("mdc-text-field--disabled", () => AppliedDisabled);

            FloatingLabelClass = string.IsNullOrEmpty(ComponentValue) ? "" : "mdc-floating-label--float-above";

            SetComponentValue += OnValueSetCallback;
            OnDisabledSet     += OnDisabledSetCallback;

            if (EditContext != null)
            {
                EditContext.OnValidationStateChanged += OnValidationStateChangedCallback;

                if (HasRequiredAttribute(ValidationMessageFor))
                {
                    LabelSuffix = " *";
                }
            }
        }
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ConditionalCssClasses
            .AddIf("mdc-deprecated-list-divider--inset", () => Inset)
            .AddIf("mdc-deprecated-list-divider--padded", () => Padded);
        }
Exemple #4
0
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ConditionalCssClasses
            .AddIf("mb-badge--dot", () => BadgeStyle == MBBadgeStyle.Dot)
            .AddIf("mb-badge--exited", () => Exited);
        }
Exemple #5
0
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ConditionalCssClasses
            .AddIf(GetMenuSurfacePositioningClass(MenuSurfacePositioning), () => MenuSurfacePositioning != MBMenuSurfacePositioning.Regular);

            ObjectReference = DotNetObjectReference.Create(this);
        }
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ConditionalCssClasses
            .AddIf("mdc-drawer--dismissible", () => IsDismissible)
            .AddIf("mdc-drawer--open", () => StartOpen);

            isOpen = StartOpen;
        }
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ConditionalCssClasses
            .AddIf("mdc-top-app-bar--fixed", () => (TopAppBarType & MBTopAppBarType.Fixed) == MBTopAppBarType.Fixed)
            .AddIf("mdc-top-app-bar--dense", () => (TopAppBarType & MBTopAppBarType.Dense) == MBTopAppBarType.Dense)
            .AddIf("mdc-top-app-bar--prominent", () => (TopAppBarType & MBTopAppBarType.Prominent) == MBTopAppBarType.Prominent)
            .AddIf("mdc-top-app-bar--short", () => (TopAppBarType & MBTopAppBarType.Short) == MBTopAppBarType.Short)
            .AddIf("mdc-top-app-bar--short mdc-top-app-bar--short-collapsed", () => (TopAppBarType & MBTopAppBarType.ShortCollapsed) == MBTopAppBarType.ShortCollapsed);
        }
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ConditionalCssClasses
            .AddIf("mdc-switch--unselected", () => !ComponentValue)
            .AddIf("mdc-switch--selected", () => ComponentValue);

            SetComponentValue += OnValueSetCallback;
            OnDisabledSet     += OnDisabledSetCallback;
        }
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ObjectReference = DotNetObjectReference.Create(this);

            ConditionalCssClasses
            .AddIf(DensityInfo.CssClassName, () => DensityInfo.ApplyCssClass);

            SetComponentValue += OnValueSetCallback;
        }
Exemple #10
0
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ConditionalCssClasses
            .AddIf(DensityInfo.CssClassName, () => DensityInfo.ApplyCssClass && NumberOfLines == 1 && AppliedListType != MBListType.Dense)
            .AddIf("mdc-card--outlined", () => (CascadingDefaults.AppliedStyle(AppliedListStyle) == MBListStyle.Outlined))
            .AddIf("mdc-deprecated-list--two-line", () => (NumberOfLines == 2))
            .AddIf("mb-list--three-line", () => (NumberOfLines == 3))
            .AddIf("mdc-deprecated-list--non-interactive", () => NonInteractive)
            .AddIf("mdc-deprecated-list--dense", () => AppliedListType == MBListType.Dense)
            .AddIf("mdc-deprecated-list--avatar-list", () => AppliedListType == MBListType.Avatar);
        }
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            MBItemValidation appliedItemValidation = CascadingDefaults.AppliedItemValidation(ItemValidation);

            ForceShouldRenderToTrue = true;

            bool hasValue;

            (hasValue, ComponentValue) = ValidateItemList(Items, appliedItemValidation);

            ConditionalCssClasses.AddIf("mb-mdc-radio-group-vertical", () => Vertical);
        }
Exemple #12
0
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            ConditionalCssClasses
            .AddIf(DensityInfo.CssClassName, () => DensityInfo.ApplyCssClass)
            .AddIf("mdc-checkbox--disabled", () => AppliedDisabled);

            InputDisabled = AppliedDisabled;
            IsChecked     = ComponentValue != null && ComponentValue.Equals(TargetCheckedValue);

            ForceShouldRenderToTrue = true;

            SetComponentValue += OnValueSetCallback;
            OnDisabledSet     += OnDisabledSetCallback;
        }
Exemple #13
0
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            IsSingleSelect = SegmentedButtonSingle != null;

            ConditionalCssClasses
            .AddIf("mdc-segmented-button--single-select", () => IsSingleSelect);

            ItemsArray = Items.ToArray();

            SegmentAttributes = new Dictionary <string, object> [ItemsArray.Length];

            for (int i = 0; i < ItemsArray.Length; i++)
            {
                SegmentAttributes[i] = new();

                var selected = Value.Contains(ItemsArray[i].SelectedValue);

                SegmentAttributes[i].Add("class", "mdc-segmented-button__segment mdc-segmented-button--touch" + (selected ? " mdc-segmented-button__segment--selected" : ""));

                if (IsSingleSelect)
                {
                    SegmentAttributes[i].Add("role", "radio");
                    SegmentAttributes[i].Add("aria-checked", selected.ToString().ToLower());
                }
                else
                {
                    SegmentAttributes[i].Add("aria-pressed", selected.ToString().ToLower());
                }
            }

            SetComponentValue += OnValueSetCallback;
            OnDisabledSet     += OnDisabledSetCallback;

            ObjectReference = DotNetObjectReference.Create(this);
        }
Exemple #14
0
        // Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            if (ValueMax <= ValueMin)
            {
                throw new ArgumentException($"{GetType()} must have ValueMax ({ValueMax}) greater than ValueMin ({ValueMin})");
            }

            if (Value < ValueMin || Value > ValueMax)
            {
                throw new ArgumentException($"{GetType()} must have Value ({Value}) between ValueMin ({ValueMin}) and ValueMax ({ValueMax})");
            }

            // Reinstate these 4 lines once https://github.com/material-components/material-components-web/issues/7404 is fixed
            //Value = Math.Round(Value, (int)DecimalPlaces);
            //ValueMin = Math.Round(ValueMin, (int)DecimalPlaces);
            //ValueMax = Math.Round(ValueMax, (int)DecimalPlaces);
            //Format = $"F{DecimalPlaces}";

            // Delete once https://github.com/material-components/material-components-web/issues/7404 is fixed
            if (SliderType == MBSliderType.Continuous)
            {
                Mult = Convert.ToDecimal(Math.Pow(10, DecimalPlaces));
            }
            else
            {
                Mult = NumSteps / (ValueMax - ValueMin);
            }

            LocalValue         = Math.Round(Value * Mult, (int)DecimalPlaces);
            LocalValueMin      = Math.Round(ValueMin * Mult, (int)DecimalPlaces);
            LocalValueMax      = Math.Round(ValueMax * Mult, (int)DecimalPlaces);
            Format             = $"F0";
            ValueStepIncrement = 1;
            // End delete

            TabIndex            = AppliedDisabled ? -1 : 0;
            RangePercentDecimal = (Value - ValueMin) / (ValueMax - ValueMin);

            // Reinstate once https://github.com/material-components/material-components-web/issues/7404 is fixed
            //if (SliderType == MBSliderType.Continuous)
            //{
            //    ValueStepIncrement = Convert.ToDecimal(Math.Pow(10, -DecimalPlaces));
            //}
            //else
            //{
            //    ValueStepIncrement = (ValueMax - ValueMin) / NumSteps;
            //}

            ConditionalCssClasses
            .AddIf("mdc-slider--discrete", () => SliderType != MBSliderType.Continuous)
            .AddIf("mdc-slider--tick-marks", () => SliderType == MBSliderType.DiscreteWithTickmarks)
            .AddIf("mdc-slider--disabled", () => AppliedDisabled);

            InputMarkup = new($"<input class=\"mdc-slider__input\" type=\"range\" value=\"{LocalValue.ToString(Format)}\" step=\"{ValueStepIncrement}\" min=\"{LocalValueMin.ToString(Format)}\" max=\"{LocalValueMax.ToString(Format)}\" name=\"volume\" aria-label=\"{AriaLabel}\">");

            SetComponentValue += OnValueSetCallback;
            OnDisabledSet     += OnDisabledSetCallback;

            ObjectReference = DotNetObjectReference.Create(this);
        }