|
1 | 1 | @use 'sass:map';
|
2 | 2 | @use '@material/checkbox/checkbox' as mdc-checkbox;
|
3 | 3 | @use '@material/checkbox/checkbox-theme' as mdc-checkbox-theme;
|
| 4 | +@use '@material/radio/radio' as mdc-radio; |
| 5 | +@use '@material/radio/radio-theme' as mdc-radio-theme; |
4 | 6 |
|
5 | 7 | @use '../core/mdc-helpers/mdc-helpers';
|
6 | 8 | @use '../checkbox/checkbox-private';
|
| 9 | +@use '../radio/radio-private'; |
7 | 10 | @use './list-option-trailing-avatar-compat';
|
8 | 11 | @use './list-item-hcm-indicator';
|
9 | 12 |
|
|
12 | 15 | @include list-option-trailing-avatar-compat.core-styles($query: mdc-helpers.$mdc-base-styles-query);
|
13 | 16 |
|
14 | 17 | .mat-mdc-list-option {
|
15 |
| - // The MDC-based list-option uses the MDC checkbox for the selection indicators. |
16 |
| - // We need to ensure that the checkbox styles are not included for the list-option. |
| 18 | + // The MDC-based list-option uses the MDC checkbox/radio for the selection indicators. |
| 19 | + // We need to ensure that the checkbox and radio styles are not included for the list-option. |
17 | 20 | @include mdc-helpers.disable-mdc-fallback-declarations {
|
18 | 21 | @include mdc-checkbox.static-styles(
|
19 | 22 | $query: mdc-helpers.$mdc-base-styles-without-animation-query);
|
| 23 | + @include mdc-radio.static-styles( |
| 24 | + $query: mdc-helpers.$mdc-base-styles-without-animation-query); |
20 | 25 |
|
21 | 26 | &:not(._mat-animation-noopable) {
|
22 | 27 | @include mdc-checkbox.static-styles($query: animation);
|
| 28 | + @include mdc-radio.static-styles($query: animation); |
23 | 29 | }
|
24 | 30 | }
|
25 | 31 |
|
26 |
| - // We can't use the MDC checkbox here directly, because this checkbox is purely |
27 |
| - // decorative and including the MDC one will bring in unnecessary JS. |
28 |
| - .mdc-checkbox { |
29 |
| - $config: map.merge(checkbox-private.$private-checkbox-theme-config, ( |
30 |
| - // Since this checkbox isn't interactive, we can exclude the focus/hover/press styles. |
| 32 | + $without-ripple-config: ( |
| 33 | + // Since this checkbox/radio isn't interactive, we can exclude the focus/hover/press styles. |
31 | 34 | selected-focus-icon-color: null,
|
32 | 35 | selected-hover-icon-color: null,
|
33 | 36 | selected-pressed-icon-color: null,
|
34 | 37 | unselected-focus-icon-color: null,
|
35 | 38 | unselected-hover-icon-color: null,
|
36 | 39 | unselected-pressed-icon-color: null,
|
37 |
| - )); |
| 40 | + ); |
| 41 | + |
| 42 | + // We can't use the MDC checkbox here directly, because this checkbox is purely |
| 43 | + // decorative and including the MDC one will bring in unnecessary JS. |
| 44 | + .mdc-checkbox { |
| 45 | + $config: map.merge(checkbox-private.$private-checkbox-theme-config, $without-ripple-config); |
38 | 46 |
|
39 | 47 | // MDC theme styles also include structural styles so we have to include the theme at least
|
40 | 48 | // once here. The values will be overwritten by our own theme file afterwards.
|
41 | 49 | @include mdc-checkbox-theme.theme-styles($config);
|
42 | 50 | }
|
43 | 51 |
|
44 |
| - // The internal checkbox is purely decorative, but because it's an `input`, the user can still |
45 |
| - // focus it by tabbing or clicking. Furthermore, `mat-list-option` has the `option` role which |
46 |
| - // doesn't allow a nested `input`. We use `display: none` both to remove it from the tab order |
47 |
| - // and to prevent focus from reaching it through the screen reader's forms mode. Ideally we'd |
48 |
| - // remove the `input` completely, but we can't because MDC uses a `:checked` selector to |
| 52 | + // We can't use the MDC radio here directly, because this radio is purely |
| 53 | + // decorative and including the MDC one will bring in unnecessary JS. |
| 54 | + .mdc-radio { |
| 55 | + $config: map.merge(radio-private.$private-radio-theme-config, $without-ripple-config); |
| 56 | + |
| 57 | + // MDC theme styles also include structural styles so we have to include the theme at least |
| 58 | + // once here. The values will be overwritten by our own theme file afterwards. |
| 59 | + @include mdc-radio-theme.theme-styles($config); |
| 60 | + } |
| 61 | + |
| 62 | + |
| 63 | + // The internal checkbox/radio is purely decorative, but because it's an `input`, the user can |
| 64 | + // still focus it by tabbing or clicking. Furthermore, `mat-list-option` has the `option` role |
| 65 | + // which doesn't allow a nested `input`. We use `display: none` both to remove it from the tab |
| 66 | + // order and to prevent focus from reaching it through the screen reader's forms mode. Ideally |
| 67 | + // we'd remove the `input` completely, but we can't because MDC uses a `:checked` selector to |
49 | 68 | // toggle the selected styles.
|
50 |
| - .mdc-checkbox__native-control { |
| 69 | + .mdc-checkbox__native-control, .mdc-radio__native-control { |
51 | 70 | display: none;
|
52 | 71 | }
|
53 | 72 | }
|
|
0 commit comments