@angular/material 20.0.2 → 20.1.0-next.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 (110) hide show
  1. package/_index.scss +0 -1
  2. package/autocomplete/_m2-autocomplete.scss +1 -14
  3. package/badge/_badge-theme.scss +2 -2
  4. package/badge/_m2-badge.scss +13 -34
  5. package/bottom-sheet/_m2-bottom-sheet.scss +2 -15
  6. package/button/_button-theme.scss +2 -2
  7. package/button/_fab-theme.scss +2 -2
  8. package/button/_icon-button-theme.scss +2 -2
  9. package/button/_m2-button.scss +59 -108
  10. package/button/_m2-fab.scss +28 -60
  11. package/button/_m2-icon-button.scss +12 -26
  12. package/button-toggle/_button-toggle-theme.scss +2 -1
  13. package/button-toggle/_m2-button-toggle.scss +24 -49
  14. package/card/_m2-card.scss +9 -18
  15. package/checkbox/_checkbox-theme.scss +4 -3
  16. package/checkbox/_m2-checkbox.scss +31 -59
  17. package/chips/_chips-theme.scss +7 -4
  18. package/chips/_m2-chip.scss +19 -27
  19. package/chips/index.d.ts +56 -4
  20. package/chips/testing/index.d.ts +23 -2
  21. package/core/_m2-app.scss +6 -19
  22. package/core/m2/_theming.scss +55 -9
  23. package/core/option/_m2-optgroup.scss +1 -14
  24. package/core/option/_m2-option.scss +8 -16
  25. package/core/option/_option-theme.scss +3 -3
  26. package/core/ripple/_m2-ripple.scss +0 -13
  27. package/core/selection/pseudo-checkbox/_m2-pseudo-checkbox.scss +10 -20
  28. package/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss +3 -3
  29. package/core/style/_private.scss +6 -9
  30. package/core/style/_sass-utils.scss +0 -29
  31. package/core/tokens/_m2-utils.scss +20 -42
  32. package/{date-range-input-harness.d-CaEyN8dT.d.ts → date-range-input-harness.d-CJ4r85Uf.d.ts} +7 -4
  33. package/datepicker/_datepicker-theme.scss +10 -6
  34. package/datepicker/_m2-datepicker.scss +32 -41
  35. package/datepicker/testing/index.d.ts +3 -3
  36. package/dialog/_m2-dialog.scss +3 -24
  37. package/divider/_m2-divider.scss +1 -14
  38. package/expansion/_m2-expansion.scss +15 -25
  39. package/fesm2022/chips/testing.mjs +26 -1
  40. package/fesm2022/chips/testing.mjs.map +1 -1
  41. package/fesm2022/chips.mjs +131 -13
  42. package/fesm2022/chips.mjs.map +1 -1
  43. package/fesm2022/core.mjs +1 -1
  44. package/fesm2022/core.mjs.map +1 -1
  45. package/fesm2022/{date-range-input-harness-Bp1T4oUe.mjs → date-range-input-harness-DEyfkeOs.mjs} +32 -4
  46. package/fesm2022/date-range-input-harness-DEyfkeOs.mjs.map +1 -0
  47. package/fesm2022/datepicker/testing.mjs +3 -3
  48. package/fesm2022/form-field/testing/control.mjs +26 -1
  49. package/fesm2022/form-field/testing/control.mjs.map +1 -1
  50. package/fesm2022/form-field/testing.mjs +4 -4
  51. package/fesm2022/input/testing.mjs +7 -4
  52. package/fesm2022/input/testing.mjs.map +1 -1
  53. package/fesm2022/{input-harness-oQzj5EsQ.mjs → input-harness-C5Msdc4-.mjs} +6 -3
  54. package/fesm2022/input-harness-C5Msdc4-.mjs.map +1 -0
  55. package/fesm2022/menu.mjs +11 -2
  56. package/fesm2022/menu.mjs.map +1 -1
  57. package/fesm2022/paginator/testing.mjs +2 -3
  58. package/fesm2022/paginator/testing.mjs.map +1 -1
  59. package/fesm2022/select/testing.mjs +8 -5
  60. package/fesm2022/select/testing.mjs.map +1 -1
  61. package/fesm2022/stepper.mjs +2 -2
  62. package/fesm2022/stepper.mjs.map +1 -1
  63. package/form-field/_form-field-theme.scss +2 -2
  64. package/form-field/_m2-form-field.scss +58 -92
  65. package/form-field/testing/control/index.d.ts +8 -5
  66. package/form-field/testing/index.d.ts +5 -5
  67. package/form-field-control-harness.d-BLvFBy6v.d.ts +18 -0
  68. package/grid-list/_m2-grid-list.scss +0 -13
  69. package/icon/_m2-icon.scss +0 -13
  70. package/input/testing/index.d.ts +5 -4
  71. package/{input-harness.d-8fkAAbu2.d.ts → input-harness.d-DVI6ttzl.d.ts} +4 -4
  72. package/list/_list-theme.scss +10 -5
  73. package/list/_m2-list.scss +17 -31
  74. package/menu/_m2-menu.scss +4 -18
  75. package/menu/index.d.ts +2 -0
  76. package/package.json +6 -6
  77. package/paginator/_m2-paginator.scss +6 -18
  78. package/paginator/testing/index.d.ts +2 -3
  79. package/prebuilt-themes/deeppurple-amber.css +1 -1
  80. package/prebuilt-themes/indigo-pink.css +1 -1
  81. package/prebuilt-themes/pink-bluegrey.css +1 -1
  82. package/prebuilt-themes/purple-green.css +1 -1
  83. package/progress-bar/_m2-progress-bar.scss +11 -20
  84. package/progress-bar/_progress-bar-theme.scss +2 -2
  85. package/progress-spinner/_m2-progress-spinner.scss +7 -15
  86. package/progress-spinner/_progress-spinner-theme.scss +2 -2
  87. package/radio/_m2-radio.scss +21 -32
  88. package/radio/_radio-theme.scss +6 -3
  89. package/schematics/ng-add/index.js +2 -2
  90. package/select/_m2-select.scss +12 -35
  91. package/select/testing/index.d.ts +5 -6
  92. package/sidenav/_m2-sidenav.scss +10 -20
  93. package/slide-toggle/_m2-slide-toggle.scss +13 -20
  94. package/slide-toggle/_slide-toggle-theme.scss +3 -2
  95. package/slider/_m2-slider.scss +5 -18
  96. package/snack-bar/_m2-snack-bar.scss +6 -22
  97. package/sort/_m2-sort.scss +1 -34
  98. package/stepper/_m2-stepper.scss +23 -34
  99. package/stepper/_m3-stepper.scss +2 -2
  100. package/stepper/_stepper-theme.scss +2 -2
  101. package/table/_m2-table.scss +4 -17
  102. package/tabs/_m2-tabs.scss +16 -27
  103. package/tabs/_tabs-theme.scss +4 -4
  104. package/timepicker/_m2-timepicker.scss +1 -14
  105. package/toolbar/_m2-toolbar.scss +2 -15
  106. package/tooltip/_m2-tooltip.scss +4 -14
  107. package/tree/_m2-tree.scss +2 -17
  108. package/core/tokens/_m2-tokens.scss +0 -131
  109. package/fesm2022/date-range-input-harness-Bp1T4oUe.mjs.map +0 -1
  110. package/fesm2022/input-harness-oQzj5EsQ.mjs.map +0 -1
@@ -1,16 +1,16 @@
1
1
  @use 'sass:map';
2
- @use 'sass:meta';
3
- @use '../core/tokens/m2-utils';
4
2
  @use '../core/theming/theming';
5
3
  @use '../core/theming/inspection';
6
- @use '../core/style/sass-utils';
4
+ @use '../core/tokens/m2-utils';
5
+ @use '../core/tokens/m3-utils';
7
6
 
8
7
  // Tokens that can't be configured through Angular Material's current theming API,
9
8
  // but may be in a future version of the theming API.
10
- @function get-unthemable-tokens() {
9
+ @function get-unthemable-tokens($theme) {
10
+ $system: m2-utils.get-system($theme);
11
11
  @return (
12
- button-toggle-focus-state-layer-opacity: 0.12,
13
- button-toggle-hover-state-layer-opacity: 0.04,
12
+ button-toggle-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
13
+ button-toggle-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
14
14
  button-toggle-legacy-focus-state-layer-opacity: 1,
15
15
  button-toggle-legacy-height: 36px,
16
16
  button-toggle-legacy-shape: 2px,
@@ -20,48 +20,34 @@
20
20
 
21
21
  // Tokens that can be configured through Angular Material's color theming API.
22
22
  @function get-color-tokens($theme) {
23
- $theme-divider-color: inspection.get-theme-color($theme, foreground, divider);
24
-
25
- // By default the theme usually has an rgba color for the dividers, which can
26
- // stack up with the background of a button toggle. This can cause the border
27
- // of a selected toggle to look different from an unselected one. We use a solid
28
- // color to ensure that the border always stays the same.
29
- $divider-color: if(
30
- meta.type-of($theme-divider-color) == color,
31
- theming.private-rgba-to-hex(
32
- $theme-divider-color, inspection.get-theme-color($theme, background, card)),
33
- $theme-divider-color);
23
+ $system: m2-utils.get-system($theme);
34
24
 
35
25
  @return (
36
- button-toggle-background-color: inspection.get-theme-color($theme, background, card),
26
+ button-toggle-background-color: map.get($system, surface),
37
27
  button-toggle-disabled-selected-state-background-color:
38
- inspection.get-theme-color($theme, background, selected-disabled-button),
28
+ m3-utils.color-with-opacity(map.get($system, on-surface), 12%),
39
29
  button-toggle-disabled-selected-state-text-color:
40
- inspection.get-theme-color($theme, foreground, text),
41
- button-toggle-disabled-state-background-color:
42
- inspection.get-theme-color($theme, background, card),
30
+ m3-utils.color-with-opacity(map.get($system, on-surface), 38%),
31
+ button-toggle-disabled-state-background-color: map.get($system, surface),
43
32
  button-toggle-disabled-state-text-color:
44
- inspection.get-theme-color($theme, foreground, disabled-button),
45
- button-toggle-divider-color: $divider-color,
33
+ m3-utils.color-with-opacity(map.get($system, on-surface), 38%),
34
+ button-toggle-divider-color: map.get($system, outline),
46
35
  button-toggle-legacy-disabled-selected-state-background-color:
47
- inspection.get-theme-color($theme, background, selected-disabled-button),
48
- button-toggle-legacy-disabled-state-background-color:
49
- inspection.get-theme-color($theme, background, disabled-button-toggle),
36
+ m3-utils.color-with-opacity(map.get($system, on-surface), 12%),
37
+ button-toggle-legacy-disabled-state-background-color: map.get($system, surface),
50
38
  button-toggle-legacy-disabled-state-text-color:
51
- inspection.get-theme-color($theme, foreground, disabled-button),
39
+ m3-utils.color-with-opacity(map.get($system, on-surface), 38%),
52
40
  button-toggle-legacy-selected-state-background-color:
53
- inspection.get-theme-color($theme, background, selected-button),
54
- button-toggle-legacy-selected-state-text-color:
55
- inspection.get-theme-color($theme, foreground, secondary-text),
41
+ m3-utils.color-with-opacity(map.get($system, on-surface), 12%),
42
+ button-toggle-legacy-selected-state-text-color: map.get($system, on-surface),
56
43
  button-toggle-legacy-state-layer-color:
57
- inspection.get-theme-color($theme, background, focused-button),
58
- button-toggle-legacy-text-color: inspection.get-theme-color($theme, foreground, hint-text),
44
+ m3-utils.color-with-opacity(map.get($system, on-surface), 12%),
45
+ button-toggle-legacy-text-color: map.get($system, on-surface),
59
46
  button-toggle-selected-state-background-color:
60
- inspection.get-theme-color($theme, background, selected-button),
61
- button-toggle-selected-state-text-color: inspection.get-theme-color($theme, foreground, text),
62
- button-toggle-state-layer-color: sass-utils.safe-color-change(
63
- inspection.get-theme-color($theme, background, focused-button), $alpha: 1),
64
- button-toggle-text-color: inspection.get-theme-color($theme, foreground, text),
47
+ m3-utils.color-with-opacity(map.get($system, on-surface), 12%),
48
+ button-toggle-selected-state-text-color: map.get($system, on-surface),
49
+ button-toggle-state-layer-color: map.get($system, on-surface),
50
+ button-toggle-text-color: map.get($system, on-surface),
65
51
  );
66
52
  }
67
53
 
@@ -103,14 +89,3 @@
103
89
  button-toggle-height: map.get($size-scale, $density-scale)
104
90
  );
105
91
  }
106
-
107
- // Combines the tokens generated by the above functions into a single map with placeholder values.
108
- // This is used to create token slots.
109
- @function get-token-slots() {
110
- @return sass-utils.deep-merge-all(
111
- get-unthemable-tokens(),
112
- get-color-tokens(m2-utils.$placeholder-color-config),
113
- get-typography-tokens(m2-utils.$placeholder-typography-config),
114
- get-density-tokens(m2-utils.$placeholder-density-config)
115
- );
116
- }
@@ -1,7 +1,7 @@
1
- @use '../core/tokens/m2-utils';
2
1
  @use '../core/theming/inspection';
3
- @use '../core/style/sass-utils';
4
2
  @use '../core/style/elevation';
3
+ @use '../core/tokens/m2-utils';
4
+ @use 'sass:map';
5
5
 
6
6
  // Tokens that can't be configured through Angular Material's current theming API,
7
7
  // but may be in a future version of the theming API.
@@ -16,14 +16,16 @@
16
16
 
17
17
  // Tokens that can be configured through Angular Material's color theming API.
18
18
  @function get-color-tokens($theme) {
19
+ $system: m2-utils.get-system($theme);
20
+
19
21
  @return (
20
- card-elevated-container-color: inspection.get-theme-color($theme, background, card),
22
+ card-elevated-container-color: map.get($system, surface),
21
23
  card-elevated-container-elevation: elevation.get-box-shadow(1),
22
- card-outlined-container-color: inspection.get-theme-color($theme, background, card),
24
+ card-outlined-container-color: map.get($system, surface),
23
25
  card-outlined-container-elevation: elevation.get-box-shadow(0),
24
- card-outlined-outline-color: rgba(inspection.get-theme-color($theme, foreground, base), 0.12),
25
- card-subtitle-text-color: inspection.get-theme-color($theme, foreground, secondary-text),
26
- card-filled-container-color: inspection.get-theme-color($theme, background, card),
26
+ card-outlined-outline-color: inspection.get-theme-color($theme, system, outline),
27
+ card-subtitle-text-color: map.get($system, on-surface-variant),
28
+ card-filled-container-color: map.get($system, surface),
27
29
  card-filled-container-elevation: elevation.get-box-shadow(0)
28
30
  );
29
31
  }
@@ -50,14 +52,3 @@
50
52
  @function get-density-tokens($theme) {
51
53
  @return ();
52
54
  }
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(m2-utils.$placeholder-color-config),
60
- get-typography-tokens(m2-utils.$placeholder-typography-config),
61
- get-density-tokens(m2-utils.$placeholder-density-config)
62
- );
63
- }
@@ -15,7 +15,7 @@
15
15
  @include token-utils.create-token-values(map.get(m3-checkbox.get-tokens($theme), base));
16
16
  } @else {
17
17
  @include sass-utils.current-selector-or-root() {
18
- @include token-utils.create-token-values-mixed(m2-checkbox.get-unthemable-tokens());
18
+ @include token-utils.create-token-values-mixed(m2-checkbox.get-unthemable-tokens($theme));
19
19
  }
20
20
  }
21
21
  }
@@ -29,7 +29,8 @@
29
29
  map.get(m3-checkbox.get-tokens($theme, $color-variant), color));
30
30
  } @else {
31
31
  @include sass-utils.current-selector-or-root() {
32
- @include token-utils.create-token-values-mixed(m2-checkbox.get-color-tokens($theme));
32
+ @include token-utils.create-token-values-mixed(
33
+ m2-checkbox.get-color-tokens($theme, secondary));
33
34
  }
34
35
 
35
36
  .mat-mdc-checkbox {
@@ -42,7 +43,7 @@
42
43
 
43
44
  &.mat-warn {
44
45
  @include token-utils.create-token-values-mixed(
45
- m2-checkbox.get-color-tokens($theme, warn,
46
+ m2-checkbox.get-color-tokens($theme, error,
46
47
  $exclude: (checkbox-disabled-label-color, checkbox-label-text-color))
47
48
  );
48
49
  }
@@ -1,68 +1,51 @@
1
1
  @use 'sass:map';
2
2
  @use '../core/tokens/m2-utils';
3
+ @use '../core/tokens/m3-utils';
3
4
  @use '../core/theming/theming';
4
5
  @use '../core/theming/inspection';
5
- @use '../core/style/sass-utils';
6
- @use '../core/m2/theming' as m2-theming;
7
- @use '../core/m2/palette' as m2-palette;
8
6
 
9
7
  // Tokens that can't be configured through Angular Material's current theming API,
10
8
  // but may be in a future version of the theming API.
11
- @function get-unthemable-tokens() {
9
+ @function get-unthemable-tokens($theme) {
10
+ $system: m2-utils.get-system($theme);
11
+
12
12
  @return (
13
13
  checkbox-disabled-selected-checkmark-color: #fff,
14
- checkbox-selected-focus-state-layer-opacity: 0.16,
15
- checkbox-selected-hover-state-layer-opacity: 0.04,
16
- checkbox-selected-pressed-state-layer-opacity: 0.16,
17
- checkbox-unselected-focus-state-layer-opacity: 0.16,
18
- checkbox-unselected-hover-state-layer-opacity: 0.04,
19
- checkbox-unselected-pressed-state-layer-opacity: 0.16,
14
+ checkbox-selected-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
15
+ checkbox-selected-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
16
+ checkbox-selected-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
17
+ checkbox-unselected-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
18
+ checkbox-unselected-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
19
+ checkbox-unselected-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
20
20
  );
21
21
  }
22
22
 
23
23
  // Tokens that can be configured through Angular Material's color theming API.
24
- @function get-color-tokens($theme, $palette-name: accent, $exclude: ()) {
24
+ @function get-color-tokens($theme, $color-variant, $exclude: ()) {
25
+ $system: m2-utils.get-system($theme);
26
+ $system: m3-utils.replace-colors-with-variant($system, secondary, $color-variant);
25
27
  $is-dark: inspection.get-theme-type($theme) == dark;
26
28
  $foreground-base: inspection.get-theme-color($theme, foreground, base);
27
- $palette-default: inspection.get-theme-color($theme, $palette-name, default);
28
- $disabled-color: sass-utils.safe-color-change(
29
- inspection.get-theme-color($theme, foreground, base), $alpha: 0.38);
30
- $palette-selected: inspection.get-theme-color($theme, $palette-name);
31
- $border-color: sass-utils.safe-color-change(
32
- inspection.get-theme-color($theme, foreground, base), $alpha: 0.54);
33
- $active-border-color:
34
- m2-theming.get-color-from-palette(m2-palette.$gray-palette, if($is-dark, 200, 900));
35
- $selected-checkmark-color: null;
36
-
37
- // Ideally we would derive all values directly from the theme, but it causes a lot of regressions
38
- // internally. For now we fall back to the old hardcoded behavior only for internal apps.
39
- @if (m2-utils.$private-is-internal-build) {
40
- $contrast-tone: m2-utils.contrast-tone($palette-selected, $is-dark);
41
- $selected-checkmark-color: if($contrast-tone == 'dark', #000, #fff);
42
- }
43
- @else {
44
- $selected-checkmark-color:
45
- inspection.get-theme-color($theme, $palette-name, default-contrast, 1);
46
- }
29
+ $disabled: m3-utils.color-with-opacity(map.get($system, on-surface), 38%);
47
30
 
48
31
  $tokens: (
49
- checkbox-disabled-label-color: inspection.get-theme-color($theme, foreground, disabled-text),
50
- checkbox-label-text-color: inspection.get-theme-color($theme, foreground, text),
51
- checkbox-disabled-selected-icon-color: $disabled-color,
52
- checkbox-disabled-unselected-icon-color: $disabled-color,
53
- checkbox-selected-checkmark-color: $selected-checkmark-color,
54
- checkbox-selected-focus-icon-color: $palette-selected,
55
- checkbox-selected-hover-icon-color: $palette-selected,
56
- checkbox-selected-icon-color: $palette-selected,
57
- checkbox-selected-pressed-icon-color: $palette-selected,
58
- checkbox-unselected-focus-icon-color: $active-border-color,
59
- checkbox-unselected-hover-icon-color: $active-border-color,
60
- checkbox-unselected-icon-color: $border-color,
61
- checkbox-selected-focus-state-layer-color: $palette-default,
62
- checkbox-selected-hover-state-layer-color: $palette-default,
63
- checkbox-selected-pressed-state-layer-color: $palette-default,
64
- checkbox-unselected-focus-state-layer-color: $foreground-base,
65
- checkbox-unselected-hover-state-layer-color: $foreground-base,
32
+ checkbox-disabled-label-color: $disabled,
33
+ checkbox-label-text-color: map.get($system, on-surface),
34
+ checkbox-disabled-selected-icon-color: $disabled,
35
+ checkbox-disabled-unselected-icon-color: $disabled,
36
+ checkbox-selected-checkmark-color: map.get($system, on-secondary),
37
+ checkbox-selected-focus-icon-color: map.get($system, secondary),
38
+ checkbox-selected-hover-icon-color: map.get($system, secondary),
39
+ checkbox-selected-icon-color: map.get($system, secondary),
40
+ checkbox-selected-pressed-icon-color: map.get($system, secondary),
41
+ checkbox-unselected-focus-icon-color: map.get($system, on-surface),
42
+ checkbox-unselected-hover-icon-color: map.get($system, on-surface),
43
+ checkbox-unselected-icon-color: map.get($system, on-surface-variant),
44
+ checkbox-selected-focus-state-layer-color: map.get($system, secondary),
45
+ checkbox-selected-hover-state-layer-color: map.get($system, secondary),
46
+ checkbox-selected-pressed-state-layer-color: map.get($system, secondary),
47
+ checkbox-unselected-focus-state-layer-color: map.get($system, on-surface),
48
+ checkbox-unselected-hover-state-layer-color: map.get($system, on-surface),
66
49
  checkbox-unselected-pressed-state-layer-color: $foreground-base,
67
50
  );
68
51
 
@@ -98,14 +81,3 @@
98
81
  ), $scale)
99
82
  );
100
83
  }
101
-
102
- // Combines the tokens generated by the above functions into a single map with placeholder values.
103
- // This is used to create token slots.
104
- @function get-token-slots() {
105
- @return sass-utils.deep-merge-all(
106
- get-unthemable-tokens(),
107
- get-color-tokens(m2-utils.$placeholder-color-config),
108
- get-typography-tokens(m2-utils.$placeholder-typography-config),
109
- get-density-tokens(m2-utils.$placeholder-density-config)
110
- );
111
- }
@@ -15,7 +15,7 @@
15
15
  @include token-utils.create-token-values(map.get(m3-chip.get-tokens($theme), base));
16
16
  } @else {
17
17
  .mat-mdc-standard-chip {
18
- @include token-utils.create-token-values-mixed(m2-chip.get-unthemable-tokens());
18
+ @include token-utils.create-token-values-mixed(m2-chip.get-unthemable-tokens($theme));
19
19
  }
20
20
  }
21
21
  }
@@ -34,15 +34,18 @@
34
34
  &.mat-mdc-chip-selected,
35
35
  &.mat-mdc-chip-highlighted {
36
36
  &.mat-primary {
37
- @include token-utils.create-token-values-mixed(m2-chip.get-color-tokens($theme, primary));
37
+ @include token-utils.create-token-values-mixed(
38
+ m2-chip.get-color-tokens($theme, primary));
38
39
  }
39
40
 
40
41
  &.mat-accent {
41
- @include token-utils.create-token-values-mixed(m2-chip.get-color-tokens($theme, accent));
42
+ @include token-utils.create-token-values-mixed(
43
+ m2-chip.get-color-tokens($theme, secondary));
42
44
  }
43
45
 
44
46
  &.mat-warn {
45
- @include token-utils.create-token-values-mixed(m2-chip.get-color-tokens($theme, warn));
47
+ @include token-utils.create-token-values-mixed(
48
+ m2-chip.get-color-tokens($theme, error));
46
49
  }
47
50
  }
48
51
  }
@@ -1,25 +1,27 @@
1
1
  @use 'sass:map';
2
2
  @use 'sass:meta';
3
3
  @use 'sass:color';
4
- @use '../core/tokens/m2-utils';
5
4
  @use '../core/theming/inspection';
6
- @use '../core/style/sass-utils';
7
5
  @use '../core/m2/palette' as m2-palette;
8
6
  @use '../core/theming/theming';
7
+ @use '../core/tokens/m2-utils';
8
+ @use '../core/tokens/m3-utils';
9
9
 
10
10
  // Tokens that can't be configured through Angular Material's current theming API,
11
11
  // but may be in a future version of the theming API.
12
- @function get-unthemable-tokens() {
12
+ @function get-unthemable-tokens($theme) {
13
+ $system: m2-utils.get-system($theme);
14
+
13
15
  @return (
14
16
  chip-container-shape-radius: 16px,
15
17
  chip-disabled-container-opacity: 0.4,
16
18
  chip-disabled-outline-color: transparent,
17
19
  chip-flat-selected-outline-width: 0,
18
20
  chip-focus-outline-color: transparent,
19
- chip-hover-state-layer-opacity: 0.04,
21
+ chip-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
20
22
  chip-outline-color: transparent,
21
23
  chip-outline-width: 0,
22
- chip-selected-hover-state-layer-opacity: 0.04,
24
+ chip-selected-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
23
25
  chip-selected-trailing-action-state-layer-color: transparent,
24
26
  chip-trailing-action-focus-opacity: 1,
25
27
  chip-trailing-action-focus-state-layer-opacity: 0,
@@ -36,20 +38,19 @@
36
38
  }
37
39
 
38
40
  // Tokens that can be configured through Angular Material's color theming API.
39
- @function get-color-tokens($theme, $palette-name: null) {
41
+ @function get-color-tokens($theme, $color-variant: null) {
42
+ $system: m2-utils.get-system($theme);
40
43
  $foreground: null;
41
44
  $background: null;
42
45
  $state-layer-color: inspection.get-theme-color($theme, foreground, base);
43
- $state-layer-opacity: 0.12; // 0.12 is a common value in Material Design for opacity.
44
- $surface: inspection.get-theme-color($theme, background, card);
45
46
 
46
- @if $palette-name == null {
47
+ @if $color-variant == null {
47
48
  $is-dark: inspection.get-theme-type($theme) == dark;
48
49
  $grey-50: map.get(m2-palette.$grey-palette, 50);
49
50
  $grey-900: map.get(m2-palette.$grey-palette, 900);
50
51
  $foreground: if($is-dark, $grey-50, $grey-900);
51
52
 
52
- $surface: inspection.get-theme-color($theme, background, card);
53
+ $surface: map.get($system, surface);
53
54
  $background: if(
54
55
  meta.type-of($state-layer-color) == color and meta.type-of($surface) == color,
55
56
  color.mix($state-layer-color, $surface, 12%),
@@ -57,8 +58,10 @@
57
58
  );
58
59
  }
59
60
  @else {
60
- $background: inspection.get-theme-color($theme, $palette-name);
61
- $foreground: inspection.get-theme-color($theme, $palette-name, default-contrast);
61
+ $system: m3-utils.replace-colors-with-variant($system, primary, $color-variant);
62
+
63
+ $background: map.get($system, primary);
64
+ $foreground: map.get($system, on-primary);
62
65
  }
63
66
  @return (
64
67
  chip-disabled-label-text-color: $foreground,
@@ -67,13 +70,13 @@
67
70
  chip-elevated-selected-container-color: $background,
68
71
  chip-flat-disabled-selected-container-color: $background,
69
72
  chip-focus-state-layer-color: $state-layer-color,
70
- chip-focus-state-layer-opacity: $state-layer-opacity,
73
+ chip-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
71
74
  chip-hover-state-layer-color: $state-layer-color,
72
75
  chip-label-text-color: $foreground,
73
76
  chip-selected-disabled-trailing-icon-color: $foreground,
74
- chip-selected-focus-state-layer-color: $state-layer-color,
75
- chip-selected-focus-state-layer-opacity: $state-layer-opacity,
76
- chip-selected-hover-state-layer-color: $state-layer-color,
77
+ chip-selected-focus-state-layer-color: map.get($system, focus-state-layer-opacity),
78
+ chip-selected-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
79
+ chip-selected-hover-state-layer-color: map.get($system, hover-state-layer-opacity),
77
80
  chip-selected-label-text-color: $foreground,
78
81
  chip-selected-trailing-icon-color: $foreground,
79
82
  chip-with-icon-disabled-icon-color: $foreground,
@@ -110,14 +113,3 @@
110
113
  )
111
114
  );
112
115
  }
113
-
114
- // Combines the tokens generated by the above functions into a single map with placeholder values.
115
- // This is used to create token slots.
116
- @function get-token-slots() {
117
- @return sass-utils.deep-merge-all(
118
- get-unthemable-tokens(),
119
- get-color-tokens(m2-utils.$placeholder-color-config),
120
- get-typography-tokens(m2-utils.$placeholder-typography-config),
121
- get-density-tokens(m2-utils.$placeholder-density-config)
122
- );
123
- }
package/chips/index.d.ts CHANGED
@@ -21,12 +21,15 @@ declare class MatChipAction {
21
21
  _handlePrimaryActionInteraction(): void;
22
22
  remove(): void;
23
23
  disabled: boolean;
24
+ _edit(): void;
24
25
  _isEditing?: boolean;
25
26
  };
26
27
  /** Whether the action is interactive. */
27
28
  isInteractive: boolean;
28
29
  /** Whether this is the primary action in the chip. */
29
30
  _isPrimary: boolean;
31
+ /** Whether this is the leading action in the chip. */
32
+ _isLeading: boolean;
30
33
  /** Whether the action is disabled. */
31
34
  get disabled(): boolean;
32
35
  set disabled(value: boolean);
@@ -71,6 +74,31 @@ declare class MatChipTrailingIcon extends MatChipAction {
71
74
  static ɵfac: i0.ɵɵFactoryDeclaration<MatChipTrailingIcon, never>;
72
75
  static ɵdir: i0.ɵɵDirectiveDeclaration<MatChipTrailingIcon, "mat-chip-trailing-icon, [matChipTrailingIcon]", never, {}, {}, never, never, true, never>;
73
76
  }
77
+ /**
78
+ * Directive to edit the parent chip when the leading action icon is clicked or
79
+ * when the ENTER key is pressed on it.
80
+ *
81
+ * Recommended for use with the Material Design "edit" icon
82
+ * available at https://material.io/icons/#ic_edit.
83
+ *
84
+ * Example:
85
+ *
86
+ * ```
87
+ * <mat-chip>
88
+ * <button matChipEdit aria-label="Edit">
89
+ * <mat-icon>edit</mat-icon>
90
+ * </button>
91
+ * </mat-chip>
92
+ * ```
93
+ */
94
+ declare class MatChipEdit extends MatChipAction {
95
+ _isPrimary: boolean;
96
+ _isLeading: boolean;
97
+ _handleClick(event: MouseEvent): void;
98
+ _handleKeydown(event: KeyboardEvent): void;
99
+ static ɵfac: i0.ɵɵFactoryDeclaration<MatChipEdit, never>;
100
+ static ɵdir: i0.ɵɵDirectiveDeclaration<MatChipEdit, "[matChipEdit]", never, {}, {}, never, never, true, never>;
101
+ }
74
102
  /**
75
103
  * Directive to remove the parent chip when the trailing icon is clicked or
76
104
  * when the ENTER key is pressed on it.
@@ -132,6 +160,8 @@ declare class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoChec
132
160
  protected _allLeadingIcons: QueryList<MatChipAvatar>;
133
161
  /** All trailing icons present in the chip. */
134
162
  protected _allTrailingIcons: QueryList<MatChipTrailingIcon>;
163
+ /** All edit icons present in the chip. */
164
+ protected _allEditIcons: QueryList<MatChipEdit>;
135
165
  /** All remove icons present in the chip. */
136
166
  protected _allRemoveIcons: QueryList<MatChipRemove>;
137
167
  _hasFocus(): boolean;
@@ -183,6 +213,8 @@ declare class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoChec
183
213
  protected basicChipAttrName: string;
184
214
  /** The chip's leading icon. */
185
215
  leadingIcon: MatChipAvatar;
216
+ /** The chip's leading edit icon. */
217
+ editIcon: MatChipEdit;
186
218
  /** The chip's trailing icon. */
187
219
  trailingIcon: MatChipTrailingIcon;
188
220
  /** The chip's trailing remove icon. */
@@ -221,10 +253,12 @@ declare class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoChec
221
253
  _getActions(): MatChipAction[];
222
254
  /** Handles interactions with the primary action of the chip. */
223
255
  _handlePrimaryActionInteraction(): void;
256
+ /** Handles interactions with the edit action of the chip. */
257
+ _edit(event: Event): void;
224
258
  /** Starts the focus monitoring process on the chip. */
225
259
  private _monitorFocus;
226
260
  static ɵfac: i0.ɵɵFactoryDeclaration<MatChip, never>;
227
- static ɵcmp: i0.ɵɵComponentDeclaration<MatChip, "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", ["matChip"], { "role": { "alias": "role"; "required": false; }; "id": { "alias": "id"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaDescription": { "alias": "aria-description"; "required": false; }; "value": { "alias": "value"; "required": false; }; "color": { "alias": "color"; "required": false; }; "removable": { "alias": "removable"; "required": false; }; "highlighted": { "alias": "highlighted"; "required": false; }; "disableRipple": { "alias": "disableRipple"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "removed": "removed"; "destroyed": "destroyed"; }, ["leadingIcon", "trailingIcon", "removeIcon", "_allLeadingIcons", "_allTrailingIcons", "_allRemoveIcons"], ["mat-chip-avatar, [matChipAvatar]", "*", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], true, never>;
261
+ static ɵcmp: i0.ɵɵComponentDeclaration<MatChip, "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", ["matChip"], { "role": { "alias": "role"; "required": false; }; "id": { "alias": "id"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaDescription": { "alias": "aria-description"; "required": false; }; "value": { "alias": "value"; "required": false; }; "color": { "alias": "color"; "required": false; }; "removable": { "alias": "removable"; "required": false; }; "highlighted": { "alias": "highlighted"; "required": false; }; "disableRipple": { "alias": "disableRipple"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "removed": "removed"; "destroyed": "destroyed"; }, ["leadingIcon", "editIcon", "trailingIcon", "removeIcon", "_allLeadingIcons", "_allTrailingIcons", "_allEditIcons", "_allRemoveIcons"], ["mat-chip-avatar, [matChipAvatar]", "*", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], true, never>;
228
262
  static ngAcceptInputType_removable: unknown;
229
263
  static ngAcceptInputType_highlighted: unknown;
230
264
  static ngAcceptInputType_disableRipple: unknown;
@@ -353,13 +387,25 @@ declare class MatChipRow extends MatChip implements AfterViewInit {
353
387
  defaultEditInput?: MatChipEditInput;
354
388
  /** The projected chip edit input. */
355
389
  contentEditInput?: MatChipEditInput;
390
+ /**
391
+ * Set on a mousedown when the chip is already focused via mouse or keyboard.
392
+ *
393
+ * This allows us to ensure chip is already focused when deciding whether to enter the
394
+ * edit mode on a subsequent click. Otherwise, the chip appears focused when handling the
395
+ * first click event.
396
+ */
397
+ private _alreadyFocused;
356
398
  _isEditing: boolean;
357
399
  constructor(...args: unknown[]);
400
+ ngAfterViewInit(): void;
401
+ protected _hasLeadingActionIcon(): boolean;
358
402
  _hasTrailingIcon(): boolean;
359
403
  /** Sends focus to the first gridcell when the user clicks anywhere inside the chip. */
360
404
  _handleFocus(): void;
361
405
  _handleKeydown(event: KeyboardEvent): void;
406
+ _handleClick(event: MouseEvent): void;
362
407
  _handleDoubleclick(event: MouseEvent): void;
408
+ _edit(): void;
363
409
  private _startEditing;
364
410
  private _onEditFinish;
365
411
  _isRippleDisabled(): boolean;
@@ -369,7 +415,7 @@ declare class MatChipRow extends MatChip implements AfterViewInit {
369
415
  */
370
416
  private _getEditInput;
371
417
  static ɵfac: i0.ɵɵFactoryDeclaration<MatChipRow, never>;
372
- static ɵcmp: i0.ɵɵComponentDeclaration<MatChipRow, "mat-chip-row, [mat-chip-row], mat-basic-chip-row, [mat-basic-chip-row]", never, { "editable": { "alias": "editable"; "required": false; }; }, { "edited": "edited"; }, ["contentEditInput"], ["mat-chip-avatar, [matChipAvatar]", "[matChipEditInput]", "*", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], true, never>;
418
+ static ɵcmp: i0.ɵɵComponentDeclaration<MatChipRow, "mat-chip-row, [mat-chip-row], mat-basic-chip-row, [mat-basic-chip-row]", never, { "editable": { "alias": "editable"; "required": false; }; }, { "edited": "edited"; }, ["contentEditInput"], ["[matChipEdit]", "mat-chip-avatar, [matChipAvatar]", "[matChipEditInput]", "*", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], true, never>;
373
419
  }
374
420
 
375
421
  /**
@@ -888,7 +934,7 @@ declare class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy {
888
934
 
889
935
  declare class MatChipsModule {
890
936
  static ɵfac: i0.ɵɵFactoryDeclaration<MatChipsModule, never>;
891
- static ɵmod: i0.ɵɵNgModuleDeclaration<MatChipsModule, never, [typeof MatCommonModule, typeof MatRippleModule, typeof MatChipAction, typeof MatChip, typeof MatChipAvatar, typeof MatChipEditInput, typeof MatChipGrid, typeof MatChipInput, typeof MatChipListbox, typeof MatChipOption, typeof MatChipRemove, typeof MatChipRow, typeof MatChipSet, typeof MatChipTrailingIcon], [typeof MatCommonModule, typeof MatChip, typeof MatChipAvatar, typeof MatChipEditInput, typeof MatChipGrid, typeof MatChipInput, typeof MatChipListbox, typeof MatChipOption, typeof MatChipRemove, typeof MatChipRow, typeof MatChipSet, typeof MatChipTrailingIcon]>;
937
+ static ɵmod: i0.ɵɵNgModuleDeclaration<MatChipsModule, never, [typeof MatCommonModule, typeof MatRippleModule, typeof MatChipAction, typeof MatChip, typeof MatChipAvatar, typeof MatChipEdit, typeof MatChipEditInput, typeof MatChipGrid, typeof MatChipInput, typeof MatChipListbox, typeof MatChipOption, typeof MatChipRemove, typeof MatChipRow, typeof MatChipSet, typeof MatChipTrailingIcon], [typeof MatCommonModule, typeof MatChip, typeof MatChipAvatar, typeof MatChipEdit, typeof MatChipEditInput, typeof MatChipGrid, typeof MatChipInput, typeof MatChipListbox, typeof MatChipOption, typeof MatChipRemove, typeof MatChipRow, typeof MatChipSet, typeof MatChipTrailingIcon]>;
892
938
  static ɵinj: i0.ɵɵInjectorDeclaration<MatChipsModule>;
893
939
  }
894
940
 
@@ -915,6 +961,12 @@ declare const MAT_CHIP_AVATAR: InjectionToken<unknown>;
915
961
  * retention of the class and its directive metadata.
916
962
  */
917
963
  declare const MAT_CHIP_TRAILING_ICON: InjectionToken<unknown>;
964
+ /**
965
+ * Injection token that can be used to reference instances of `MatChipEdit`. It serves as
966
+ * alternative token to the actual `MatChipEdit` class which could cause unnecessary
967
+ * retention of the class and its directive metadata.
968
+ */
969
+ declare const MAT_CHIP_EDIT: InjectionToken<unknown>;
918
970
  /**
919
971
  * Injection token that can be used to reference instances of `MatChipRemove`. It serves as
920
972
  * alternative token to the actual `MatChipRemove` class which could cause unnecessary
@@ -926,5 +978,5 @@ declare const MAT_CHIP_REMOVE: InjectionToken<unknown>;
926
978
  */
927
979
  declare const MAT_CHIP: InjectionToken<unknown>;
928
980
 
929
- export { MAT_CHIP, MAT_CHIPS_DEFAULT_OPTIONS, MAT_CHIP_AVATAR, MAT_CHIP_LISTBOX_CONTROL_VALUE_ACCESSOR, MAT_CHIP_REMOVE, MAT_CHIP_TRAILING_ICON, MatChip, MatChipAvatar, MatChipEditInput, MatChipGrid, MatChipGridChange, MatChipInput, MatChipListbox, MatChipListboxChange, MatChipOption, MatChipRemove, MatChipRow, MatChipSelectionChange, MatChipSet, MatChipTrailingIcon, MatChipsModule };
981
+ export { MAT_CHIP, MAT_CHIPS_DEFAULT_OPTIONS, MAT_CHIP_AVATAR, MAT_CHIP_EDIT, MAT_CHIP_LISTBOX_CONTROL_VALUE_ACCESSOR, MAT_CHIP_REMOVE, MAT_CHIP_TRAILING_ICON, MatChip, MatChipAvatar, MatChipEdit, MatChipEditInput, MatChipGrid, MatChipGridChange, MatChipInput, MatChipListbox, MatChipListboxChange, MatChipOption, MatChipRemove, MatChipRow, MatChipSelectionChange, MatChipSet, MatChipTrailingIcon, MatChipsModule };
930
982
  export type { MatChipEditedEvent, MatChipEvent, MatChipInputEvent, MatChipTextControl, MatChipsDefaultOptions };
@@ -31,6 +31,8 @@ interface ChipRowHarnessFilters extends ChipHarnessFilters {
31
31
  }
32
32
  interface ChipSetHarnessFilters extends BaseHarnessFilters {
33
33
  }
34
+ interface ChipEditHarnessFilters extends BaseHarnessFilters {
35
+ }
34
36
  interface ChipRemoveHarnessFilters extends BaseHarnessFilters {
35
37
  }
36
38
  interface ChipAvatarHarnessFilters extends BaseHarnessFilters {
@@ -50,6 +52,20 @@ declare class MatChipAvatarHarness extends ComponentHarness {
50
52
  static with<T extends MatChipAvatarHarness>(this: ComponentHarnessConstructor<T>, options?: ChipAvatarHarnessFilters): HarnessPredicate<T>;
51
53
  }
52
54
 
55
+ /** Harness for interacting with a standard Material chip edit button in tests. */
56
+ declare class MatChipEditHarness extends ComponentHarness {
57
+ static hostSelector: string;
58
+ /**
59
+ * Gets a `HarnessPredicate` that can be used to search for a chip edit with specific
60
+ * attributes.
61
+ * @param options Options for filtering which input instances are considered a match.
62
+ * @return a `HarnessPredicate` configured with the given options.
63
+ */
64
+ static with<T extends MatChipEditHarness>(this: ComponentHarnessConstructor<T>, options?: ChipEditHarnessFilters): HarnessPredicate<T>;
65
+ /** Clicks the edit button. */
66
+ click(): Promise<void>;
67
+ }
68
+
53
69
  /** Harness for interacting with a standard Material chip remove button in tests. */
54
70
  declare class MatChipRemoveHarness extends ComponentHarness {
55
71
  static hostSelector: string;
@@ -80,6 +96,11 @@ declare class MatChipHarness extends ContentContainerComponentHarness {
80
96
  isDisabled(): Promise<boolean>;
81
97
  /** Delete a chip from the set. */
82
98
  remove(): Promise<void>;
99
+ /**
100
+ * Gets the edit button inside of a chip.
101
+ * @param filter Optionally filters which chips are included.
102
+ */
103
+ geEditButton(filter?: ChipEditHarnessFilters): Promise<MatChipEditHarness>;
83
104
  /**
84
105
  * Gets the remove button inside of a chip.
85
106
  * @param filter Optionally filters which chips are included.
@@ -245,5 +266,5 @@ declare class MatChipSetHarness extends ComponentHarness {
245
266
  getChips(filter?: ChipHarnessFilters): Promise<MatChipHarness[]>;
246
267
  }
247
268
 
248
- export { MatChipAvatarHarness, MatChipEditInputHarness, MatChipGridHarness, MatChipHarness, MatChipInputHarness, MatChipListboxHarness, MatChipOptionHarness, MatChipRemoveHarness, MatChipRowHarness, MatChipSetHarness };
249
- export type { ChipAvatarHarnessFilters, ChipEditInputHarnessFilters, ChipGridHarnessFilters, ChipHarnessFilters, ChipInputHarnessFilters, ChipListboxHarnessFilters, ChipOptionHarnessFilters, ChipRemoveHarnessFilters, ChipRowHarnessFilters, ChipSetHarnessFilters };
269
+ export { MatChipAvatarHarness, MatChipEditHarness, MatChipEditInputHarness, MatChipGridHarness, MatChipHarness, MatChipInputHarness, MatChipListboxHarness, MatChipOptionHarness, MatChipRemoveHarness, MatChipRowHarness, MatChipSetHarness };
270
+ export type { ChipAvatarHarnessFilters, ChipEditHarnessFilters, ChipEditInputHarnessFilters, ChipGridHarnessFilters, ChipHarnessFilters, ChipInputHarnessFilters, ChipListboxHarnessFilters, ChipOptionHarnessFilters, ChipRemoveHarnessFilters, ChipRowHarnessFilters, ChipSetHarnessFilters };