internal void OnCheckboxChange(Checkbox checkbox)
        {
            var index = CheckboxItems.IndexOf(checkbox);

            Options.Switch(opts =>
            {
                if (opts[index] != null)
                {
                    opts[index].Checked = checkbox.Checked;
                }

                _selectedValues = Options.AsT0.Where(x => x.Checked).Select(x => x.Value).ToArray();
            }, opts =>
            {
                if (checkbox.Checked && !opts[index].IsIn(_selectedValues))
                {
                    _selectedValues = _selectedValues.Append(opts[index]);
                }
                else
                {
                    _selectedValues = _selectedValues.Except(new[] { opts[index] }).ToArray();
                }
            });

            CurrentValue = _selectedValues;

            if (OnChange.HasDelegate)
            {
                OnChange.InvokeAsync(CurrentValue);
            }

            StateHasChanged();
        }
Exemplo n.º 2
0
        internal void OnCheckboxChange(Checkbox checkboxBase)
        {
            if (checkboxBase is Checkbox checkbox)
            {
                int index = CheckboxItems.IndexOf(checkbox);
                if (Options[index] != null)
                {
                    Options[index].Checked = checkbox.Checked;
                }
            }

            StateHasChanged();
        }
        internal async Task OnCheckboxChange(AntCheckboxBase checkboxBase)
        {
            if (checkboxBase is AntCheckbox checkbox)
            {
                int index = CheckboxItems.IndexOf(checkbox);
                if (options[index] != null)
                {
                    options[index].@checked = checkbox.@checked;
                }
            }

            StateHasChanged();
        }