@angular/material 16.1.0-next.0 → 16.1.0-next.2

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 (152) hide show
  1. package/_index.scss +7 -4
  2. package/_token-theming.scss +2 -0
  3. package/button/_icon-button-theme.scss +0 -1
  4. package/button/index.d.ts +3 -2
  5. package/card/_card-theme.import.scss +1 -1
  6. package/card/_card-theme.scss +11 -0
  7. package/checkbox/_checkbox-theme.import.scss +1 -1
  8. package/checkbox/_checkbox-theme.scss +18 -3
  9. package/chips/_chips-theme.scss +44 -60
  10. package/core/mdc-helpers/_mdc-helpers.scss +19 -34
  11. package/core/style/_sass-utils.scss +37 -0
  12. package/core/tokens/_token-utils.scss +3 -12
  13. package/core/tokens/m2/_index.scss +84 -0
  14. package/core/tokens/m2/mat/_card.scss +17 -16
  15. package/core/tokens/m2/mat/_radio.scss +6 -5
  16. package/core/tokens/m2/mat/_snack-bar.scss +6 -5
  17. package/core/tokens/m2/mat/_tab-header-with-background.scss +6 -5
  18. package/core/tokens/m2/mat/_tab-header.scss +2 -1
  19. package/core/tokens/m2/mdc/_checkbox.scss +39 -38
  20. package/core/tokens/m2/mdc/_chip.scss +313 -0
  21. package/core/tokens/m2/mdc/_circular-progress.scss +5 -8
  22. package/core/tokens/m2/mdc/_dialog.scss +6 -7
  23. package/core/tokens/m2/mdc/_elevated-card.scss +2 -1
  24. package/core/tokens/m2/mdc/_icon-button.scss +5 -13
  25. package/core/tokens/m2/mdc/_linear-progress.scss +11 -16
  26. package/core/tokens/m2/mdc/_list.scss +102 -101
  27. package/core/tokens/m2/mdc/_outlined-card.scss +2 -1
  28. package/core/tokens/m2/mdc/_plain-tooltip.scss +6 -9
  29. package/core/tokens/m2/mdc/_radio.scss +6 -7
  30. package/core/tokens/m2/mdc/_snack-bar.scss +6 -8
  31. package/core/tokens/m2/mdc/_tab-indicator.scss +6 -6
  32. package/core/tokens/m2/mdc/_tab.scss +6 -6
  33. package/core/typography/_all-typography.scss +1 -154
  34. package/core/typography/_typography.scss +162 -0
  35. package/esm2022/autocomplete/autocomplete.mjs +3 -3
  36. package/esm2022/button/button-base.mjs +7 -11
  37. package/esm2022/button/button.mjs +3 -3
  38. package/esm2022/button/fab.mjs +5 -5
  39. package/esm2022/button/icon-button.mjs +3 -3
  40. package/esm2022/checkbox/checkbox.mjs +2 -2
  41. package/esm2022/chips/chip-grid.mjs +2 -2
  42. package/esm2022/chips/chip-listbox.mjs +5 -5
  43. package/esm2022/chips/chip-option.mjs +3 -3
  44. package/esm2022/chips/chip-row.mjs +2 -2
  45. package/esm2022/chips/chip-set.mjs +2 -2
  46. package/esm2022/chips/chip.mjs +2 -2
  47. package/esm2022/core/version.mjs +1 -1
  48. package/esm2022/datepicker/calendar-body.mjs +29 -16
  49. package/esm2022/datepicker/datepicker-toggle.mjs +3 -3
  50. package/esm2022/form-field/directives/floating-label.mjs +66 -5
  51. package/esm2022/form-field/directives/notched-outline.mjs +14 -16
  52. package/esm2022/form-field/form-field.mjs +30 -36
  53. package/esm2022/icon/testing/icon-harness.mjs +7 -2
  54. package/esm2022/legacy-autocomplete/autocomplete.mjs +3 -3
  55. package/esm2022/legacy-chips/chip-list.mjs +3 -3
  56. package/esm2022/legacy-core/option/optgroup.mjs +3 -3
  57. package/esm2022/legacy-form-field/form-field.mjs +3 -3
  58. package/esm2022/legacy-menu/menu-item.mjs +3 -3
  59. package/esm2022/legacy-menu/menu.mjs +3 -3
  60. package/esm2022/legacy-paginator/paginator.mjs +3 -3
  61. package/esm2022/legacy-select/public-api.mjs +2 -2
  62. package/esm2022/legacy-select/select.mjs +3 -3
  63. package/esm2022/legacy-table/table.mjs +3 -3
  64. package/esm2022/legacy-tabs/tab-group.mjs +3 -3
  65. package/esm2022/list/list-base.mjs +2 -1
  66. package/esm2022/menu/menu-item.mjs +3 -3
  67. package/esm2022/menu/menu.mjs +3 -3
  68. package/esm2022/paginator/paginator.mjs +3 -3
  69. package/esm2022/progress-bar/progress-bar.mjs +2 -2
  70. package/esm2022/select/select.mjs +28 -17
  71. package/esm2022/sidenav/drawer.mjs +7 -7
  72. package/esm2022/sidenav/sidenav.mjs +7 -7
  73. package/esm2022/slide-toggle/slide-toggle.mjs +3 -3
  74. package/esm2022/slider/slider-input.mjs +21 -9
  75. package/esm2022/stepper/stepper.mjs +3 -3
  76. package/esm2022/table/row.mjs +2 -2
  77. package/esm2022/table/table.mjs +3 -3
  78. package/esm2022/tabs/tab-group.mjs +3 -3
  79. package/esm2022/tooltip/tooltip.mjs +5 -1
  80. package/fesm2022/autocomplete.mjs +2 -2
  81. package/fesm2022/autocomplete.mjs.map +1 -1
  82. package/fesm2022/button.mjs +14 -18
  83. package/fesm2022/button.mjs.map +1 -1
  84. package/fesm2022/checkbox.mjs +2 -2
  85. package/fesm2022/checkbox.mjs.map +1 -1
  86. package/fesm2022/chips.mjs +14 -14
  87. package/fesm2022/chips.mjs.map +1 -1
  88. package/fesm2022/core.mjs +1 -1
  89. package/fesm2022/core.mjs.map +1 -1
  90. package/fesm2022/datepicker.mjs +30 -17
  91. package/fesm2022/datepicker.mjs.map +1 -1
  92. package/fesm2022/form-field.mjs +102 -50
  93. package/fesm2022/form-field.mjs.map +1 -1
  94. package/fesm2022/icon/testing.mjs +6 -1
  95. package/fesm2022/icon/testing.mjs.map +1 -1
  96. package/fesm2022/legacy-autocomplete.mjs +2 -2
  97. package/fesm2022/legacy-autocomplete.mjs.map +1 -1
  98. package/fesm2022/legacy-chips.mjs +2 -2
  99. package/fesm2022/legacy-chips.mjs.map +1 -1
  100. package/fesm2022/legacy-core.mjs +2 -2
  101. package/fesm2022/legacy-core.mjs.map +1 -1
  102. package/fesm2022/legacy-form-field.mjs +2 -2
  103. package/fesm2022/legacy-form-field.mjs.map +1 -1
  104. package/fesm2022/legacy-menu.mjs +4 -4
  105. package/fesm2022/legacy-menu.mjs.map +1 -1
  106. package/fesm2022/legacy-paginator.mjs +2 -2
  107. package/fesm2022/legacy-paginator.mjs.map +1 -1
  108. package/fesm2022/legacy-select.mjs +2 -2
  109. package/fesm2022/legacy-select.mjs.map +1 -1
  110. package/fesm2022/legacy-table.mjs +2 -2
  111. package/fesm2022/legacy-table.mjs.map +1 -1
  112. package/fesm2022/legacy-tabs.mjs +2 -2
  113. package/fesm2022/legacy-tabs.mjs.map +1 -1
  114. package/fesm2022/list.mjs +1 -0
  115. package/fesm2022/list.mjs.map +1 -1
  116. package/fesm2022/menu.mjs +4 -4
  117. package/fesm2022/menu.mjs.map +1 -1
  118. package/fesm2022/paginator.mjs +2 -2
  119. package/fesm2022/paginator.mjs.map +1 -1
  120. package/fesm2022/progress-bar.mjs +2 -2
  121. package/fesm2022/progress-bar.mjs.map +1 -1
  122. package/fesm2022/select.mjs +27 -16
  123. package/fesm2022/select.mjs.map +1 -1
  124. package/fesm2022/sidenav.mjs +12 -12
  125. package/fesm2022/sidenav.mjs.map +1 -1
  126. package/fesm2022/slide-toggle.mjs +2 -2
  127. package/fesm2022/slide-toggle.mjs.map +1 -1
  128. package/fesm2022/slider.mjs +20 -8
  129. package/fesm2022/slider.mjs.map +1 -1
  130. package/fesm2022/stepper.mjs +2 -2
  131. package/fesm2022/stepper.mjs.map +1 -1
  132. package/fesm2022/table.mjs +3 -3
  133. package/fesm2022/table.mjs.map +1 -1
  134. package/fesm2022/tabs.mjs +2 -2
  135. package/fesm2022/tabs.mjs.map +1 -1
  136. package/fesm2022/tooltip.mjs +4 -0
  137. package/fesm2022/tooltip.mjs.map +1 -1
  138. package/form-field/index.d.ts +44 -12
  139. package/legacy-select/index.d.ts +7 -2
  140. package/list/index.d.ts +2 -1
  141. package/package.json +49 -49
  142. package/prebuilt-themes/deeppurple-amber.css +1 -1
  143. package/prebuilt-themes/indigo-pink.css +1 -1
  144. package/prebuilt-themes/pink-bluegrey.css +1 -1
  145. package/prebuilt-themes/purple-green.css +1 -1
  146. package/schematics/ng-add/index.js +1 -1
  147. package/schematics/ng-add/index.mjs +1 -1
  148. package/select/index.d.ts +13 -5
  149. package/slider/index.d.ts +10 -1
  150. package/table/index.d.ts +1 -1
  151. package/tabs/_tabs-theme.scss +0 -1
  152. package/tooltip/index.d.ts +4 -0
package/_index.scss CHANGED
@@ -9,10 +9,12 @@
9
9
  $amber-palette, $orange-palette, $deep-orange-palette, $brown-palette, $grey-palette,
10
10
  $gray-palette, $blue-grey-palette, $blue-gray-palette, $light-theme-background-palette,
11
11
  $dark-theme-background-palette, $light-theme-foreground-palette, $dark-theme-foreground-palette;
12
- @forward './core/typography/typography' show define-typography-level,
13
- define-legacy-typography-config, legacy-typography-hierarchy, typography-hierarchy;
12
+ @forward './core/typography/typography' show define-typography-level, define-rem-typography-config,
13
+ define-typography-config, typography-hierarchy, define-legacy-typography-config,
14
+ legacy-typography-hierarchy;
14
15
  @forward './core/typography/typography-utils' show typography-level,
15
16
  font-size, line-height, font-weight, letter-spacing, font-family, font-shorthand;
17
+ @forward './core/tokens/m2' show m2-tokens-from-theme;
16
18
 
17
19
  // Private/Internal
18
20
  @forward './core/density/private/all-density' show all-component-densities;
@@ -36,6 +38,8 @@
36
38
  @forward './core/style/button-common' as private-button-common-*;
37
39
  // The form field density mixin needs to be exposed, because the paginator depends on it.
38
40
  @forward './form-field/form-field-theme' as private-form-field-* show private-form-field-density;
41
+ @forward './token-theming' as private-apply-*;
42
+ @forward './core/style/sass-utils' as private-*;
39
43
 
40
44
  // Structural
41
45
  @forward './core/core' show core;
@@ -48,8 +52,7 @@
48
52
  // Theme bundles
49
53
  @forward './core/theming/all-theme' show all-component-themes;
50
54
  @forward './core/color/all-color' show all-component-colors;
51
- @forward './core/typography/all-typography' show all-component-typographies,
52
- define-rem-typography-config, define-typography-config;
55
+ @forward './core/typography/all-typography' show all-component-typographies;
53
56
  @forward './legacy-core/theming/all-theme' show all-legacy-component-themes;
54
57
  @forward './legacy-core/color/all-color' show all-legacy-component-colors;
55
58
  @forward './legacy-core/typography/all-typography' show all-legacy-component-typographies;
@@ -0,0 +1,2 @@
1
+ @forward './card/card-theme' as card-* show card-theme-from-tokens;
2
+ @forward './checkbox/checkbox-theme' as checkbox-* show checkbox-theme-from-tokens;
@@ -1,7 +1,6 @@
1
1
  @use 'sass:map';
2
2
  @use 'sass:math';
3
3
  @use '@material/density/functions' as mdc-density-functions;
4
- @use '@material/icon-button/mixins' as mdc-icon-button;
5
4
  @use '@material/icon-button/icon-button-theme' as mdc-icon-button-theme;
6
5
  @use '@material/theme/theme-color' as mdc-theme-color;
7
6
  @use '../core/tokens/m2/mdc/icon-button' as tokens-mdc-icon-button;
package/button/index.d.ts CHANGED
@@ -12,6 +12,7 @@ import * as i4 from '@angular/material/core';
12
12
  import { InjectionToken } from '@angular/core';
13
13
  import { MatRipple } from '@angular/material/core';
14
14
  import { NgZone } from '@angular/core';
15
+ import { OnChanges } from '@angular/core';
15
16
  import { OnDestroy } from '@angular/core';
16
17
  import { OnInit } from '@angular/core';
17
18
  import { Platform } from '@angular/cdk/platform';
@@ -94,7 +95,7 @@ export declare class MatButton extends MatButtonBase {
94
95
  }
95
96
 
96
97
  /** Base class for all buttons. */
97
- declare class MatButtonBase extends _MatButtonMixin implements CanDisable, CanColor, CanDisableRipple, AfterViewInit, OnDestroy {
98
+ declare class MatButtonBase extends _MatButtonMixin implements CanDisable, CanColor, CanDisableRipple, AfterViewInit, OnChanges, OnDestroy {
98
99
  _platform: Platform;
99
100
  _ngZone: NgZone;
100
101
  _animationMode?: string | undefined;
@@ -117,12 +118,12 @@ declare class MatButtonBase extends _MatButtonMixin implements CanDisable, CanCo
117
118
  protected _ripple?: MatRipple;
118
119
  constructor(elementRef: ElementRef, _platform: Platform, _ngZone: NgZone, _animationMode?: string | undefined);
119
120
  ngAfterViewInit(): void;
121
+ ngOnChanges(): void;
120
122
  ngOnDestroy(): void;
121
123
  /** Focuses the button. */
122
124
  focus(_origin?: FocusOrigin, options?: FocusOptions): void;
123
125
  /** Gets whether the button has one of the given attributes. */
124
126
  private _hasHostAttributes;
125
- _isRippleDisabled(): void;
126
127
  static ɵfac: i0.ɵɵFactoryDeclaration<MatButtonBase, never>;
127
128
  static ɵdir: i0.ɵɵDirectiveDeclaration<MatButtonBase, never, never, {}, {}, never, never, false, never>;
128
129
  }
@@ -1,3 +1,3 @@
1
- @forward 'card-theme' hide color, density, theme, typography;
1
+ @forward 'card-theme' hide color, density, theme, typography, theme-from-tokens;
2
2
  @forward 'card-theme' as mat-mdc-card-* hide $mat-mdc-card-mdc-card-action-icon-color,
3
3
  $mat-mdc-card-mdc-card-outline-color;
@@ -1,3 +1,4 @@
1
+ @use 'sass:map';
1
2
  @use '../core/theming/theming';
2
3
  @use '../core/typography/typography';
3
4
  @use '../core/tokens/token-utils';
@@ -76,3 +77,13 @@
76
77
  }
77
78
  }
78
79
  }
80
+
81
+ @mixin theme-from-tokens($tokens) {
82
+ // Add values for card tokens.
83
+ .mat-mdc-card {
84
+ @include mdc-elevated-card-theme.theme(map.get($tokens, tokens-mdc-elevated-card.$prefix));
85
+ @include mdc-outlined-card-theme.theme(map.get($tokens, tokens-mdc-outlined-card.$prefix));
86
+ @include token-utils.create-token-values(
87
+ tokens-mat-card.$prefix, map.get($tokens, tokens-mat-card.$prefix));
88
+ }
89
+ }
@@ -1,5 +1,5 @@
1
1
  @forward 'checkbox-theme' hide color, density, private-checkbox-styles-with-color, theme,
2
- typography;
2
+ typography, theme-from-tokens;
3
3
  @forward 'checkbox-theme' as mat-mdc-* hide $mat-mdc-mdc-checkbox-border-color,
4
4
  $mat-mdc-mdc-checkbox-disabled-color, mat-mdc-background-focus-density,
5
5
  mat-mdc-background-focus-indicator-checked-color, mat-mdc-background-focus-indicator-color,
@@ -1,6 +1,7 @@
1
1
  @use 'sass:map';
2
2
  @use '@material/checkbox/checkbox-theme' as mdc-checkbox-theme;
3
3
  @use '@material/form-field' as mdc-form-field;
4
+ @use '../core/style/sass-utils';
4
5
  @use '../core/theming/theming';
5
6
  @use '../core/typography/typography';
6
7
  @use '../core/mdc-helpers/mdc-helpers';
@@ -12,9 +13,11 @@
12
13
  $warn: map.get($config, warn);
13
14
  $foreground: map.get($config, foreground);
14
15
 
15
- .mat-mdc-checkbox {
16
+ @include sass-utils.current-selector-or-root() {
16
17
  @include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-color-tokens($config));
18
+ }
17
19
 
20
+ .mat-mdc-checkbox {
18
21
  &.mat-primary {
19
22
  $primary-config: map.merge($config, (accent: $primary));
20
23
  @include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-color-tokens($primary-config));
@@ -40,9 +43,12 @@
40
43
  @mixin typography($config-or-theme) {
41
44
  $config: typography.private-typography-to-2018-config(
42
45
  theming.get-typography-config($config-or-theme));
43
- .mat-mdc-checkbox {
46
+
47
+ @include sass-utils.current-selector-or-root() {
44
48
  @include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-typography-tokens($config));
49
+ }
45
50
 
51
+ .mat-mdc-checkbox {
46
52
  @include mdc-helpers.using-mdc-typography($config) {
47
53
  // TODO(mmalerba): Switch to static-styles, theme-styles, and theme once they're available.
48
54
  @include mdc-form-field.core-styles($query: mdc-helpers.$mdc-typography-styles-query);
@@ -53,7 +59,7 @@
53
59
  @mixin density($config-or-theme) {
54
60
  $density-scale: theming.get-density-config($config-or-theme);
55
61
 
56
- .mat-mdc-checkbox {
62
+ @include sass-utils.current-selector-or-root() {
57
63
  @include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-density-tokens($density-scale));
58
64
  }
59
65
 
@@ -82,3 +88,12 @@
82
88
  }
83
89
  }
84
90
  }
91
+
92
+ @mixin theme-from-tokens($tokens) {
93
+ // TODO(mmalerba): Some of the theme styles above are not represented in terms of tokens,
94
+ // so this mixin is currently incomplete.
95
+
96
+ .mat-mdc-checkbox {
97
+ @include mdc-checkbox-theme.theme(map.get($tokens, tokens-mdc-checkbox.$prefix));
98
+ }
99
+ }
@@ -2,100 +2,84 @@
2
2
  @use 'sass:map';
3
3
  @use 'sass:meta';
4
4
  @use '@material/chips/chip-theme' as mdc-chip-theme;
5
- @use '@material/chips/chip-set' as mdc-chip-set;
6
- @use '@material/theme/theme-color' as mdc-theme-color;
7
- @use '@material/theme/color-palette' as mdc-color-palette;
8
- @use '@material/typography' as mdc-typography;
9
- @use '../core/mdc-helpers/mdc-helpers';
5
+ @use '../core/tokens/m2/mdc/chip' as tokens-mdc-chip;
6
+ @use '../core/theming/palette';
10
7
  @use '../core/theming/theming';
11
8
  @use '../core/typography/typography';
9
+ @use '../core/mdc-helpers/mdc-helpers';
12
10
 
13
- @mixin _chip-variant($background, $foreground) {
14
- @include mdc-chip-theme.theme((
15
- elevated-container-color: $background,
16
- elevated-disabled-container-color: $background,
17
- label-text-color: $foreground,
18
- disabled-label-text-color: $foreground,
19
- with-icon-icon-color: $foreground,
20
- with-icon-disabled-icon-color: $foreground,
21
- with-trailing-icon-disabled-trailing-icon-color: $foreground,
22
- with-trailing-icon-trailing-icon-color: $foreground,
23
- with-icon-selected-icon-color: $foreground,
24
- ));
25
- }
11
+ @function _get-default-palette($config) {
12
+ $is-dark: map.get($config, is-dark);
13
+ $grey-50: map.get(palette.$grey-palette, 50);
14
+ $grey-900: map.get(palette.$grey-palette, 900);
15
+ $default-foreground: if($is-dark, $grey-50, $grey-900);
26
16
 
27
- @mixin _colored-chip($palette) {
28
- $background: theming.get-color-from-palette($palette);
29
- $foreground: theming.get-color-from-palette($palette, default-contrast);
17
+ $surface: map.get(map.get($config, background), card);
18
+ $on-surface: if(
19
+ mdc-helpers.variable-safe-contrast-tone($surface, $is-dark) == 'dark',
20
+ #000,
21
+ #fff
22
+ );
23
+ $default-background: if(
24
+ meta.type-of($on-surface) == color and meta.type-of($surface) == color,
25
+ color.mix($on-surface, $surface, 12%),
26
+ $on-surface
27
+ );
30
28
 
31
- &.mat-mdc-chip-selected,
32
- &.mat-mdc-chip-highlighted {
33
- @include _chip-variant($background, $foreground);
34
- }
29
+ @return (default: $default-background, default-contrast: $default-foreground);
35
30
  }
36
31
 
37
32
  @mixin color($config-or-theme) {
38
33
  $config: theming.get-color-config($config-or-theme);
39
- $primary: map.get($config, primary);
40
- $accent: map.get($config, accent);
41
- $warn: map.get($config, warn);
42
- $foreground: map.get($config, foreground);
43
- $is-dark: map.get($config, is-dark);
44
-
45
- @include mdc-helpers.using-mdc-theme($config) {
46
- $on-surface: mdc-theme-color.prop-value(on-surface);
47
- $surface: mdc-theme-color.prop-value(surface);
48
-
49
- .mat-mdc-standard-chip {
50
- $standard-background: if(
51
- meta.type-of($on-surface) == color and meta.type-of($surface) == color,
52
- color.mix($on-surface, $surface, 12%),
53
- $on-surface
54
- );
55
34
 
56
- @include _chip-variant(
57
- $standard-background,
58
- if($is-dark, mdc-color-palette.$grey-50, mdc-color-palette.$grey-900)
59
- );
35
+ .mat-mdc-standard-chip {
36
+ $default-palette: _get-default-palette($config);
37
+ $default-config: map.merge($config, (primary: $default-palette));
38
+ $default-color-tokens: tokens-mdc-chip.get-color-tokens($default-config);
39
+ @include mdc-chip-theme.theme($default-color-tokens);
60
40
 
41
+ &.mat-mdc-chip-selected,
42
+ &.mat-mdc-chip-highlighted {
61
43
  &.mat-primary {
62
- @include _colored-chip($primary);
44
+ $primary-color-tokens: tokens-mdc-chip.get-color-tokens($config);
45
+ @include mdc-chip-theme.theme($primary-color-tokens);
63
46
  }
64
47
 
65
48
  &.mat-accent {
66
- @include _colored-chip($accent);
49
+ $accent-config: map.merge($config, (primary: map.get($config, accent)));
50
+ $accent-color-tokens: tokens-mdc-chip.get-color-tokens($accent-config);
51
+ @include mdc-chip-theme.theme($accent-color-tokens);
67
52
  }
68
53
 
69
54
  &.mat-warn {
70
- @include _colored-chip($warn);
55
+ $warn-config: map.merge($config, (primary: map.get($config, warn)));
56
+ $warn-color-tokens: tokens-mdc-chip.get-color-tokens($warn-config);
57
+ @include mdc-chip-theme.theme($warn-color-tokens);
71
58
  }
72
59
  }
73
60
  }
74
61
 
75
62
  .mat-mdc-chip-focus-overlay {
76
- background: map.get($foreground, base);
63
+ background: map.get(map.get($config, foreground), base);
77
64
  }
78
65
  }
79
66
 
80
67
  @mixin typography($config-or-theme) {
81
68
  $config: typography.private-typography-to-2018-config(
82
- theming.get-typography-config($config-or-theme));
83
- @include mdc-chip-set.core-styles($query: mdc-helpers.$mdc-typography-styles-query);
84
- @include mdc-helpers.using-mdc-typography($config) {
85
- // Note that we don't go through MDC's typography mixin, because it assigns the styles to
86
- // an inner element which makes it difficult for clients to customize. Instead we apply the
87
- // same styles ourselves to the root.
88
- .mat-mdc-standard-chip {
89
- @include mdc-typography.typography(body2, $query: mdc-helpers.$mdc-typography-styles-query);
90
- }
69
+ theming.get-typography-config($config-or-theme)
70
+ );
71
+ $typography-tokens: tokens-mdc-chip.get-typography-tokens($config);
72
+
73
+ .mat-mdc-standard-chip {
74
+ @include mdc-chip-theme.theme($typography-tokens);
91
75
  }
92
76
  }
93
77
 
94
78
  @mixin density($config-or-theme) {
95
79
  $density-scale: theming.get-density-config($config-or-theme);
96
- $density-scale: theming.clamp-density($density-scale, -2);
80
+ $density-tokens: tokens-mdc-chip.get-density-tokens($density-scale);
97
81
  .mat-mdc-chip.mat-mdc-standard-chip {
98
- @include mdc-chip-theme.density($density-scale, $query: mdc-helpers.$mdc-base-styles-query);
82
+ @include mdc-chip-theme.theme($density-tokens);
99
83
  }
100
84
  }
101
85
 
@@ -83,24 +83,9 @@ $mat-typography-mdc-level-mappings: (
83
83
  @return $mdc-config;
84
84
  }
85
85
 
86
- // Converts an MDC typography level config to an Angular Material one.
87
- @function typography-config-level-from-mdc($mdc-level, $font-family: null) {
88
- $mdc-level-config: map.get(mdc-typography.$styles, $mdc-level);
89
-
90
- // Explicitly default the font family to null since we'll apply it globally
91
- // through the `define-typgraphy-config`/`define-legacy-typography-config`.
92
- @return typography.define-typography-level(
93
- $font-family: $font-family,
94
- $font-size: map.get($mdc-level-config, font-size),
95
- $line-height: map.get($mdc-level-config, line-height),
96
- $font-weight: map.get($mdc-level-config, font-weight),
97
- $letter-spacing: map.get($mdc-level-config, letter-spacing)
98
- );
99
- }
100
-
101
86
  // MDC logs a warning if the `contrast-tone` function is called with a CSS variable.
102
87
  // This function falls back to determining the tone based on whether the theme is light or dark.
103
- @function _variable-safe-contrast-tone($value, $is-dark) {
88
+ @function variable-safe-contrast-tone($value, $is-dark) {
104
89
  @if ($value == 'dark' or $value == 'light' or type-of($value) == 'color') {
105
90
  @return mdc-theme-color.contrast-tone($value);
106
91
  }
@@ -109,7 +94,7 @@ $mat-typography-mdc-level-mappings: (
109
94
  }
110
95
 
111
96
  @function _variable-safe-ink-color-for-fill($text-style, $fill-color, $is-dark) {
112
- $contrast-tone: _variable-safe-contrast-tone($fill-color, $is-dark);
97
+ $contrast-tone: variable-safe-contrast-tone($fill-color, $is-dark);
113
98
  @return map.get(map.get(mdc-theme-color.$text-colors, $contrast-tone), $text-style);
114
99
  }
115
100
 
@@ -137,17 +122,17 @@ $mat-typography-mdc-level-mappings: (
137
122
  // Set new values based on the given Angular Material theme.
138
123
  mdc-theme-color.$primary: $primary;
139
124
  mdc-theme-color.$on-primary:
140
- if(_variable-safe-contrast-tone(mdc-theme-color.$primary, $is-dark) == 'dark', #000, #fff);
125
+ if(variable-safe-contrast-tone(mdc-theme-color.$primary, $is-dark) == 'dark', #000, #fff);
141
126
  mdc-theme-color.$secondary: $accent;
142
127
  mdc-theme-color.$on-secondary:
143
- if(_variable-safe-contrast-tone(mdc-theme-color.$secondary, $is-dark) == 'dark', #000, #fff);
128
+ if(variable-safe-contrast-tone(mdc-theme-color.$secondary, $is-dark) == 'dark', #000, #fff);
144
129
  mdc-theme-color.$background: theming.get-color-from-palette($background-palette, background);
145
130
  mdc-theme-color.$surface: theming.get-color-from-palette($background-palette, card);
146
131
  mdc-theme-color.$on-surface:
147
- if(_variable-safe-contrast-tone(mdc-theme-color.$surface, $is-dark) == 'dark', #000, #fff);
132
+ if(variable-safe-contrast-tone(mdc-theme-color.$surface, $is-dark) == 'dark', #000, #fff);
148
133
  mdc-theme-color.$error: $warn;
149
134
  mdc-theme-color.$on-error:
150
- if(_variable-safe-contrast-tone(mdc-theme-color.$error, $is-dark) == 'dark', #000, #fff);
135
+ if(variable-safe-contrast-tone(mdc-theme-color.$error, $is-dark) == 'dark', #000, #fff);
151
136
  mdc-theme-color.$property-values: (
152
137
  // Primary
153
138
  primary: mdc-theme-color.$primary,
@@ -238,19 +223,19 @@ $mat-typography-mdc-level-mappings: (
238
223
  $font-family: mdc-typography.$font-family;
239
224
  @return (
240
225
  font-family: $font-family,
241
- headline-1: typography-config-level-from-mdc(headline1, $font-family),
242
- headline-2: typography-config-level-from-mdc(headline2, $font-family),
243
- headline-3: typography-config-level-from-mdc(headline3, $font-family),
244
- headline-4: typography-config-level-from-mdc(headline4, $font-family),
245
- headline-5: typography-config-level-from-mdc(headline5, $font-family),
246
- headline-6: typography-config-level-from-mdc(headline6, $font-family),
247
- subtitle-1: typography-config-level-from-mdc(subtitle1, $font-family),
248
- subtitle-2: typography-config-level-from-mdc(subtitle2, $font-family),
249
- body-1: typography-config-level-from-mdc(body1, $font-family),
250
- body-2: typography-config-level-from-mdc(body2, $font-family),
251
- caption: typography-config-level-from-mdc(caption, $font-family),
252
- button: typography-config-level-from-mdc(button, $font-family),
253
- overline: typography-config-level-from-mdc(overline, $font-family),
226
+ headline-1: typography.typography-config-level-from-mdc(headline1, $font-family),
227
+ headline-2: typography.typography-config-level-from-mdc(headline2, $font-family),
228
+ headline-3: typography.typography-config-level-from-mdc(headline3, $font-family),
229
+ headline-4: typography.typography-config-level-from-mdc(headline4, $font-family),
230
+ headline-5: typography.typography-config-level-from-mdc(headline5, $font-family),
231
+ headline-6: typography.typography-config-level-from-mdc(headline6, $font-family),
232
+ subtitle-1: typography.typography-config-level-from-mdc(subtitle1, $font-family),
233
+ subtitle-2: typography.typography-config-level-from-mdc(subtitle2, $font-family),
234
+ body-1: typography.typography-config-level-from-mdc(body1, $font-family),
235
+ body-2: typography.typography-config-level-from-mdc(body2, $font-family),
236
+ caption: typography.typography-config-level-from-mdc(caption, $font-family),
237
+ button: typography.typography-config-level-from-mdc(button, $font-family),
238
+ overline: typography.typography-config-level-from-mdc(overline, $font-family),
254
239
  );
255
240
  }
256
241
 
@@ -0,0 +1,37 @@
1
+ @use 'sass:map';
2
+ @use 'sass:meta';
3
+
4
+ /// Include content under the current selector (&) or the document root if there is no current
5
+ /// selector.
6
+ /// @param {String} $root [html] The default root selector to use when there is no current selector.
7
+ /// @output The given content under the current selector, or root selector if there is no current
8
+ /// selector.
9
+ /// @content Content to output under the current selector, or root selector if there is no current
10
+ /// selector.
11
+ @mixin current-selector-or-root($root: html) {
12
+ @at-root #{& or $root} {
13
+ @content;
14
+ }
15
+ }
16
+
17
+ /// A version of the standard `map.deep-merge` function that takes a variable number of arguments.
18
+ /// Each argument is deep-merged into the final result from left to right.
19
+ /// @param {List} $maps The maps to combine with map.deep-merge
20
+ /// @return {Map} The combined result of successively calling map.deep-merge with each parameter.
21
+ @function deep-merge-all($maps...) {
22
+ $result: ();
23
+ @each $map in $maps {
24
+ $result: map.deep-merge($result, $map);
25
+ }
26
+ @return $result;
27
+ }
28
+
29
+ /// Coerces the given value to a list, by converting any non-list value into a single-item list.
30
+ /// This should be used when dealing with user-passed lists of args to avoid confusing errors,
31
+ /// since Sass treats `($x)` as equivalent to `$x`.
32
+ /// @param {Any} $value The value to coerce to a list.
33
+ /// @return {List} The original $value if it was a list, otherwise a single-item list containing
34
+ /// $value.
35
+ @function coerce-to-list($value) {
36
+ @return if(meta.type-of($value) != 'list', ($value,), $value);
37
+ }
@@ -3,9 +3,9 @@
3
3
  @use '@material/theme/custom-properties' as mdc-custom-properties;
4
4
  @use '@material/theme/theme' as mdc-theme;
5
5
  @use '@material/theme/keys' as mdc-keys;
6
- @use '../mdc-helpers/mdc-helpers';
7
6
  @use '../theming/palette';
8
7
  @use '../theming/theming';
8
+ @use '../typography/typography';
9
9
 
10
10
  $_placeholder-color-palette: theming.define-palette(palette.$red-palette);
11
11
 
@@ -20,7 +20,7 @@ $placeholder-color-config: (
20
20
  background: palette.$light-theme-background-palette,
21
21
  );
22
22
 
23
- $_placeholder-typography-level-config: mdc-helpers.typography-config-level-from-mdc(body1);
23
+ $_placeholder-typography-level-config: typography.typography-config-level-from-mdc(body1);
24
24
 
25
25
  // Placeholder typography config that can be passed to token getter functions when generating token
26
26
  // slots.
@@ -52,7 +52,7 @@ $_component-prefix: null;
52
52
  $_component-prefix: '' !global;
53
53
  @each $item in $rest {
54
54
  $_component-prefix:
55
- if($_component-prefix == '', $item, '#{$_component-prefix}-#{$item}') !global;
55
+ if($_component-prefix == '', $item, '#{$_component-prefix}-#{$item}') !global;
56
56
  }
57
57
  @include mdc-custom-properties.configure($varname-prefix: $first) {
58
58
  @content;
@@ -87,15 +87,6 @@ $_component-prefix: null;
87
87
  }
88
88
  }
89
89
 
90
- // Merges together a list of maps into a single map.
91
- @function merge-all($maps...) {
92
- $result: ();
93
- @each $map in $maps {
94
- $result: map.merge($result, $map);
95
- }
96
- @return $result;
97
- }
98
-
99
90
  // MDC doesn't currently handle elevation tokens properly. As a temporary workaround we can combine
100
91
  // the elevation and shadow-color tokens into a full box-shadow and use it as the value for the
101
92
  // elevation token.
@@ -0,0 +1,84 @@
1
+ @use 'sass:map';
2
+ @use 'sass:meta';
3
+ @use '../../style/sass-utils';
4
+
5
+ @use './mat/card' as tokens-mat-card;
6
+ @use './mat/radio' as tokens-mat-radio;
7
+ @use './mat/snack-bar' as tokens-mat-snack-bar;
8
+ @use './mat/tab-header' as tokens-mat-tab-header;
9
+ @use './mat/tab-header-with-background' as tokens-mat-tab-header-with-background;
10
+ @use './mdc/checkbox' as tokens-mdc-checkbox;
11
+ @use './mdc/circular-progress' as tokens-mdc-circular-progress;
12
+ @use './mdc/dialog' as tokens-mdc-dialog;
13
+ @use './mdc/elevated-card' as tokens-mdc-elevated-card;
14
+ @use './mdc/icon-button' as tokens-mdc-icon-button;
15
+ @use './mdc/linear-progress' as tokens-mdc-linear-progress;
16
+ @use './mdc/list' as tokens-mdc-list;
17
+ @use './mdc/outlined-card' as tokens-mdc-outlined-card;
18
+ @use './mdc/radio' as tokens-mdc-radio;
19
+ @use './mdc/snack-bar' as tokens-mdc-snack-bar;
20
+ @use './mdc/tab' as tokens-mdc-tab;
21
+ @use './mdc/tab-indicator' as tokens-mdc-tab-indicator;
22
+
23
+ /// Gets the tokens for the given theme, m2 tokens module, and theming system.
24
+ /// @param {Map} $theme The Angular Material theme object to generate token values from.
25
+ /// @param {String} $module The Sass module containing the token getter functions.
26
+ /// @param {String} $system The theming system to get tokens for. Valid values are: unthemable,
27
+ /// color, typography, density.
28
+ /// @return {Map} The token map by calling the token getter for the given system in the given module
29
+ /// with the given Angular Material theme. Token names are not fully-qualified.
30
+ @function _get-tokens-for-module-and-system($theme, $module, $system) {
31
+ @if $system == unthemable {
32
+ @return meta.call(
33
+ meta.get-function(get-#{$system}-tokens, $module: $module));
34
+ }
35
+ @if not map.get($theme, $system) {
36
+ @return ();
37
+ }
38
+ @return meta.call(
39
+ meta.get-function(get-#{$system}-tokens, $module: $module), map.get($theme, $system));
40
+ }
41
+
42
+ /// Gets the fully qualified tokens map for the given theme and m2 tokens module.
43
+ /// @param {Map} $theme The Angular Material theme object to generate token values from.
44
+ /// @param {String} $module The Sass module containing the token getter functions.
45
+ /// @return {Map} The token map by calling the token getters in the given module with the given
46
+ /// Angular Material theme. Token names are fully-qualified.
47
+ @function _get-tokens-for-module($theme, $module) {
48
+ $tokens: sass-utils.deep-merge-all(
49
+ _get-tokens-for-module-and-system($theme, $module, unthemable),
50
+ _get-tokens-for-module-and-system($theme, $module, color),
51
+ _get-tokens-for-module-and-system($theme, $module, typography),
52
+ _get-tokens-for-module-and-system($theme, $module, density));
53
+ @return map.set((), map.get(meta.module-variables($module), prefix), $tokens);
54
+ }
55
+
56
+ /// Gets the full set of M2 tokens for the given theme object.
57
+ /// @param {Map} $theme The Angular Material theme object to generate token values from.
58
+ /// @return {Map} The token map for the given Angular Material theme. Returned format:
59
+ /// (
60
+ /// (fully, qualified, namespace): (
61
+ /// token: value
62
+ /// )
63
+ /// )
64
+ @function m2-tokens-from-theme($theme) {
65
+ @return sass-utils.deep-merge-all(
66
+ _get-tokens-for-module($theme, tokens-mat-card),
67
+ _get-tokens-for-module($theme, tokens-mat-radio),
68
+ _get-tokens-for-module($theme, tokens-mat-snack-bar),
69
+ _get-tokens-for-module($theme, tokens-mat-tab-header),
70
+ _get-tokens-for-module($theme, tokens-mat-tab-header-with-background),
71
+ _get-tokens-for-module($theme, tokens-mdc-checkbox),
72
+ _get-tokens-for-module($theme, tokens-mdc-circular-progress),
73
+ _get-tokens-for-module($theme, tokens-mdc-dialog),
74
+ _get-tokens-for-module($theme, tokens-mdc-elevated-card),
75
+ _get-tokens-for-module($theme, tokens-mdc-icon-button),
76
+ _get-tokens-for-module($theme, tokens-mdc-linear-progress),
77
+ _get-tokens-for-module($theme, tokens-mdc-list),
78
+ _get-tokens-for-module($theme, tokens-mdc-outlined-card),
79
+ _get-tokens-for-module($theme, tokens-mdc-radio),
80
+ _get-tokens-for-module($theme, tokens-mdc-snack-bar),
81
+ _get-tokens-for-module($theme, tokens-mdc-tab),
82
+ _get-tokens-for-module($theme, tokens-mdc-tab-indicator),
83
+ );
84
+ }
@@ -2,6 +2,7 @@
2
2
  @use '../../token-utils';
3
3
  @use '../../../theming/theming';
4
4
  @use '../../../typography/typography-utils';
5
+ @use '../../../style/sass-utils';
5
6
 
6
7
  // The prefix used to generate the fully qualified name for tokens in this file.
7
8
  $prefix: (mat, card);
@@ -18,7 +19,7 @@ $prefix: (mat, card);
18
19
 
19
20
  @return (
20
21
  // Text color of the card's subtitle.
21
- subtitle-text-color: theming.get-color-from-palette($foreground, secondary-text),
22
+ subtitle-text-color: theming.get-color-from-palette($foreground, secondary-text),
22
23
  );
23
24
  }
24
25
 
@@ -26,27 +27,27 @@ $prefix: (mat, card);
26
27
  @function get-typography-tokens($config) {
27
28
  @return (
28
29
  // Font family of the card's title.
29
- title-text-font: typography-utils.font-family($config, headline-6)
30
+ title-text-font: typography-utils.font-family($config, headline-6)
30
31
  or typography-utils.font-family($config),
31
32
  // Line height of the card's title.
32
- title-text-line-height: typography-utils.line-height($config, headline-6),
33
+ title-text-line-height: typography-utils.line-height($config, headline-6),
33
34
  // Font size of the card's title.
34
- title-text-size: typography-utils.font-size($config, headline-6),
35
+ title-text-size: typography-utils.font-size($config, headline-6),
35
36
  // Letter spacing of the card's title.
36
- title-text-tracking: typography-utils.letter-spacing($config, headline-6),
37
+ title-text-tracking: typography-utils.letter-spacing($config, headline-6),
37
38
  // Font weight of the card's title.
38
- title-text-weight: typography-utils.font-weight($config, headline-6),
39
+ title-text-weight: typography-utils.font-weight($config, headline-6),
39
40
  // Font family of the card's subtitle.
40
- subtitle-text-font: typography-utils.font-family($config, subtitle-2)
41
+ subtitle-text-font: typography-utils.font-family($config, subtitle-2)
41
42
  or typography-utils.font-family($config),
42
43
  // Line height of the card's subtitle.
43
- subtitle-text-line-height: typography-utils.line-height($config, subtitle-2),
44
+ subtitle-text-line-height: typography-utils.line-height($config, subtitle-2),
44
45
  // Font size of the card's subtitle.
45
- subtitle-text-size: typography-utils.font-size($config, subtitle-2),
46
+ subtitle-text-size: typography-utils.font-size($config, subtitle-2),
46
47
  // Letter spacing of the card's subtitle.
47
- subtitle-text-tracking: typography-utils.letter-spacing($config, subtitle-2),
48
+ subtitle-text-tracking: typography-utils.letter-spacing($config, subtitle-2),
48
49
  // Font weight of the card's subtitle.
49
- subtitle-text-weight: typography-utils.font-weight($config, subtitle-2),
50
+ subtitle-text-weight: typography-utils.font-weight($config, subtitle-2),
50
51
  );
51
52
  }
52
53
 
@@ -58,10 +59,10 @@ $prefix: (mat, card);
58
59
  // Combines the tokens generated by the above functions into a single map with placeholder values.
59
60
  // This is used to create token slots.
60
61
  @function get-token-slots() {
61
- @return token-utils.merge-all(
62
- get-unthemable-tokens(),
63
- get-color-tokens(token-utils.$placeholder-color-config),
64
- get-typography-tokens(token-utils.$placeholder-typography-config),
65
- get-density-tokens(token-utils.$placeholder-density-config)
62
+ @return sass-utils.deep-merge-all(
63
+ get-unthemable-tokens(),
64
+ get-color-tokens(token-utils.$placeholder-color-config),
65
+ get-typography-tokens(token-utils.$placeholder-typography-config),
66
+ get-density-tokens(token-utils.$placeholder-density-config)
66
67
  );
67
68
  }