|
3 | 3 | @typeparam T |
4 | 4 | @inherits MudRadio<T> |
5 | 5 |
|
6 | | -<div class="mud-input-control mud-input-control-boolean-input mud-input-with-content"> |
7 | | - <div class="mud-input-control-input-container"> |
8 | | - <label class="mud-radio mud-input-content-placement-end" __internal_stoppropagation_onclick=""> |
9 | | - <span class="mud-button-root mud-icon-button mud-ripple mud-ripple-radio mud-default-text hover:mud-default-hover" |
10 | | - tabindex="0" |
11 | | - @onclick:stopPropagation="true"> |
12 | | - <input type="radio" |
13 | | - class="mud-radio-input" |
14 | | - tabindex="-1" |
15 | | - role="radio" |
16 | | - name="@ParentGroup?.GroupName" |
17 | | - value="@Value" |
18 | | - id="@($"static-radio-{_elementId}")" |
19 | | - checked="@IsChecked" /> |
20 | | - |
21 | | - <MudIcon Size="Size" |
22 | | - Color="HasErrors ? Color.Error : Color" |
23 | | - Icon="@(IsChecked ? CheckedIcon : UncheckedIcon)" |
24 | | - id="@($"radio-svg-{_elementId}")" /> |
| 6 | +<MudInputControl Class="@Classname" Style="@Style" Error="@HasErrors" ErrorText="@GetErrorText()" Required="@Required"> |
| 7 | + <InputContent> |
| 8 | + <label class="@LabelClassname" style="@Style" id="@_elementId" @onclick:stopPropagation="@StopClickPropagation"> |
| 9 | + <span tabindex="0" class="@IconClassname"> |
| 10 | + <input id="@($"static-radio-{_elementId}")" tabindex="-1" @attributes="UserAttributes" type="radio" role="radio" |
| 11 | + class="mud-radio-input" checked="@IsChecked" name="@ParentGroup?.Name" disabled="@GetDisabledState()" value="@Value" |
| 12 | + aria-checked="@(IsChecked.ToString().ToLower())" aria-disabled="@(GetDisabledState().ToString().ToLower())" @onclick:preventDefault="@GetReadOnlyState()" /> |
| 13 | + <MudIcon id="@($"radio-svg-{_elementId}")" Disabled="@Disabled" Icon="@(IsChecked ? CheckedIcon : UncheckedIcon)" Color="HasErrors ? Color.Error : Color.Inherit" Size="@Size" /> |
25 | 14 | </span> |
26 | | - |
27 | | - <p class="mud-typography mud-typography-body1"> |
28 | | - @ChildContent |
29 | | - </p> |
| 15 | + @if (!string.IsNullOrEmpty(Label)) |
| 16 | + { |
| 17 | + <MudText Color="HasErrors ? Color.Error : Color.Inherit">@Label</MudText> |
| 18 | + } |
| 19 | + @if (ChildContent is not null) |
| 20 | + { |
| 21 | + <MudText Color="HasErrors ? Color.Error : Color.Inherit"> |
| 22 | + @ChildContent |
| 23 | + </MudText> |
| 24 | + } |
30 | 25 | </label> |
31 | | - </div> |
32 | | -</div> |
33 | | - |
34 | | -<script> |
35 | | - (function() { |
36 | | - const radio = document.getElementById('static-radio-@_elementId'); |
37 | | - const svg = document.getElementById('radio-svg-@_elementId'); |
38 | | -
|
39 | | - const checkedIcon = '@(CheckedIcon)'; |
40 | | - const uncheckedIcon = '@(UncheckedIcon)'; |
41 | | -
|
42 | | - if (radio && svg) { |
43 | | - const handleChange = () => { |
44 | | - svg.innerHTML = radio.checked ? checkedIcon : uncheckedIcon; |
45 | | - }; |
46 | | -
|
47 | | - radio.addEventListener('change', handleChange); |
48 | | -
|
49 | | - document.addEventListener('change', (e) => { |
50 | | - if (e.target.type === 'radio' && e.target.name === radio.name && e.target !== radio) { |
51 | | - handleChange(); |
52 | | - } |
53 | | - }); |
54 | | - } |
55 | | - })(); |
56 | | -</script> |
| 26 | + </InputContent> |
| 27 | +</MudInputControl> |
57 | 28 |
|
58 | 29 | @code { |
59 | 30 | [CascadingParameter] |
|
84 | 55 |
|
85 | 56 | base.OnParametersSet(); |
86 | 57 | } |
| 58 | +} |
87 | 59 |
|
88 | | - private async Task SelectValue() |
89 | | - { |
90 | | - if (ParentGroup is not null) |
91 | | - { |
92 | | - await ParentGroup.SetValue(Value); |
| 60 | +<script> |
| 61 | + (function() { |
| 62 | + const radio = document.getElementById('static-radio-@_elementId'); |
| 63 | + const svg = document.getElementById('radio-svg-@_elementId'); |
| 64 | +
|
| 65 | + const checkedIcon = '@(CheckedIcon)'; |
| 66 | + const uncheckedIcon = '@(UncheckedIcon)'; |
| 67 | +
|
| 68 | + if (radio && svg) { |
| 69 | + const handleChange = () => { |
| 70 | + svg.innerHTML = radio.checked ? checkedIcon : uncheckedIcon; |
| 71 | + }; |
| 72 | +
|
| 73 | + radio.addEventListener('change', handleChange); |
| 74 | +
|
| 75 | + document.addEventListener('change', (e) => { |
| 76 | + if (e.target.type === 'radio' && e.target.name === radio.name && e.target !== radio) { |
| 77 | + handleChange(); |
| 78 | + } |
| 79 | + }); |
93 | 80 | } |
94 | | - } |
95 | | -} |
| 81 | + })(); |
| 82 | +</script> |
0 commit comments