@angular/material 16.1.4 → 16.1.6

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 (94) hide show
  1. package/autocomplete/index.d.ts +6 -2
  2. package/bottom-sheet/_bottom-sheet-theme.scss +10 -11
  3. package/button-toggle/_button-toggle-theme.scss +20 -97
  4. package/button-toggle/_button-toggle-variables.scss +2 -0
  5. package/core/index.d.ts +2 -2
  6. package/core/tokens/_token-utils.scss +2 -0
  7. package/core/tokens/m2/mat/_bottom-sheet.scss +56 -0
  8. package/core/tokens/m2/mat/_divider.scss +45 -0
  9. package/core/tokens/m2/mat/_expansion.scss +90 -0
  10. package/core/tokens/m2/mat/_legacy-button-toggle.scss +63 -0
  11. package/core/tokens/m2/mat/_sidenav.scss +65 -0
  12. package/core/tokens/m2/mat/_standard-button-toggle.scss +87 -0
  13. package/core/tokens/m2/mat/_toolbar.scss +79 -0
  14. package/divider/_divider-theme.scss +6 -8
  15. package/esm2022/autocomplete/autocomplete-trigger.mjs +61 -38
  16. package/esm2022/bottom-sheet/bottom-sheet-container.mjs +3 -3
  17. package/esm2022/button-toggle/button-toggle.mjs +2 -2
  18. package/esm2022/chips/chip-option.mjs +2 -2
  19. package/esm2022/chips/chip-row.mjs +10 -7
  20. package/esm2022/chips/chip.mjs +2 -2
  21. package/esm2022/core/option/option.mjs +9 -5
  22. package/esm2022/core/version.mjs +1 -1
  23. package/esm2022/divider/divider.mjs +2 -2
  24. package/esm2022/expansion/expansion-animations.mjs +5 -2
  25. package/esm2022/expansion/expansion-panel-header.mjs +3 -3
  26. package/esm2022/expansion/expansion-panel.mjs +3 -3
  27. package/esm2022/form-field/form-field.mjs +3 -3
  28. package/esm2022/legacy-dialog/testing/dialog-opener.mjs +6 -1
  29. package/esm2022/legacy-menu/menu.mjs +4 -2
  30. package/esm2022/legacy-table/text-column.mjs +6 -2
  31. package/esm2022/legacy-tabs/tab.mjs +6 -3
  32. package/esm2022/legacy-tooltip/tooltip.mjs +5 -2
  33. package/esm2022/menu/menu-item.mjs +4 -4
  34. package/esm2022/menu/menu.mjs +3 -3
  35. package/esm2022/radio/radio.mjs +13 -1
  36. package/esm2022/sidenav/drawer.mjs +3 -3
  37. package/esm2022/sidenav/sidenav.mjs +3 -3
  38. package/esm2022/slide-toggle/slide-toggle.mjs +2 -2
  39. package/esm2022/toolbar/toolbar.mjs +2 -2
  40. package/expansion/_expansion-legacy-index.scss +0 -1
  41. package/expansion/_expansion-theme.import.scss +0 -2
  42. package/expansion/_expansion-theme.scss +12 -68
  43. package/fesm2022/autocomplete.mjs +61 -38
  44. package/fesm2022/autocomplete.mjs.map +1 -1
  45. package/fesm2022/bottom-sheet.mjs +2 -2
  46. package/fesm2022/bottom-sheet.mjs.map +1 -1
  47. package/fesm2022/button-toggle.mjs +2 -2
  48. package/fesm2022/button-toggle.mjs.map +1 -1
  49. package/fesm2022/chips.mjs +13 -10
  50. package/fesm2022/chips.mjs.map +1 -1
  51. package/fesm2022/core.mjs +9 -5
  52. package/fesm2022/core.mjs.map +1 -1
  53. package/fesm2022/divider.mjs +2 -2
  54. package/fesm2022/divider.mjs.map +1 -1
  55. package/fesm2022/expansion.mjs +8 -5
  56. package/fesm2022/expansion.mjs.map +1 -1
  57. package/fesm2022/form-field.mjs +2 -2
  58. package/fesm2022/form-field.mjs.map +1 -1
  59. package/fesm2022/legacy-dialog/testing.mjs +5 -0
  60. package/fesm2022/legacy-dialog/testing.mjs.map +1 -1
  61. package/fesm2022/legacy-menu.mjs +3 -1
  62. package/fesm2022/legacy-menu.mjs.map +1 -1
  63. package/fesm2022/legacy-table.mjs +5 -1
  64. package/fesm2022/legacy-table.mjs.map +1 -1
  65. package/fesm2022/legacy-tabs.mjs +5 -2
  66. package/fesm2022/legacy-tabs.mjs.map +1 -1
  67. package/fesm2022/legacy-tooltip.mjs +4 -1
  68. package/fesm2022/legacy-tooltip.mjs.map +1 -1
  69. package/fesm2022/menu.mjs +5 -5
  70. package/fesm2022/menu.mjs.map +1 -1
  71. package/fesm2022/radio.mjs +12 -0
  72. package/fesm2022/radio.mjs.map +1 -1
  73. package/fesm2022/sidenav.mjs +4 -4
  74. package/fesm2022/sidenav.mjs.map +1 -1
  75. package/fesm2022/slide-toggle.mjs +2 -2
  76. package/fesm2022/slide-toggle.mjs.map +1 -1
  77. package/fesm2022/toolbar.mjs +2 -2
  78. package/fesm2022/toolbar.mjs.map +1 -1
  79. package/legacy-prebuilt-themes/legacy-deeppurple-amber.css +1 -1
  80. package/legacy-prebuilt-themes/legacy-indigo-pink.css +1 -1
  81. package/legacy-prebuilt-themes/legacy-pink-bluegrey.css +1 -1
  82. package/legacy-prebuilt-themes/legacy-purple-green.css +1 -1
  83. package/package.json +2 -2
  84. package/prebuilt-themes/deeppurple-amber.css +1 -1
  85. package/prebuilt-themes/indigo-pink.css +1 -1
  86. package/prebuilt-themes/pink-bluegrey.css +1 -1
  87. package/prebuilt-themes/purple-green.css +1 -1
  88. package/radio/index.d.ts +4 -1
  89. package/schematics/ng-add/index.js +1 -1
  90. package/schematics/ng-add/index.mjs +1 -1
  91. package/sidenav/_sidenav-theme.scss +6 -69
  92. package/toolbar/_toolbar-theme.scss +25 -71
  93. package/expansion/_expansion-mixins.import.scss +0 -1
  94. package/expansion/_expansion-mixins.scss +0 -11
@@ -302,6 +302,8 @@ export declare abstract class _MatAutocompleteTriggerBase implements ControlValu
302
302
  private _componentDestroyed;
303
303
  private _autocompleteDisabled;
304
304
  private _scrollStrategy;
305
+ private _keydownSubscription;
306
+ private _outsideClickSubscription;
305
307
  /** Old value of the native input. Used to work around issues with the `input` event on IE. */
306
308
  private _previousValue;
307
309
  /** Strategy that is used to position the panel. */
@@ -428,6 +430,10 @@ export declare abstract class _MatAutocompleteTriggerBase implements ControlValu
428
430
  */
429
431
  private _clearPreviousSelectedOption;
430
432
  private _attachOverlay;
433
+ /** Handles keyboard events coming from the overlay panel. */
434
+ private _handlePanelKeydown;
435
+ /** Updates the panel's visibility state and any trigger state tied to id. */
436
+ private _updatePanelState;
431
437
  private _getOverlayConfig;
432
438
  private _getOverlayPosition;
433
439
  /** Sets the positions on a position strategy based on the directive's input state. */
@@ -450,8 +456,6 @@ export declare abstract class _MatAutocompleteTriggerBase implements ControlValu
450
456
  private _getWindow;
451
457
  /** Scrolls to a particular option in the list. */
452
458
  private _scrollToOption;
453
- /** Handles keyboard events coming from the overlay panel. */
454
- private _handleOverlayEvents;
455
459
  /**
456
460
  * Track which modal we have modified the `aria-owns` attribute of. When the combobox trigger is
457
461
  * inside an aria-modal, we apply aria-owns to the parent modal with the `id` of the options
@@ -1,26 +1,25 @@
1
- @use 'sass:map';
2
- @use '../core/style/private';
3
1
  @use '../core/typography/typography';
4
- @use '../core/typography/typography-utils';
5
2
  @use '../core/theming/theming';
3
+ @use '../core/style/sass-utils';
4
+ @use '../core/tokens/token-utils';
5
+ @use '../core/tokens/m2/mat/bottom-sheet' as tokens-mat-bottom-sheet;
6
6
 
7
7
  @mixin color($config-or-theme) {
8
8
  $config: theming.get-color-config($config-or-theme);
9
- $background: map.get($config, background);
10
- $foreground: map.get($config, foreground);
11
9
 
12
- .mat-bottom-sheet-container {
13
- @include private.private-theme-elevation(16, $config);
14
- background: theming.get-color-from-palette($background, dialog);
15
- color: theming.get-color-from-palette($foreground, text);
10
+ @include sass-utils.current-selector-or-root() {
11
+ @include token-utils.create-token-values(tokens-mat-bottom-sheet.$prefix,
12
+ tokens-mat-bottom-sheet.get-color-tokens($config));
16
13
  }
17
14
  }
18
15
 
19
16
  @mixin typography($config-or-theme) {
20
17
  $config: typography.private-typography-to-2014-config(
21
18
  theming.get-typography-config($config-or-theme));
22
- .mat-bottom-sheet-container {
23
- @include typography-utils.typography-level($config, body-1);
19
+
20
+ @include sass-utils.current-selector-or-root() {
21
+ @include token-utils.create-token-values(tokens-mat-bottom-sheet.$prefix,
22
+ tokens-mat-bottom-sheet.get-typography-tokens($config));
24
23
  }
25
24
  }
26
25
 
@@ -1,118 +1,41 @@
1
- @use 'sass:map';
2
- @use '../core/style/private';
3
1
  @use '../core/theming/theming';
4
2
  @use '../core/typography/typography';
5
- @use '../core/typography/typography-utils';
6
- @use '../core/density/private/compatibility';
7
- @use './button-toggle-variables';
3
+ @use '../core/tokens/m2/mat/legacy-button-toggle' as tokens-mat-legacy-button-toggle;
4
+ @use '../core/tokens/m2/mat/standard-button-toggle' as tokens-mat-standard-button-toggle;
5
+ @use '../core/tokens/token-utils';
6
+ @use '../core/style/sass-utils';
8
7
 
9
8
  @mixin color($config-or-theme) {
10
9
  $config: theming.get-color-config($config-or-theme);
11
- $foreground: map.get($config, foreground);
12
- $background: map.get($config, background);
13
- $divider-color: theming.get-color-from-palette($foreground, divider);
14
- $theme-divider-color: map.get($foreground, divider);
15
10
 
16
- // By default the theme usually has an rgba color for the dividers, which can
17
- // stack up with the background of a button toggle. This can cause the border
18
- // of a selected toggle to look different from an deselected one. We use a solid
19
- // color to ensure that the border always stays the same.
20
- $divider-color: if(type-of($theme-divider-color) == color,
21
- theming.private-rgba-to-hex($theme-divider-color, map.get($background, card)),
22
- $theme-divider-color
23
- );
24
-
25
- .mat-button-toggle-standalone,
26
- .mat-button-toggle-group {
27
- @include private.private-theme-overridable-elevation(2, $config);
28
- }
29
-
30
- .mat-button-toggle-standalone.mat-button-toggle-appearance-standard,
31
- .mat-button-toggle-group-appearance-standard {
32
- &:not([class*='mat-elevation-z']) {
33
- box-shadow: none;
34
- }
35
- }
36
-
37
- .mat-button-toggle {
38
- color: theming.get-color-from-palette($foreground, hint-text);
39
-
40
- .mat-button-toggle-focus-overlay {
41
- background-color: theming.get-color-from-palette($background, focused-button);
42
- }
43
- }
44
-
45
- .mat-button-toggle-appearance-standard {
46
- color: theming.get-color-from-palette($foreground, text);
47
- background: theming.get-color-from-palette($background, card);
48
-
49
- .mat-button-toggle-focus-overlay {
50
- background-color: theming.get-color-from-palette($background, focused-button, 1);
51
- }
52
- }
53
-
54
- .mat-button-toggle-group-appearance-standard .mat-button-toggle + .mat-button-toggle {
55
- border-left: solid 1px $divider-color;
56
- }
57
-
58
- [dir='rtl'] .mat-button-toggle-group-appearance-standard .mat-button-toggle + .mat-button-toggle {
59
- border-left: none;
60
- border-right: solid 1px $divider-color;
61
- }
62
-
63
- .mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical {
64
- .mat-button-toggle + .mat-button-toggle {
65
- border-left: none;
66
- border-right: none;
67
- border-top: solid 1px $divider-color;
68
- }
69
- }
70
-
71
- .mat-button-toggle-checked {
72
- background-color: theming.get-color-from-palette($background, selected-button);
73
- color: theming.get-color-from-palette($foreground, secondary-text);
74
-
75
- &.mat-button-toggle-appearance-standard {
76
- color: theming.get-color-from-palette($foreground, text);
77
- }
78
- }
79
-
80
- .mat-button-toggle-disabled {
81
- color: theming.get-color-from-palette($foreground, disabled-button);
82
- background-color: theming.get-color-from-palette($background, disabled-button-toggle);
83
-
84
- &.mat-button-toggle-appearance-standard {
85
- background: theming.get-color-from-palette($background, card);
86
- }
87
-
88
- &.mat-button-toggle-checked {
89
- background-color: theming.get-color-from-palette($background, selected-disabled-button);
90
- }
91
- }
92
-
93
- .mat-button-toggle-standalone.mat-button-toggle-appearance-standard,
94
- .mat-button-toggle-group-appearance-standard {
95
- border: solid 1px $divider-color;
11
+ @include sass-utils.current-selector-or-root() {
12
+ @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix,
13
+ tokens-mat-legacy-button-toggle.get-color-tokens($config));
14
+ @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix,
15
+ tokens-mat-standard-button-toggle.get-color-tokens($config));
96
16
  }
97
17
  }
98
18
 
99
19
  @mixin typography($config-or-theme) {
100
20
  $config: typography.private-typography-to-2014-config(
101
21
  theming.get-typography-config($config-or-theme));
102
- .mat-button-toggle {
103
- font-family: typography-utils.font-family($config);
22
+
23
+ @include sass-utils.current-selector-or-root() {
24
+ @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix,
25
+ tokens-mat-legacy-button-toggle.get-typography-tokens($config));
26
+ @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix,
27
+ tokens-mat-standard-button-toggle.get-typography-tokens($config));
104
28
  }
105
29
  }
106
30
 
107
31
  @mixin density($config-or-theme) {
108
32
  $density-scale: theming.get-density-config($config-or-theme);
109
- $standard-height: compatibility.private-density-prop-value(
110
- button-toggle-variables.$standard-density-config, $density-scale, height);
111
33
 
112
- @include compatibility.private-density-legacy-compatibility() {
113
- .mat-button-toggle-appearance-standard .mat-button-toggle-label-content {
114
- line-height: $standard-height;
115
- }
34
+ @include sass-utils.current-selector-or-root() {
35
+ @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix,
36
+ tokens-mat-legacy-button-toggle.get-density-tokens($density-scale));
37
+ @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix,
38
+ tokens-mat-standard-button-toggle.get-density-tokens($density-scale));
116
39
  }
117
40
  }
118
41
 
@@ -1,3 +1,5 @@
1
+ // TODO(crisbeto): this file isn't used anymore and should be removed.
2
+
1
3
  $standard-height: 48px !default;
2
4
  // Minimum height for highest density can vary based on the content that developers
3
5
  // project into button-toggle's. We use a minimum of `24px` though because commonly
package/core/index.d.ts CHANGED
@@ -606,9 +606,9 @@ export declare class _MatOptionBase<T = any> implements FocusableOption, AfterVi
606
606
  */
607
607
  get viewValue(): string;
608
608
  /** Selects the option. */
609
- select(): void;
609
+ select(emitEvent?: boolean): void;
610
610
  /** Deselects the option. */
611
- deselect(): void;
611
+ deselect(emitEvent?: boolean): void;
612
612
  /** Sets focus onto this option. */
613
613
  focus(_origin?: FocusOrigin, options?: FocusOptions): void;
614
614
  /**
@@ -39,6 +39,8 @@ $placeholder-typography-config: (
39
39
  caption: $_placeholder-typography-level-config,
40
40
  button: $_placeholder-typography-level-config,
41
41
  overline: $_placeholder-typography-level-config,
42
+ subheading-1: $_placeholder-typography-level-config,
43
+ title: $_placeholder-typography-level-config,
42
44
  );
43
45
 
44
46
  // Placeholder density config that can be passed to token getter functions when generating token
@@ -0,0 +1,56 @@
1
+ @use 'sass:map';
2
+ @use '../../token-utils';
3
+ @use '../../../typography/typography-utils';
4
+ @use '../../../theming/theming';
5
+ @use '../../../style/sass-utils';
6
+
7
+ // The prefix used to generate the fully qualified name for tokens in this file.
8
+ $prefix: (mat, bottom-sheet);
9
+
10
+ // Tokens that can't be configured through Angular Material's current theming API,
11
+ // but may be in a future version of the theming API.
12
+ @function get-unthemable-tokens() {
13
+ @return (
14
+ // TODO: will be necessary for M3.
15
+ container-shape: 4px,
16
+ );
17
+ }
18
+
19
+ // Tokens that can be configured through Angular Material's color theming API.
20
+ @function get-color-tokens($config) {
21
+ $foreground: map.get($config, foreground);
22
+ $background: map.get($config, background);
23
+
24
+ @return (
25
+ container-text-color: theming.get-color-from-palette($foreground, text),
26
+ container-background-color: theming.get-color-from-palette($background, dialog),
27
+ );
28
+ }
29
+
30
+ // Tokens that can be configured through Angular Material's typography theming API.
31
+ @function get-typography-tokens($config) {
32
+ @return (
33
+ container-text-font: typography-utils.font-family($config, body-1) or
34
+ typography-utils.font-family($config),
35
+ container-text-line-height: typography-utils.line-height($config, body-1),
36
+ container-text-size: typography-utils.font-size($config, body-1),
37
+ container-text-tracking: typography-utils.letter-spacing($config, body-1),
38
+ container-text-weight: typography-utils.font-weight($config, body-1),
39
+ );
40
+ }
41
+
42
+ // Tokens that can be configured through Angular Material's density theming API.
43
+ @function get-density-tokens($config) {
44
+ @return ();
45
+ }
46
+
47
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
48
+ // This is used to create token slots.
49
+ @function get-token-slots() {
50
+ @return sass-utils.deep-merge-all(
51
+ get-unthemable-tokens(),
52
+ get-color-tokens(token-utils.$placeholder-color-config),
53
+ get-typography-tokens(token-utils.$placeholder-typography-config),
54
+ get-density-tokens(token-utils.$placeholder-density-config)
55
+ );
56
+ }
@@ -0,0 +1,45 @@
1
+ @use 'sass:map';
2
+ @use '../../token-utils';
3
+ @use '../../../theming/theming';
4
+ @use '../../../style/sass-utils';
5
+
6
+ // The prefix used to generate the fully qualified name for tokens in this file.
7
+ $prefix: (mat, divider);
8
+
9
+ // Tokens that can't be configured through Angular Material's current theming API,
10
+ // but may be in a future version of the theming API.
11
+ @function get-unthemable-tokens() {
12
+ @return (
13
+ width: 1px
14
+ );
15
+ }
16
+
17
+ // Tokens that can be configured through Angular Material's color theming API.
18
+ @function get-color-tokens($config) {
19
+ $foreground: map.get($config, foreground);
20
+
21
+ @return (
22
+ color: theming.get-color-from-palette($foreground, divider)
23
+ );
24
+ }
25
+
26
+ // Tokens that can be configured through Angular Material's typography theming API.
27
+ @function get-typography-tokens($config) {
28
+ @return ();
29
+ }
30
+
31
+ // Tokens that can be configured through Angular Material's density theming API.
32
+ @function get-density-tokens($config) {
33
+ @return ();
34
+ }
35
+
36
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
37
+ // This is used to create token slots.
38
+ @function get-token-slots() {
39
+ @return sass-utils.deep-merge-all(
40
+ get-unthemable-tokens(),
41
+ get-color-tokens(token-utils.$placeholder-color-config),
42
+ get-typography-tokens(token-utils.$placeholder-typography-config),
43
+ get-density-tokens(token-utils.$placeholder-density-config)
44
+ );
45
+ }
@@ -0,0 +1,90 @@
1
+ @use 'sass:map';
2
+ @use '../../token-utils';
3
+ @use '../../../theming/theming';
4
+ @use '../../../style/sass-utils';
5
+ @use '../../../typography/typography-utils';
6
+
7
+ // The prefix used to generate the fully qualified name for tokens in this file.
8
+ $prefix: (mat, expansion);
9
+
10
+ // Tokens that can't be configured through Angular Material's current theming API,
11
+ // but may be in a future version of the theming API.
12
+ @function get-unthemable-tokens() {
13
+ @return (
14
+ container-shape: 4px,
15
+ );
16
+ }
17
+
18
+ // Tokens that can be configured through Angular Material's color theming API.
19
+ @function get-color-tokens($config) {
20
+ $foreground: map.get($config, foreground);
21
+ $background: map.get($config, background);
22
+
23
+ @return (
24
+ container-background-color: theming.get-color-from-palette($background, card),
25
+ container-text-color: theming.get-color-from-palette($foreground, text),
26
+ actions-divider-color: theming.get-color-from-palette($foreground, divider),
27
+ header-hover-state-layer-color: theming.get-color-from-palette($background, hover),
28
+ header-focus-state-layer-color: theming.get-color-from-palette($background, hover),
29
+ header-disabled-state-text-color: theming.get-color-from-palette($foreground, disabled-button),
30
+ header-text-color: theming.get-color-from-palette($foreground, text),
31
+ header-description-color: theming.get-color-from-palette($foreground, secondary-text),
32
+ header-indicator-color: theming.get-color-from-palette($foreground, secondary-text),
33
+ );
34
+ }
35
+
36
+ // Tokens that can be configured through Angular Material's typography theming API.
37
+ @function get-typography-tokens($config) {
38
+ $fallback-font-family: typography-utils.font-family($config);
39
+
40
+ @return (
41
+ header-text-font: typography-utils.font-family($config, subheading-1) or $fallback-font-family,
42
+ header-text-size: typography-utils.font-size($config, subheading-1),
43
+ header-text-weight: typography-utils.font-weight($config, subheading-1),
44
+
45
+ // TODO(crisbeto): these two properties weren't set at all before the introduction of tokens,
46
+ // but it's inconsistent not to provide them since the container sets all of them. Eventually
47
+ // we should change the values to use come from `subheading-1`.
48
+ header-text-line-height: inherit,
49
+ header-text-tracking: inherit,
50
+
51
+ container-text-font: typography-utils.font-family($config, body-1) or $fallback-font-family,
52
+ container-text-line-height: typography-utils.line-height($config, body-1),
53
+ container-text-size: typography-utils.font-size($config, body-1),
54
+ container-text-tracking: typography-utils.letter-spacing($config, body-1),
55
+ container-text-weight: typography-utils.font-weight($config, body-1),
56
+ );
57
+ }
58
+
59
+ // Tokens that can be configured through Angular Material's density theming API.
60
+ @function get-density-tokens($config) {
61
+ $scale: theming.clamp-density($config, -3);
62
+ $collapsed-scale: (
63
+ 0: 48px,
64
+ -1: 44px,
65
+ -2: 40px,
66
+ -3: 36px,
67
+ );
68
+ $expanded-scale: (
69
+ 0: 64px,
70
+ -1: 60px,
71
+ -2: 56px,
72
+ -3: 48px,
73
+ );
74
+
75
+ @return (
76
+ header-collapsed-state-height: map.get($collapsed-scale, $scale),
77
+ header-expanded-state-height: map.get($expanded-scale, $scale),
78
+ );
79
+ }
80
+
81
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
82
+ // This is used to create token slots.
83
+ @function get-token-slots() {
84
+ @return sass-utils.deep-merge-all(
85
+ get-unthemable-tokens(),
86
+ get-color-tokens(token-utils.$placeholder-color-config),
87
+ get-typography-tokens(token-utils.$placeholder-typography-config),
88
+ get-density-tokens(token-utils.$placeholder-density-config)
89
+ );
90
+ }
@@ -0,0 +1,63 @@
1
+ @use 'sass:map';
2
+ @use '../../token-utils';
3
+ @use '../../../typography/typography-utils';
4
+ @use '../../../theming/theming';
5
+ @use '../../../style/sass-utils';
6
+
7
+ // The prefix used to generate the fully qualified name for tokens in this file.
8
+ $prefix: (mat, legacy-button-toggle);
9
+
10
+ // Tokens that can't be configured through Angular Material's current theming API,
11
+ // but may be in a future version of the theming API.
12
+ @function get-unthemable-tokens() {
13
+ @return (
14
+ height: 36px,
15
+ shape: 2px,
16
+ focus-state-layer-opacity: 1,
17
+ );
18
+ }
19
+
20
+ // Tokens that can be configured through Angular Material's color theming API.
21
+ @function get-color-tokens($config) {
22
+ $foreground: map.get($config, foreground);
23
+ $background: map.get($config, background);
24
+
25
+ @return (
26
+ text-color: theming.get-color-from-palette($foreground, hint-text),
27
+ state-layer-color: theming.get-color-from-palette($background, focused-button),
28
+ selected-state-text-color: theming.get-color-from-palette($foreground, secondary-text),
29
+ selected-state-background-color: theming.get-color-from-palette($background, selected-button),
30
+ disabled-state-text-color: theming.get-color-from-palette($foreground, disabled-button),
31
+ disabled-state-background-color:
32
+ theming.get-color-from-palette($background, disabled-button-toggle),
33
+ disabled-selected-state-background-color:
34
+ theming.get-color-from-palette($background, selected-disabled-button)
35
+ );
36
+ }
37
+
38
+ // Tokens that can be configured through Angular Material's typography theming API.
39
+ @function get-typography-tokens($config) {
40
+ @return (
41
+ // TODO(crisbeto): other components have tokens for all typography dimensions (font weight,
42
+ // letter spacing etc). The button toggle only has the font to match what it had in the
43
+ // old theming API and to reduce internal breakages. We should introduce more typography
44
+ // tokens at some point.
45
+ text-font: typography-utils.font-family($config),
46
+ );
47
+ }
48
+
49
+ // Tokens that can be configured through Angular Material's density theming API.
50
+ @function get-density-tokens($config) {
51
+ @return ();
52
+ }
53
+
54
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
55
+ // This is used to create token slots.
56
+ @function get-token-slots() {
57
+ @return sass-utils.deep-merge-all(
58
+ get-unthemable-tokens(),
59
+ get-color-tokens(token-utils.$placeholder-color-config),
60
+ get-typography-tokens(token-utils.$placeholder-typography-config),
61
+ get-density-tokens(token-utils.$placeholder-density-config)
62
+ );
63
+ }
@@ -0,0 +1,65 @@
1
+ @use 'sass:color';
2
+ @use 'sass:map';
3
+ @use 'sass:meta';
4
+ @use '../../token-utils';
5
+ @use '../../../theming/theming';
6
+ @use '../../../style/sass-utils';
7
+
8
+ // The prefix used to generate the fully qualified name for tokens in this file.
9
+ $prefix: (mat, sidenav);
10
+
11
+ // Tokens that can't be configured through Angular Material's current theming API,
12
+ // but may be in a future version of the theming API.
13
+ @function get-unthemable-tokens() {
14
+ @return (
15
+ // Currently zero, but it appears to be relevant for M3.
16
+ // See: https://m3.material.io/components/navigation-drawer/overview
17
+ container-shape: 0,
18
+ );
19
+ }
20
+
21
+ // Tokens that can be configured through Angular Material's color theming API.
22
+ @function get-color-tokens($config) {
23
+ $is-dark: map.get($config, is-dark);
24
+ $foreground: map.get($config, foreground);
25
+ $background: map.get($config, background);
26
+ $scrim-opacity: 0.6;
27
+ $scrim-color: theming.get-color-from-palette($background, card, $scrim-opacity);
28
+ $fallback-scrim-color: if($is-dark, rgba(#fff, $scrim-opacity), rgba(#000, $scrim-opacity));
29
+
30
+ @return (
31
+ container-divider-color: theming.get-color-from-palette($foreground, divider),
32
+ container-background-color: theming.get-color-from-palette($background, dialog),
33
+ container-text-color: theming.get-color-from-palette($foreground, text),
34
+ content-background-color: theming.get-color-from-palette($background, background),
35
+ content-text-color: theming.get-color-from-palette($foreground, text),
36
+
37
+ // We use invert() here to have the darken the background color expected to be used.
38
+ // If the background is light, we use a dark backdrop. If the background is dark, we
39
+ // use a light backdrop. If the value isn't a color, Sass will throw an error so we
40
+ // fall back to something generic.
41
+ scrim-color: if(meta.type-of($scrim-color) == color,
42
+ color.invert($scrim-color), $fallback-scrim-color),
43
+ );
44
+ }
45
+
46
+ // Tokens that can be configured through Angular Material's typography theming API.
47
+ @function get-typography-tokens($config) {
48
+ @return ();
49
+ }
50
+
51
+ // Tokens that can be configured through Angular Material's density theming API.
52
+ @function get-density-tokens($config) {
53
+ @return ();
54
+ }
55
+
56
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
57
+ // This is used to create token slots.
58
+ @function get-token-slots() {
59
+ @return sass-utils.deep-merge-all(
60
+ get-unthemable-tokens(),
61
+ get-color-tokens(token-utils.$placeholder-color-config),
62
+ get-typography-tokens(token-utils.$placeholder-typography-config),
63
+ get-density-tokens(token-utils.$placeholder-density-config)
64
+ );
65
+ }
@@ -0,0 +1,87 @@
1
+ @use 'sass:map';
2
+ @use 'sass:meta';
3
+ @use '../../token-utils';
4
+ @use '../../../typography/typography-utils';
5
+ @use '../../../theming/theming';
6
+ @use '../../../style/sass-utils';
7
+
8
+ // The prefix used to generate the fully qualified name for tokens in this file.
9
+ $prefix: (mat, standard-button-toggle);
10
+
11
+ // Tokens that can't be configured through Angular Material's current theming API,
12
+ // but may be in a future version of the theming API.
13
+ @function get-unthemable-tokens() {
14
+ @return (
15
+ shape: 4px,
16
+ hover-state-layer-opacity: 0.04,
17
+ focus-state-layer-opacity: 0.12,
18
+ );
19
+ }
20
+
21
+ // Tokens that can be configured through Angular Material's color theming API.
22
+ @function get-color-tokens($config) {
23
+ $foreground: map.get($config, foreground);
24
+ $background: map.get($config, background);
25
+ $theme-divider-color: theming.get-color-from-palette($foreground, divider);
26
+
27
+ // By default the theme usually has an rgba color for the dividers, which can
28
+ // stack up with the background of a button toggle. This can cause the border
29
+ // of a selected toggle to look different from an deselected one. We use a solid
30
+ // color to ensure that the border always stays the same.
31
+ $divider-color: if(meta.type-of($theme-divider-color) == color,
32
+ theming.private-rgba-to-hex($theme-divider-color, map.get($background, card)),
33
+ $theme-divider-color
34
+ );
35
+
36
+ @return (
37
+ text-color: theming.get-color-from-palette($foreground, text),
38
+ background-color: theming.get-color-from-palette($background, card),
39
+ state-layer-color: theming.get-color-from-palette($background, focused-button, 1),
40
+ selected-state-background-color: theming.get-color-from-palette($background, selected-button),
41
+ selected-state-text-color: theming.get-color-from-palette($foreground, text),
42
+ disabled-state-text-color: theming.get-color-from-palette($foreground, disabled-button),
43
+ disabled-state-background-color: theming.get-color-from-palette($background, card),
44
+ disabled-selected-state-text-color: theming.get-color-from-palette($foreground, text),
45
+ disabled-selected-state-background-color:
46
+ theming.get-color-from-palette($background, selected-disabled-button),
47
+ divider-color: $divider-color,
48
+ );
49
+ }
50
+
51
+ // Tokens that can be configured through Angular Material's typography theming API.
52
+ @function get-typography-tokens($config) {
53
+ @return (
54
+ // TODO(crisbeto): other components have tokens for all typography dimensions (font weight,
55
+ // letter spacing etc). The button toggle only has the font to match what it had in the
56
+ // old theming API and to reduce internal breakages. We should introduce more typography
57
+ // tokens at some point.
58
+ text-font: typography-utils.font-family($config),
59
+ );
60
+ }
61
+
62
+ // Tokens that can be configured through Angular Material's density theming API.
63
+ @function get-density-tokens($config) {
64
+ $density-scale: theming.clamp-density($config, -4);
65
+ $size-scale: (
66
+ 0: 48px,
67
+ -1: 44px,
68
+ -2: 40px,
69
+ -3: 36px,
70
+ -4: 24px,
71
+ );
72
+
73
+ @return (
74
+ height: map.get($size-scale, $density-scale)
75
+ );
76
+ }
77
+
78
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
79
+ // This is used to create token slots.
80
+ @function get-token-slots() {
81
+ @return sass-utils.deep-merge-all(
82
+ get-unthemable-tokens(),
83
+ get-color-tokens(token-utils.$placeholder-color-config),
84
+ get-typography-tokens(token-utils.$placeholder-typography-config),
85
+ get-density-tokens(token-utils.$placeholder-density-config)
86
+ );
87
+ }