@angular/material 20.1.0-next.1 → 20.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/_index.scss +1 -2
  2. package/autocomplete/_autocomplete-theme.scss +28 -37
  3. package/autocomplete/_m2-autocomplete.scss +10 -22
  4. package/badge/_badge-theme.scss +35 -44
  5. package/badge/_m2-badge.scss +46 -59
  6. package/bottom-sheet/_bottom-sheet-theme.scss +28 -40
  7. package/bottom-sheet/_m2-bottom-sheet.scss +16 -33
  8. package/button/_button-theme.scss +37 -55
  9. package/button/_fab-theme.scss +42 -56
  10. package/button/_icon-button-theme.scss +33 -49
  11. package/button/_m2-button.scss +135 -158
  12. package/button/_m2-fab.scss +60 -69
  13. package/button/_m2-icon-button.scss +30 -50
  14. package/button/_m3-button.scss +1 -2
  15. package/button/_m3-fab.scss +1 -2
  16. package/button/_m3-icon-button.scss +1 -2
  17. package/button/testing/index.d.ts +1 -0
  18. package/button-toggle/_button-toggle-theme.scss +29 -44
  19. package/button-toggle/_m2-button-toggle.scss +58 -81
  20. package/button-toggle/_m3-button-toggle.scss +1 -2
  21. package/card/_card-theme.scss +28 -36
  22. package/card/_m2-card.scss +30 -45
  23. package/checkbox/_checkbox-theme.scss +37 -50
  24. package/checkbox/_m2-checkbox.scss +30 -40
  25. package/checkbox/_m3-checkbox.scss +1 -2
  26. package/chips/_chips-theme.scss +27 -30
  27. package/chips/_m2-chip.scss +40 -53
  28. package/chips/_m3-chip.scss +1 -2
  29. package/core/_core-theme.scss +48 -67
  30. package/core/_m2-app.scss +11 -23
  31. package/core/focus-indicators/_private.scss +2 -5
  32. package/core/m2/_theming.scss +36 -41
  33. package/core/option/_m2-optgroup.scss +13 -25
  34. package/core/option/_m2-option.scss +16 -22
  35. package/core/option/_optgroup-theme.scss +28 -30
  36. package/core/option/_option-theme.scss +35 -34
  37. package/core/ripple/_m2-ripple.scss +8 -20
  38. package/core/ripple/_ripple-theme.scss +28 -33
  39. package/core/selection/pseudo-checkbox/_m2-pseudo-checkbox.scss +14 -21
  40. package/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss +55 -45
  41. package/core/theming/_all-theme.scss +38 -42
  42. package/core/theming/_definition.scss +22 -13
  43. package/core/theming/_inspection.scss +0 -12
  44. package/core/theming/_m2-inspection.scss +0 -33
  45. package/core/theming/_theming.scss +4 -172
  46. package/core/tokens/_m2-utils.scss +16 -68
  47. package/core/tokens/_m3-utils.scss +2 -14
  48. package/core/tokens/_token-utils.scss +7 -27
  49. package/core/tokens/m2/_index.scss +6 -0
  50. package/core/tokens/m2/_md-sys-color.scss +123 -0
  51. package/core/tokens/m2/_md-sys-elevation.scss +16 -0
  52. package/core/tokens/m2/_md-sys-motion.scss +36 -0
  53. package/core/tokens/m2/_md-sys-shape.scss +22 -0
  54. package/core/tokens/m2/_md-sys-state.scss +15 -0
  55. package/core/tokens/m2/_md-sys-typescale.scss +68 -0
  56. package/core/tokens/m3/_md-sys-color.scss +2 -2
  57. package/core/tokens/m3/_md-sys-typescale.scss +1 -1
  58. package/core/tokens/m3/_theme.scss +14 -26
  59. package/datepicker/_datepicker-theme.scss +38 -40
  60. package/datepicker/_m2-datepicker.scss +26 -40
  61. package/dialog/_dialog-theme.scss +28 -34
  62. package/dialog/_m2-dialog.scss +34 -48
  63. package/divider/_divider-theme.scss +28 -30
  64. package/divider/_m2-divider.scss +10 -21
  65. package/expansion/_expansion-theme.scss +28 -39
  66. package/expansion/_m2-expansion.scss +52 -67
  67. package/expansion/_m3-expansion.scss +3 -2
  68. package/fesm2022/autocomplete.mjs +1 -1
  69. package/fesm2022/button/testing.mjs +7 -4
  70. package/fesm2022/button/testing.mjs.map +1 -1
  71. package/fesm2022/chips.mjs +1 -1
  72. package/fesm2022/core.mjs +1 -1
  73. package/fesm2022/core.mjs.map +1 -1
  74. package/fesm2022/datepicker.mjs +1 -1
  75. package/fesm2022/expansion.mjs +2 -2
  76. package/fesm2022/expansion.mjs.map +1 -1
  77. package/fesm2022/{form-field-C9DZXojn.mjs → form-field-CFbrnFED.mjs} +3 -3
  78. package/fesm2022/{form-field-C9DZXojn.mjs.map → form-field-CFbrnFED.mjs.map} +1 -1
  79. package/fesm2022/form-field.mjs +2 -2
  80. package/fesm2022/input.mjs +3 -27
  81. package/fesm2022/input.mjs.map +1 -1
  82. package/fesm2022/menu/testing.mjs +97 -13
  83. package/fesm2022/menu/testing.mjs.map +1 -1
  84. package/fesm2022/menu.mjs +343 -122
  85. package/fesm2022/menu.mjs.map +1 -1
  86. package/fesm2022/{module-BDiw_nWS.mjs → module-B0CLRw5e.mjs} +3 -3
  87. package/fesm2022/{module-BDiw_nWS.mjs.map → module-B0CLRw5e.mjs.map} +1 -1
  88. package/fesm2022/{module-DzZHEh7B.mjs → module-B62K-792.mjs} +2 -2
  89. package/fesm2022/{module-DzZHEh7B.mjs.map → module-B62K-792.mjs.map} +1 -1
  90. package/fesm2022/paginator.mjs +3 -3
  91. package/fesm2022/select.mjs +3 -3
  92. package/fesm2022/sidenav.mjs +2 -4
  93. package/fesm2022/sidenav.mjs.map +1 -1
  94. package/fesm2022/slide-toggle.mjs +2 -2
  95. package/fesm2022/slide-toggle.mjs.map +1 -1
  96. package/fesm2022/snack-bar.mjs +2 -2
  97. package/fesm2022/timepicker.mjs +1 -1
  98. package/form-field/_form-field-theme.scss +35 -51
  99. package/form-field/_m2-form-field.scss +125 -146
  100. package/form-field/_m3-form-field.scss +1 -2
  101. package/grid-list/_grid-list-theme.scss +28 -28
  102. package/grid-list/_m2-grid-list.scss +16 -29
  103. package/icon/_icon-theme.scss +40 -41
  104. package/icon/_m2-icon.scss +7 -21
  105. package/input/_input-theme.scss +1 -4
  106. package/input/index.d.ts +0 -11
  107. package/list/_list-theme.scss +57 -53
  108. package/list/_m2-list.scss +84 -108
  109. package/list/_m3-list.scss +1 -2
  110. package/menu/_m2-menu.scss +33 -46
  111. package/menu/_menu-theme.scss +28 -33
  112. package/menu/index.d.ts +145 -61
  113. package/menu/testing/index.d.ts +50 -2
  114. package/package.json +2 -2
  115. package/paginator/_m2-paginator.scss +38 -58
  116. package/paginator/_m3-paginator.scss +1 -2
  117. package/paginator/_paginator-theme.scss +28 -33
  118. package/prebuilt-themes/deeppurple-amber.css +1 -1
  119. package/prebuilt-themes/indigo-pink.css +1 -1
  120. package/prebuilt-themes/pink-bluegrey.css +1 -1
  121. package/prebuilt-themes/purple-green.css +1 -1
  122. package/progress-bar/_m2-progress-bar.scss +11 -24
  123. package/progress-bar/_progress-bar-theme.scss +35 -43
  124. package/progress-spinner/_m2-progress-spinner.scss +9 -20
  125. package/progress-spinner/_progress-spinner-theme.scss +42 -43
  126. package/radio/_m2-radio.scss +30 -40
  127. package/radio/_m3-radio.scss +1 -2
  128. package/radio/_radio-theme.scss +33 -46
  129. package/schematics/ng-add/index.js +1 -1
  130. package/schematics/ng-generate/theme-color/schema.json +1 -1
  131. package/select/_m2-select.scss +23 -30
  132. package/select/_m3-select.scss +1 -2
  133. package/select/_select-theme.scss +38 -51
  134. package/sidenav/_m2-sidenav.scss +26 -36
  135. package/sidenav/_sidenav-theme.scss +28 -30
  136. package/slide-toggle/_m2-slide-toggle.scss +111 -143
  137. package/slide-toggle/_m3-slide-toggle.scss +1 -0
  138. package/slide-toggle/_slide-toggle-theme.scss +42 -80
  139. package/slider/_m2-slider.scss +34 -55
  140. package/slider/_slider-theme.scss +38 -45
  141. package/snack-bar/_m2-snack-bar.scss +16 -36
  142. package/snack-bar/_snack-bar-theme.scss +28 -31
  143. package/sort/_m2-sort.scss +7 -18
  144. package/sort/_sort-theme.scss +28 -33
  145. package/stepper/_m2-stepper.scss +39 -57
  146. package/stepper/_m3-stepper.scss +1 -2
  147. package/stepper/_stepper-theme.scss +41 -49
  148. package/table/_m2-table.scss +54 -72
  149. package/table/_m3-table.scss +1 -2
  150. package/table/_table-theme.scss +28 -36
  151. package/tabs/_m2-tabs.scss +31 -46
  152. package/tabs/_m3-tabs.scss +1 -2
  153. package/tabs/_tabs-theme.scss +41 -49
  154. package/timepicker/_m2-timepicker.scss +10 -22
  155. package/timepicker/_timepicker-theme.scss +28 -46
  156. package/toolbar/_m2-toolbar.scss +26 -46
  157. package/toolbar/_m3-toolbar.scss +1 -2
  158. package/toolbar/_toolbar-theme.scss +55 -46
  159. package/tooltip/_m2-tooltip.scss +16 -34
  160. package/tooltip/_tooltip-theme.scss +28 -37
  161. package/tree/_m2-tree.scss +21 -38
  162. package/tree/_m3-tree.scss +1 -2
  163. package/tree/_tree-theme.scss +28 -38
  164. package/core/tokens/_format-tokens.scss +0 -5
@@ -1,32 +1,21 @@
1
- @use '../../theming/theming';
2
1
  @use '../../theming/inspection';
3
- @use '../../style/sass-utils';
4
2
  @use '../../tokens/token-utils';
5
3
  @use './m2-pseudo-checkbox';
6
4
  @use './m3-pseudo-checkbox';
7
5
  @use 'sass:map';
8
6
 
9
7
  @mixin _palette-styles($theme, $palette-name) {
10
- @include sass-utils.current-selector-or-root() {
11
- @include token-utils.create-token-values-mixed(
12
- m2-pseudo-checkbox.get-color-tokens($theme, $palette-name));
13
- }
8
+ $tokens: map.get(m2-pseudo-checkbox.get-tokens($theme), color);
9
+ @include token-utils.values($tokens);
14
10
  }
15
11
 
16
- /// Outputs base theme styles (styles not dependent on the color, typography, or density settings)
17
- /// for the mat-pseudo-checkbox.
18
- /// @param {Map} $theme The theme to generate base styles for.
19
12
  @mixin base($theme) {
20
- }
13
+ $tokens: map.get(m2-pseudo-checkbox.get-tokens($theme), base);
14
+ @if inspection.get-theme-version($theme) == 1 {
15
+ $tokens: map.get(m3-pseudo-checkbox.get-tokens($theme), base);
16
+ }
21
17
 
22
- /// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
23
- @function _define-overrides() {
24
- @return (
25
- (
26
- namespace: pseudo-checkbox,
27
- tokens: token-utils.get-overrides(m3-pseudo-checkbox.get-tokens(), pseudo-checkbox)
28
- ),
29
- );
18
+ @include token-utils.values($tokens);
30
19
  }
31
20
 
32
21
  /// Outputs the CSS variable values for the given tokens.
@@ -39,62 +28,83 @@
39
28
  /// @param {Map} $theme The theme to generate color styles for.
40
29
  /// @param {String} $color-variant The color variant to use for the component (M3 only)
41
30
  @mixin color($theme, $color-variant: null) {
31
+ $tokens: map.get(m2-pseudo-checkbox.get-tokens($theme), color);
42
32
  @if inspection.get-theme-version($theme) == 1 {
43
- @include token-utils.create-token-values(
44
- map.get(m3-pseudo-checkbox.get-tokens($theme, $color-variant), color));
45
- } @else {
33
+ $tokens: map.get(m3-pseudo-checkbox.get-tokens($theme, $color-variant), color);
34
+ }
35
+
36
+ @include token-utils.values($tokens);
37
+
38
+ @if inspection.get-theme-version($theme) != 1 {
46
39
  // Default to the accent color. Note that the pseudo checkboxes are meant to inherit the
47
40
  // theme from their parent, rather than implementing their own theming, which is why we
48
41
  // don't attach to the `mat-*` classes. Also note that this needs to be below `.mat-primary`
49
42
  // in order to allow for the color to be overwritten if the checkbox is inside a parent that
50
43
  // has `mat-accent` and is placed inside another parent that has `mat-primary`.
51
- @include _palette-styles($theme, secondary);
52
-
53
44
  .mat-primary {
54
- @include _palette-styles($theme, primary);
45
+ $tokens: m2-pseudo-checkbox.private-get-color-palette-color-tokens($theme, primary);
46
+ @include token-utils.values($tokens);
55
47
  }
56
48
 
57
49
  .mat-accent {
58
- @include _palette-styles($theme, secondary);
50
+ $tokens: m2-pseudo-checkbox.private-get-color-palette-color-tokens($theme, secondary);
51
+ @include token-utils.values($tokens);
59
52
  }
60
53
 
61
54
  .mat-warn {
62
- @include _palette-styles($theme, error);
55
+ $tokens: m2-pseudo-checkbox.private-get-color-palette-color-tokens($theme, error);
56
+ @include token-utils.values($tokens);
63
57
  }
64
58
  }
65
59
  }
66
60
 
67
- /// Outputs typography theme styles for the mat-pseudo-checkbox.
68
- /// @param {Map} $theme The theme to generate typography styles for.
69
61
  @mixin typography($theme) {
62
+ $tokens: map.get(m2-pseudo-checkbox.get-tokens($theme), typography);
63
+ @if inspection.get-theme-version($theme) == 1 {
64
+ $tokens: map.get(m3-pseudo-checkbox.get-tokens($theme), typography);
65
+ }
66
+
67
+ @include token-utils.values($tokens);
70
68
  }
71
69
 
72
- /// Outputs density theme styles for the mat-pseudo-checkbox.
73
- /// @param {Map} $theme The theme to generate density styles for.
74
70
  @mixin density($theme) {
71
+ $tokens: map.get(m2-pseudo-checkbox.get-tokens($theme), density);
72
+ @if inspection.get-theme-version($theme) == 1 {
73
+ $tokens: map.get(m3-pseudo-checkbox.get-tokens($theme), density);
74
+ }
75
+
76
+ @include token-utils.values($tokens);
77
+ }
78
+
79
+ /// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
80
+ @function _define-overrides() {
81
+ @return (
82
+ (
83
+ namespace: pseudo-checkbox,
84
+ tokens: token-utils.get-overrides(m3-pseudo-checkbox.get-tokens(), pseudo-checkbox)
85
+ ),
86
+ );
75
87
  }
76
88
 
77
89
  /// Outputs all (base, color, typography, and density) theme styles for the mat-pseudo-checkbox.
78
90
  /// @param {Map} $theme The theme to generate styles for.
79
91
  /// @param {String} $color-variant The color variant to use for the component (M3 only)
80
92
  @mixin theme($theme, $color-variant: null) {
81
- @include theming.private-check-duplicate-theme-styles($theme, 'mat-pseudo-checkbox') {
82
- @if inspection.get-theme-version($theme) == 1 {
83
- @include base($theme);
84
- @include color($theme, $color-variant);
93
+ @if inspection.get-theme-version($theme) == 1 {
94
+ @include base($theme);
95
+ @include color($theme, $color-variant);
96
+ @include density($theme);
97
+ @include typography($theme);
98
+ } @else {
99
+ @include base($theme);
100
+ @if inspection.theme-has($theme, color) {
101
+ @include color($theme);
102
+ }
103
+ @if inspection.theme-has($theme, density) {
85
104
  @include density($theme);
105
+ }
106
+ @if inspection.theme-has($theme, typography) {
86
107
  @include typography($theme);
87
- } @else {
88
- @include base($theme);
89
- @if inspection.theme-has($theme, color) {
90
- @include color($theme);
91
- }
92
- @if inspection.theme-has($theme, density) {
93
- @include density($theme);
94
- }
95
- @if inspection.theme-has($theme, typography) {
96
- @include typography($theme);
97
- }
98
108
  }
99
109
  }
100
110
  }
@@ -37,51 +37,47 @@
37
37
  @use '../../snack-bar/snack-bar-theme';
38
38
  @use '../../form-field/form-field-theme';
39
39
  @use '../../timepicker/timepicker-theme';
40
- @use './theming';
41
40
 
42
41
  // Create a theme.
43
42
  @mixin all-component-themes($theme) {
44
- $dedupe-key: 'angular-material-theme';
45
- @include theming.private-check-duplicate-theme-styles($theme, $dedupe-key) {
46
- @include core-theme.theme($theme);
47
- @include card-theme.theme($theme);
48
- @include progress-bar-theme.theme($theme);
49
- @include tooltip-theme.theme($theme);
50
- @include form-field-theme.theme($theme);
51
- @include input-theme.theme($theme);
52
- @include select-theme.theme($theme);
53
- @include autocomplete-theme.theme($theme);
54
- @include dialog-theme.theme($theme);
55
- @include chips-theme.theme($theme);
56
- @include slide-toggle-theme.theme($theme);
57
- @include radio-theme.theme($theme);
58
- @include slider-theme.theme($theme);
59
- @include menu-theme.theme($theme);
60
- @include list-theme.theme($theme);
61
- @include paginator-theme.theme($theme);
62
- @include tabs-theme.theme($theme);
63
- @include checkbox-theme.theme($theme);
64
- @include button-theme.theme($theme);
65
- @include icon-button-theme.theme($theme);
66
- @include fab-theme.theme($theme);
67
- @include snack-bar-theme.theme($theme);
68
- @include table-theme.theme($theme);
69
- @include progress-spinner-theme.theme($theme);
70
- @include badge-theme.theme($theme);
71
- @include bottom-sheet-theme.theme($theme);
72
- @include button-toggle-theme.theme($theme);
73
- @include datepicker-theme.theme($theme);
74
- @include divider-theme.theme($theme);
75
- @include expansion-theme.theme($theme);
76
- @include grid-list-theme.theme($theme);
77
- @include icon-theme.theme($theme);
78
- @include sidenav-theme.theme($theme);
79
- @include stepper-theme.theme($theme);
80
- @include sort-theme.theme($theme);
81
- @include toolbar-theme.theme($theme);
82
- @include tree-theme.theme($theme);
83
- @include timepicker-theme.theme($theme);
84
- }
43
+ @include core-theme.theme($theme);
44
+ @include card-theme.theme($theme);
45
+ @include progress-bar-theme.theme($theme);
46
+ @include tooltip-theme.theme($theme);
47
+ @include form-field-theme.theme($theme);
48
+ @include input-theme.theme($theme);
49
+ @include select-theme.theme($theme);
50
+ @include autocomplete-theme.theme($theme);
51
+ @include dialog-theme.theme($theme);
52
+ @include chips-theme.theme($theme);
53
+ @include slide-toggle-theme.theme($theme);
54
+ @include radio-theme.theme($theme);
55
+ @include slider-theme.theme($theme);
56
+ @include menu-theme.theme($theme);
57
+ @include list-theme.theme($theme);
58
+ @include paginator-theme.theme($theme);
59
+ @include tabs-theme.theme($theme);
60
+ @include checkbox-theme.theme($theme);
61
+ @include button-theme.theme($theme);
62
+ @include icon-button-theme.theme($theme);
63
+ @include fab-theme.theme($theme);
64
+ @include snack-bar-theme.theme($theme);
65
+ @include table-theme.theme($theme);
66
+ @include progress-spinner-theme.theme($theme);
67
+ @include badge-theme.theme($theme);
68
+ @include bottom-sheet-theme.theme($theme);
69
+ @include button-toggle-theme.theme($theme);
70
+ @include datepicker-theme.theme($theme);
71
+ @include divider-theme.theme($theme);
72
+ @include expansion-theme.theme($theme);
73
+ @include grid-list-theme.theme($theme);
74
+ @include icon-theme.theme($theme);
75
+ @include sidenav-theme.theme($theme);
76
+ @include stepper-theme.theme($theme);
77
+ @include sort-theme.theme($theme);
78
+ @include toolbar-theme.theme($theme);
79
+ @include tree-theme.theme($theme);
80
+ @include timepicker-theme.theme($theme);
85
81
  }
86
82
 
87
83
  @mixin all-component-bases($theme) {
@@ -76,7 +76,29 @@ $theme-version: 1;
76
76
  // density
77
77
  $density-scale: map.get($density-config, scale) or 0;
78
78
 
79
+ $system-maps: (
80
+ m3-tokens.get-sys-color($type, $palettes, $color-system-variables-prefix),
81
+ m3.md-sys-elevation-values(),
82
+ m3.md-sys-motion-values(),
83
+ m3.md-sys-shape-values(),
84
+ m3.md-sys-state-values(),
85
+ (
86
+ // Form field native select option text color
87
+ neutral10: map.get($palettes, neutral, 10),
88
+ // Sidenav scrim (container background shadow when opened),
89
+ neutral-variant20: map.get($palettes, neutral-variant, 20),
90
+ ),
91
+ m3-tokens.get-sys-typeface($typography, $typography-system-variables-prefix),
92
+ );
93
+ $system: (
94
+ density-scale: $density-scale,
95
+ );
96
+ @each $sys-map in $system-maps {
97
+ $system: map.merge($system, $sys-map);
98
+ }
99
+
79
100
  @return (
101
+ _mat-system: $system,
80
102
  $internals: (
81
103
  base-tokens: m3-tokens.generate-base-tokens(),
82
104
  color-system-variables-prefix: $color-system-variables-prefix,
@@ -84,19 +106,6 @@ $theme-version: 1;
84
106
  m3-tokens.generate-color-tokens($type, $palettes, $color-system-variables-prefix),
85
107
  density-scale: $density-scale,
86
108
  font-definition: $typography,
87
- md-sys-color: m3-tokens.get-sys-color($type, $palettes, $color-system-variables-prefix),
88
- md-sys-elevation: m3.md-sys-elevation-values(),
89
- md-sys-motion: m3.md-sys-motion-values(),
90
- md-sys-shape: m3.md-sys-shape-values(),
91
- md-sys-state: m3.md-sys-state-values(),
92
- md-ref-palette: (
93
- // Form field native select option text color
94
- neutral10: map.get($palettes, neutral, 10),
95
- // Sidenav scrim (container background shadow when opened),
96
- neutral-variant20: map.get($palettes, neutral-variant, 20),
97
- ),
98
- md-sys-typescale:
99
- m3-tokens.get-sys-typeface($typography, $typography-system-variables-prefix),
100
109
  palettes: $palettes,
101
110
  theme-type: $type,
102
111
  theme-version: $theme-version,
@@ -279,15 +279,3 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
279
279
  @return $theme;
280
280
  }
281
281
  }
282
-
283
- /// Gets a version of the theme with a modified typography config that preserves old behavior in
284
- /// some components that previously used `private-typography-to-2014-config`.
285
- /// Do not introduce new usages of this, it should be cleaned up and removed.
286
- /// @deprecated
287
- @function private-get-typography-back-compat-theme($theme) {
288
- @return if(
289
- get-theme-version($theme) == 0,
290
- m2-inspection.private-get-typography-back-compat-theme($theme),
291
- $theme
292
- );
293
- }
@@ -235,36 +235,3 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
235
235
  }
236
236
  @return $theme;
237
237
  }
238
-
239
- /// Gets a version of the theme with a modified typography config that preserves old behavior in
240
- /// some components that previously used `private-typography-to-2014-config`.
241
- /// Do not introduce new usages of this, it should be cleaned up and removed.
242
- /// @deprecated
243
- @function private-get-typography-back-compat-theme($theme) {
244
- // It is possible for a user to pass a "density theme" that is just a number.
245
- @if meta.type-of($theme) != 'map' {
246
- @return $theme;
247
- }
248
- $internal: map.get($theme, $_internals, m2-config);
249
- $theme: map.remove($theme, $_internals);
250
- @if theme-has($theme, typography) {
251
- $typography-config: m2-theming.get-typography-config($theme);
252
- // gmat configs have both 2018 and 2014 keys.
253
- @if (not typography-versioning.private-typography-is-2014-config($typography-config)) or
254
- (not typography-versioning.private-typography-is-2018-config($typography-config)) {
255
- @return $theme;
256
- }
257
- $new-typography-config: typography-versioning.private-typography-to-2018-config(
258
- $typography-config, true);
259
- // subtitle-2 is mapped differently by `private-typography-to-2014-config`.
260
- $new-typography-config: map.set(
261
- $new-typography-config, subtitle-2, map.get($new-typography-config, body-1));
262
- $theme: if($theme == $typography-config, $new-typography-config,
263
- map.set($theme, typography, $new-typography-config));
264
- }
265
- @if $internal {
266
- $internal: private-get-typography-back-compat-theme($internal);
267
- $theme: map.set($theme, $_internals, m2-config, $internal);
268
- }
269
- @return $theme;
270
- }
@@ -4,19 +4,16 @@
4
4
  @use 'sass:meta';
5
5
  @use 'sass:color';
6
6
 
7
+ // Deprecated flag that is no longer used to control duplication warnings.
8
+ // Remove in v22
9
+ $theme-ignore-duplication-warnings: false;
10
+
7
11
  // Whether to enable compatibility with legacy methods for accessing theme information.
8
12
  $theme-legacy-inspection-api-compatibility: true !default;
9
13
 
10
- // Whether duplication warnings should be disabled. Warnings enabled by default.
11
- $theme-ignore-duplication-warnings: false !default;
12
-
13
14
  // Whether density should be generated by default.
14
15
  $_generate-default-density: true !default;
15
16
 
16
- // Warning that will be printed if duplicated styles are generated by a theme.
17
- $_duplicate-warning: 'Read more about how style duplication can be avoided in a dedicated ' +
18
- 'guide. https://v18.material.angular.dev/guide/duplicate-theming-styles';
19
-
20
17
  // Warning that will be printed if the legacy theming API is used.
21
18
  $private-legacy-theme-warning: 'Angular Material themes should be created from a map containing ' +
22
19
  'the keys "color", "typography", and "density". The color value should be a map containing the ' +
@@ -40,46 +37,6 @@ $_emitted-base: () !default;
40
37
 
41
38
  $private-internal-name: _mat-theming-internals-do-not-access;
42
39
 
43
- // Checks if configurations that have been declared in the given theme have been generated
44
- // before. If so, warnings will be reported. This should notify developers in case duplicate
45
- // styles are accidentally generated due to wrong usage of the all-theme mixins.
46
- //
47
- // Additionally, this mixin controls the default value for the density configuration. By
48
- // default, density styles are generated at scale zero. If the same density styles would be
49
- // generated a second time though, the default value will change to avoid duplicate styles.
50
- //
51
- // The mixin keeps track of all configurations in a list that is scoped to the specified
52
- // id. This is necessary because a given theme can be passed to multiple disjoint theme mixins
53
- // (e.g. `all-component-themes` and `all-legacy-component-themes`) without causing any
54
- // style duplication.
55
- @mixin private-check-duplicate-theme-styles($theme-or-color-config, $id) {
56
- // TODO(mmalerba): use get-theme-version for this check when its moved out of experimental.
57
- @if map.get($theme-or-color-config, $private-internal-name, theme-version) == 1 {
58
- @include _check-duplicate-theme-styles-v1($theme-or-color-config, $id) {
59
- // Optionally, consumers of this mixin can wrap contents inside so that nested
60
- // duplicate style checks do not report another warning. e.g. if developers include
61
- // the `all-component-themes` mixin twice, only the top-level duplicate styles check
62
- // should report a warning. Not all individual components should report a warning too.
63
- $orig-mat-theme-ignore-duplication-warnings: $theme-ignore-duplication-warnings;
64
- $theme-ignore-duplication-warnings: true !global;
65
- @content;
66
- $theme-ignore-duplication-warnings: $orig-mat-theme-ignore-duplication-warnings !global;
67
- }
68
- }
69
- @else {
70
- @include _check-duplicate-theme-styles-v0($theme-or-color-config, $id) {
71
- // Optionally, consumers of this mixin can wrap contents inside so that nested
72
- // duplicate style checks do not report another warning. e.g. if developers include
73
- // the `all-component-themes` mixin twice, only the top-level duplicate styles check
74
- // should report a warning. Not all individual components should report a warning too.
75
- $orig-mat-theme-ignore-duplication-warnings: $theme-ignore-duplication-warnings;
76
- $theme-ignore-duplication-warnings: true !global;
77
- @content;
78
- $theme-ignore-duplication-warnings: $orig-mat-theme-ignore-duplication-warnings !global;
79
- }
80
- }
81
- }
82
-
83
40
  /// Strip out any settings map entries that have empty values (null or ()).
84
41
  @function _strip-empty-settings($settings) {
85
42
  $result: ();
@@ -91,131 +48,6 @@ $private-internal-name: _mat-theming-internals-do-not-access;
91
48
  @return if($result == (), null, $result);
92
49
  }
93
50
 
94
- // Checks for duplicate styles in a `theme-version: 1` style theme.
95
- @mixin _check-duplicate-theme-styles-v1($theme-or-color-config, $id) {
96
- $color-settings: _strip-empty-settings((
97
- theme-type: map.get($theme-or-color-config, $private-internal-name, theme-type),
98
- color-tokens: map.get($theme-or-color-config, $private-internal-name, color-tokens),
99
- ));
100
- $typography-settings: _strip-empty-settings((
101
- typography-tokens:
102
- map.get($theme-or-color-config, $private-internal-name, typography-tokens),
103
- ));
104
- $density-settings: _strip-empty-settings((
105
- density-scale:
106
- map.get($theme-or-color-config, $private-internal-name, density-scale),
107
- density-tokens:
108
- map.get($theme-or-color-config, $private-internal-name, density-tokens),
109
- ));
110
- $base-settings: _strip-empty-settings((
111
- base-tokens: map.get($theme-or-color-config, $private-internal-name, base-tokens),
112
- ));
113
- $previous-color-settings: map.get($_emitted-color, $id) or ();
114
- $previous-typography-settings: map.get($_emitted-typography, $id) or ();
115
- $previous-density-settings: map.get($_emitted-density, $id) or ();
116
- $previous-base-settings: map.get($_emitted-base, $id) or ();
117
-
118
- // Check if the color configuration has been generated before.
119
- @if $color-settings != null {
120
- @if list.index($previous-color-settings, $color-settings) != null and
121
- not $theme-ignore-duplication-warnings {
122
- @warn 'The same color styles are generated multiple times. ' + $_duplicate-warning;
123
- }
124
- $previous-color-settings: list.append($previous-color-settings, $color-settings);
125
- }
126
-
127
- // Check if the typography configuration has been generated before.
128
- @if $typography-settings != null {
129
- @if list.index($previous-typography-settings, $typography-settings) != null and
130
- not $theme-ignore-duplication-warnings {
131
- @warn 'The same typography styles are generated multiple times. ' + $_duplicate-warning;
132
- }
133
- $previous-typography-settings: list.append($previous-typography-settings, $typography-settings);
134
- }
135
-
136
- // Check if the density configuration has been generated before.
137
- @if $density-settings != null {
138
- @if list.index($previous-density-settings, $density-settings) != null and
139
- not $theme-ignore-duplication-warnings {
140
- @warn 'The same density styles are generated multiple times. ' + $_duplicate-warning;
141
- }
142
- $previous-density-settings: list.append($previous-density-settings, $density-settings);
143
- }
144
-
145
- // Check if the base configuration has been generated before.
146
- @if $base-settings != null {
147
- @if list.index($previous-base-settings, $base-settings) != null and
148
- not $theme-ignore-duplication-warnings {
149
- @warn 'The same base theme styles are generated multiple times. ' + $_duplicate-warning;
150
- }
151
- $previous-base-settings: list.append($previous-base-settings, $base-settings);
152
- }
153
-
154
- $_emitted-color: map.set($_emitted-color, $id, $previous-color-settings) !global;
155
- $_emitted-density: map.set($_emitted-density, $id, $previous-density-settings) !global;
156
- $_emitted-typography: map.set($_emitted-typography, $id, $previous-typography-settings) !global;
157
- $_emitted-base: map.set($_emitted-base, $id, $previous-base-settings) !global;
158
-
159
- @content;
160
- }
161
-
162
- // Checks for duplicate styles in a `theme-version: 0` style theme.
163
- @mixin _check-duplicate-theme-styles-v0($theme-or-color-config, $id) {
164
- $theme: private-legacy-get-theme($theme-or-color-config);
165
- $color-config: map.get($theme, $private-internal-name, m2-config, color) or
166
- private-get-color-config($theme);
167
- $density-config: map.get($theme, $private-internal-name, m2-config, density) or
168
- private-get-density-config($theme);
169
- $typography-config: map.get($theme, $private-internal-name, m2-config, typography) or
170
- private-get-typography-config($theme);
171
- // Lists of previous `color`, `density` and `typography` configurations.
172
- $previous-color: map.get($_emitted-color, $id) or ();
173
- $previous-typography: map.get($_emitted-typography, $id) or ();
174
- $previous-density: map.get($_emitted-density, $id) or ();
175
- // Whether duplicate legacy density styles would be generated.
176
- $duplicate-legacy-density: false;
177
-
178
- // Check if the color configuration has been generated before.
179
- @if $color-config != null {
180
- @if list.index($previous-color, $color-config) != null and
181
- not $theme-ignore-duplication-warnings {
182
- @warn 'The same color styles are generated multiple times. ' + $_duplicate-warning;
183
- }
184
- $previous-color: list.append($previous-color, $color-config);
185
- }
186
-
187
- // Check if the typography configuration has been generated before.
188
- @if $typography-config != null {
189
- @if list.index($previous-typography, $typography-config) != null and
190
- not $theme-ignore-duplication-warnings {
191
- @warn 'The same typography styles are generated multiple times. ' + $_duplicate-warning;
192
- }
193
- $previous-typography: list.append($previous-typography, $typography-config);
194
- }
195
-
196
- // Check if the density configuration has been generated before.
197
- @if $density-config != null {
198
- @if list.index($previous-density, $density-config) != null {
199
- // Only report a warning if density styles would be duplicated for non-legacy theme
200
- // definitions. For legacy themes, we have compatibility logic that avoids duplication
201
- // of default density styles. We don't want to report a warning in those cases.
202
- @if private-is-legacy-constructed-theme($theme) {
203
- $duplicate-legacy-density: true;
204
- }
205
- @else if not $theme-ignore-duplication-warnings {
206
- @warn 'The same density styles are generated multiple times. ' + $_duplicate-warning;
207
- }
208
- }
209
- $previous-density: list.append($previous-density, $density-config);
210
- }
211
-
212
- $_emitted-color: map.merge($_emitted-color, ($id: $previous-color)) !global;
213
- $_emitted-density: map.merge($_emitted-density, ($id: $previous-density)) !global;
214
- $_emitted-typography: map.merge($_emitted-typography, ($id: $previous-typography)) !global;
215
-
216
- @content;
217
- }
218
-
219
51
  // Checks whether the given value resolves to a theme object. Theme objects are always
220
52
  // of type `map` and can optionally only specify `color`, `density` or `typography`.
221
53
  @function private-is-theme-object($value) {
@@ -1,77 +1,25 @@
1
- @use 'sass:color';
2
- @use 'sass:math';
3
- @use 'sass:meta';
4
1
  @use 'sass:map';
5
-
6
- // Indicates whether we're building internally. Used for backwards compatibility.
7
- $private-is-internal-build: false;
2
+ @use 'sass:meta';
3
+ @use './m2';
8
4
 
9
5
  // Gets the theme's system values as a flat map.
10
6
  @function get-system($theme) {
11
- $system: map.get($theme, _mat-system);
12
- @if $system {
13
- @return $system;
7
+ @if meta.type-of($theme) == map {
8
+ $system: map.get($theme, _mat-system);
9
+ @if $system {
10
+ @return $system;
11
+ }
12
+
13
+ // If the $theme is a typography-config, convert it to a system map.
14
+ @if map.has-key($theme, body-1) {
15
+ @return m2.md-sys-typescale-values($theme);
16
+ }
14
17
  }
15
18
 
16
- @return ();
17
- }
18
-
19
- /// Inherited function from MDC that computes which contrast tone to use on top of a color.
20
- /// This is used only in a narrow set of use cases when generating M2 button tokens to maintain
21
- /// backwards compatibility.
22
- /// @param {Color} $value Color for which we're calculating the contrast tone.
23
- /// @param {Boolean} $is-dark Whether the current theme is dark.
24
- /// @return {Map} Either `dark` or `light`.
25
- @function contrast-tone($value, $is-dark) {
26
- @if ($value == 'dark') {
27
- @return 'light';
28
- }
29
-
30
- @if ($value == 'light') {
31
- @return 'dark';
32
- }
33
-
34
- // Fallback if the app is using a non-color palette (e.g. CSS variable based).
35
- @if (meta.type-of($value) != 'color') {
36
- @return if($is-dark, 'light', 'dark');
37
- }
38
-
39
- $minimum-contrast: 3.1;
40
- $light-contrast: _contrast($value, #fff);
41
- $dark-contrast: _contrast($value, rgba(0, 0, 0, 0.87));
42
-
43
- @if ($light-contrast < $minimum-contrast) and ($dark-contrast > $light-contrast) {
44
- @return 'dark';
19
+ // If the $theme is a density scale, convert it to a system map.
20
+ @if meta.type-of($theme) == 'number' or $theme == minimum or $theme == maximum {
21
+ @return (density-scale: $theme);
45
22
  }
46
23
 
47
- @return 'light';
48
- }
49
-
50
- @function _linear-channel-value($channel-value) {
51
- $normalized-channel-value: math.div($channel-value, 255);
52
-
53
- @if ($normalized-channel-value < 0.03928) {
54
- @return math.div($normalized-channel-value, 12.92);
55
- }
56
-
57
- @return math.pow(math.div($normalized-channel-value + 0.055, 1.055), 2.4);
58
- }
59
-
60
- // Calculate the luminance for a color.
61
- // See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
62
- @function _luminance($color) {
63
- $red: _linear-channel-value(color.red($color));
64
- $green: _linear-channel-value(color.green($color));
65
- $blue: _linear-channel-value(color.blue($color));
66
-
67
- @return 0.2126 * $red + 0.7152 * $green + 0.0722 * $blue;
68
- }
69
-
70
- // Calculate the contrast ratio between two colors.
71
- // See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
72
- @function _contrast($back, $front) {
73
- $back-lum: _luminance($back) + 0.05;
74
- $fore-lum: _luminance($front) + 0.05;
75
-
76
- @return math.div(math.max($back-lum, $fore-lum), math.min($back-lum, $fore-lum));
24
+ @return ();
77
25
  }
@@ -8,25 +8,13 @@
8
8
  $system: map.set($system, on-#{$color}-container, map.get($system, on-#{$variant}-container));
9
9
  $system: map.set($system, #{$color}, map.get($system, #{$variant}));
10
10
  $system: map.set($system, #{$color}-container, map.get($system, #{$variant}-container));
11
+ $system: map.set($system, inverse-#{$color}, map.get($system, inverse-#{$variant}));
11
12
  @return $system;
12
13
  }
13
14
 
14
15
  // Gets the theme's system values as a flat map.
15
16
  @function get-system($theme) {
16
- $system: ();
17
- $system: map.merge($system,
18
- map.get($theme, _mat-theming-internals-do-not-access, md-sys-color));
19
- $system: map.merge($system,
20
- map.get($theme, _mat-theming-internals-do-not-access, md-sys-elevation));
21
- $system: map.merge($system,
22
- map.get($theme, _mat-theming-internals-do-not-access, md-sys-shape));
23
- $system: map.merge($system,
24
- map.get($theme, _mat-theming-internals-do-not-access, md-sys-state));
25
- $system: map.merge($system,
26
- map.get($theme, _mat-theming-internals-do-not-access, md-sys-typescale));
27
- $system: map.merge($system,
28
- map.get($theme, _mat-theming-internals-do-not-access, md-ref-palette));
29
- @return $system;
17
+ @return map.get($theme, _mat-system);
30
18
  }
31
19
 
32
20
  // Returns the color with an opacity value using color-mix. If the color is a variable name, it