@ng-matero/extensions 17.1.4 → 17.2.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 (69) hide show
  1. package/_index.scss +6 -0
  2. package/alert/_alert-theme.scss +10 -5
  3. package/alert/alert.scss +4 -1
  4. package/colorpicker/_colorpicker-theme.scss +9 -5
  5. package/colorpicker/colorpicker.d.ts +5 -11
  6. package/core/style/_sass-utils.scss +19 -0
  7. package/core/theming/_inspection.scss +38 -0
  8. package/core/theming/_validation.scss +5 -0
  9. package/core/theming/m3/_color-api-back-compat.scss +46 -0
  10. package/core/theming/m3/_config-validation.scss +166 -0
  11. package/core/theming/m3/_custom-tokens.scss +315 -0
  12. package/core/theming/m3/_definition.scss +104 -0
  13. package/core/theming/m3/_format-tokens.scss +5 -0
  14. package/core/theming/m3/_m3-density.scss +50 -0
  15. package/core/theming/m3/_m3-tokens.scss +308 -0
  16. package/core/tokens/_token-utils.scss +140 -0
  17. package/core/tokens/m2/_index.scss +23 -2
  18. package/core/tokens/m2/mtx/_alert.scss +1 -0
  19. package/core/tokens/m2/mtx/_datetimepicker.scss +11 -6
  20. package/core/tokens/m2/mtx/_grid.scss +3 -2
  21. package/core/tokens/m2/mtx/_popover.scss +1 -1
  22. package/core/tokens/m2/mtx/_select.scss +1 -1
  23. package/datetimepicker/_datetimepicker-theme.scss +14 -12
  24. package/datetimepicker/calendar.scss +13 -0
  25. package/datetimepicker/clock.scss +5 -5
  26. package/datetimepicker/datetimepicker-content.scss +9 -2
  27. package/datetimepicker/datetimepicker.d.ts +5 -11
  28. package/datetimepicker/time.scss +10 -8
  29. package/drawer/_drawer-theme.scss +10 -5
  30. package/esm2022/alert/alert.mjs +2 -2
  31. package/esm2022/colorpicker/colorpicker.mjs +10 -16
  32. package/esm2022/datetimepicker/calendar.mjs +3 -3
  33. package/esm2022/datetimepicker/clock.mjs +3 -3
  34. package/esm2022/datetimepicker/datetimepicker.mjs +11 -16
  35. package/esm2022/datetimepicker/time.mjs +3 -3
  36. package/esm2022/grid/grid.mjs +3 -3
  37. package/esm2022/popover/popover.mjs +3 -3
  38. package/esm2022/select/select.mjs +3 -3
  39. package/esm2022/split/split.mjs +7 -14
  40. package/fesm2022/mtxAlert.mjs +2 -2
  41. package/fesm2022/mtxAlert.mjs.map +1 -1
  42. package/fesm2022/mtxColorpicker.mjs +10 -16
  43. package/fesm2022/mtxColorpicker.mjs.map +1 -1
  44. package/fesm2022/mtxDatetimepicker.mjs +16 -21
  45. package/fesm2022/mtxDatetimepicker.mjs.map +1 -1
  46. package/fesm2022/mtxGrid.mjs +2 -2
  47. package/fesm2022/mtxGrid.mjs.map +1 -1
  48. package/fesm2022/mtxPopover.mjs +2 -2
  49. package/fesm2022/mtxPopover.mjs.map +1 -1
  50. package/fesm2022/mtxSelect.mjs +2 -2
  51. package/fesm2022/mtxSelect.mjs.map +1 -1
  52. package/fesm2022/mtxSplit.mjs +6 -13
  53. package/fesm2022/mtxSplit.mjs.map +1 -1
  54. package/grid/_grid-theme.scss +9 -5
  55. package/grid/grid.scss +18 -8
  56. package/loader/_loader-theme.scss +10 -5
  57. package/package.json +13 -13
  58. package/popover/_popover-theme.scss +10 -5
  59. package/popover/popover.scss +1 -1
  60. package/prebuilt-themes/deeppurple-amber.css +1 -1
  61. package/prebuilt-themes/indigo-pink.css +1 -1
  62. package/prebuilt-themes/pink-bluegrey.css +1 -1
  63. package/prebuilt-themes/purple-green.css +1 -1
  64. package/progress/_progress-theme.scss +10 -5
  65. package/select/_select-theme.scss +14 -12
  66. package/select/select.scss +1 -1
  67. package/split/_split-theme.scss +15 -12
  68. package/split/split.d.ts +3 -9
  69. package/tooltip/_tooltip-theme.scss +9 -5
@@ -0,0 +1,308 @@
1
+ @use 'sass:list';
2
+ @use 'sass:map';
3
+ @use 'sass:meta';
4
+ @use '@angular/material' as mat;
5
+ @use '@material/tokens/v0_161' as mdc-tokens;
6
+ @use './m3-density';
7
+ @use './custom-tokens';
8
+ @use './format-tokens';
9
+ @use '../../tokens/m2';
10
+
11
+ /// Picks a submap containing only the given keys out the given map.
12
+ /// @param {Map} $map The map to pick from.
13
+ /// @param {List} $keys The map keys to pick.
14
+ /// @return {Map} A submap containing only the given keys.
15
+ @function _pick($map, $keys) {
16
+ $result: ();
17
+ @each $key in $keys {
18
+ @if map.has-key($map, $key) {
19
+ $result: map.set($result, $key, map.get($map, $key));
20
+ }
21
+ }
22
+ @return $result;
23
+ }
24
+
25
+ /// Filters keys with a null value out of the map.
26
+ /// @param {Map} $map The map to filter.
27
+ /// @return {Map} The given map with all of the null keys filtered out.
28
+ @function _filter-nulls($map) {
29
+ $result: ();
30
+ @each $key, $val in $map {
31
+ @if $val != null {
32
+ $result: map.set($result, $key, $val);
33
+ }
34
+ }
35
+ @return $result;
36
+ }
37
+
38
+ /// Gets the MDC tokens for the given prefix, M3 token values, and supported token slots.
39
+ /// @param {List} $prefix The token prefix for the given tokens.
40
+ /// @param {Map|(Map, Map)} $m3-values A map of M3 token values for the given prefix.
41
+ /// This param may also be a tuple of maps, the first one representing the default M3 token values,
42
+ // and the second containing overrides for different color variants.
43
+ // Single map example:
44
+ // (token1: green, token2: 2px)
45
+ // Tuple example:
46
+ // (
47
+ // (token1: green, token2: 2px),
48
+ // (
49
+ // secondary: (token1: blue),
50
+ // error: (token1: red),
51
+ // )
52
+ // )
53
+ /// @param {Map} $slots A map of token slots, with null value indicating the token is not supported.
54
+ /// @param {String|null} $variant The name of the variant the token values are for.
55
+ /// @return {Map} A map of fully qualified token names to values, for only the supported tokens.
56
+ @function _namespace-tokens($prefix, $m3-values, $slots, $variant: null) {
57
+ $result: ();
58
+ @if $variant == null and meta.type-of($m3-values) == 'list' and list.length($m3-values == 2) {
59
+ $variants: list.nth($m3-values, 2);
60
+ $m3-values: list.nth($m3-values, 1);
61
+ @each $variant, $overrides in $variants {
62
+ $result: map.merge($result, _namespace-tokens($prefix, $overrides, $slots, $variant));
63
+ }
64
+ }
65
+ $used-token-names: map.keys(_filter-nulls(map.get($slots, $prefix)));
66
+ $used-m3-tokens: _pick(_filter-nulls($m3-values), $used-token-names);
67
+ $prefix: if($variant == null, $prefix, list.append($prefix, $variant));
68
+ @return map.merge($result, ($prefix: $used-m3-tokens));
69
+ }
70
+
71
+ /// Generates tokens for the given palette with the given prefix.
72
+ /// @param {Map} $palette The palette to generate tokens for
73
+ /// @param {String} $prefix The key prefix used to name the tokens
74
+ /// @return {Map} A set of tokens for the given palette
75
+ @function _generate-palette-tokens($palette, $prefix) {
76
+ $palette: map.remove($palette, neutral, neutral-variant);
77
+ $result: ();
78
+ @each $hue, $value in $palette {
79
+ $result: map.set($result, '#{$prefix}#{$hue}', $value);
80
+ }
81
+ @return $result;
82
+ }
83
+
84
+ /// Creates a set of `md-ref-palette` tokens from the given palettes. (See
85
+ /// https://github.com/material-components/material-components-web/blob/master/packages/mdc-tokens/v0_161/_md-ref-palette.scss)
86
+ /// @param {Map} $primary The primary palette
87
+ /// @param {Map} $secondary The secondary palette
88
+ /// @param {Map} $tertiary The tertiary palette
89
+ /// @param {Map} $error The error palette
90
+ /// @return {Map} A set of `md-ref-palette` tokens
91
+ @function _generate-ref-palette-tokens($primary, $tertiary, $error) {
92
+ @return mat.private-merge-all(
93
+ (black: #000, white: #fff),
94
+ _generate-palette-tokens($primary, primary),
95
+ _generate-palette-tokens(map.get($primary, secondary), secondary),
96
+ _generate-palette-tokens($tertiary, tertiary),
97
+ _generate-palette-tokens(map.get($primary, neutral), neutral),
98
+ _generate-palette-tokens(map.get($primary, neutral-variant), neutral-variant),
99
+ _generate-palette-tokens($error, error),
100
+ );
101
+ }
102
+
103
+ /// Creates a set of `md-ref-typeface` tokens from the given palettes. (See
104
+ /// https://github.com/material-components/material-components-web/blob/master/packages/mdc-tokens/v0_161/_md-ref-typeface.scss)
105
+ /// @param {List|String} $brand The font-family to use for brand text
106
+ /// @param {List|String} $plain The font-family to use for plain text
107
+ /// @param {String} $bold The font-weight to use for bold text
108
+ /// @param {String} $medium The font-weight to use for medium text
109
+ /// @param {String} $regular The font-weight to use for regular text
110
+ /// @return {Map} A set of `md-ref-typeface` tokens
111
+ @function _generate-ref-typeface-tokens($brand, $plain, $bold, $medium, $regular) {
112
+ @return (
113
+ brand: $brand,
114
+ plain: $plain,
115
+ weight-bold: $bold,
116
+ weight-medium: $medium,
117
+ weight-regular: $regular,
118
+ );
119
+ }
120
+
121
+ /// At the time of writing, some color tokens (e.g. disabled state) are defined as a solid color
122
+ /// token and a separate opacity token. This function applies the opacity to the color and drops the
123
+ /// opacity key from the map. Can be removed once b/213331407 is resolved.
124
+ /// @param {Map} $tokens The map of tokens currently being generated
125
+ /// @param {Map} $all-tokens A map of all tokens, including hardcoded values
126
+ /// @param {List} $pairs Pairs of color token names and their opacities. Should be in the shape of
127
+ /// `((color: 'color-key', opacity: 'opacity-key'))`.
128
+ /// @return {Map} The initial tokens with the combined color values.
129
+ @function _combine-color-tokens($tokens, $opacity-lookup, $pairs) {
130
+ $result: $tokens;
131
+
132
+ @each $pair in $pairs {
133
+ $color-key: map.get($pair, color);
134
+ $opacity-key: map.get($pair, opacity);
135
+ $color: map.get($tokens, $color-key);
136
+ $opacity: map.get($opacity-lookup, $opacity-key);
137
+
138
+ @if meta.type-of($color) == 'color' {
139
+ @if meta.type-of($opacity) != 'number' {
140
+ @error 'Cannot find valid opacity value for color token "#{$color-key}"';
141
+ }
142
+
143
+ $result: map.remove($result, $opacity-key);
144
+ $result: map.set($result, $color-key, rgba($color, $opacity));
145
+ }
146
+ }
147
+
148
+ @return $result;
149
+ }
150
+
151
+ /// Generates a set of namespaced tokens for all components.
152
+ /// @param {Map} $systems The MDC system tokens
153
+ /// @param {Boolean} $include-non-systemized Whether to include non-systemized tokens
154
+ /// @return {Map} A map of namespaced tokens
155
+ @function _generate-tokens($systems, $include-non-systemized: false) {
156
+ $systems: map.merge((
157
+ md-sys-color: (),
158
+ md-sys-elevation: (),
159
+ md-sys-motion: (),
160
+ md-sys-shape: (),
161
+ md-sys-state: (),
162
+ md-sys-typescale: ()
163
+ ), $systems);
164
+ $exclude-hardcoded: not $include-non-systemized;
165
+
166
+ // DO NOT REMOVE
167
+ // This function is used internally.
168
+ $systems: format-tokens.private-format-tokens($systems);
169
+
170
+ // TODO(mmalerba): Refactor this to not depend on the legacy theme when moving out of
171
+ // material-experimental. This is a hack for now because there is no good way to get the token
172
+ // slots in material-experimental without exposing them all from material.
173
+ $fake-theme: mat.define-light-theme((
174
+ color: (
175
+ primary: mat.define-palette(mat.$red-palette),
176
+ accent: mat.define-palette(mat.$red-palette),
177
+ warn: mat.define-palette(mat.$red-palette),
178
+ ),
179
+ typography: mat.define-typography-config(),
180
+ density: 0
181
+ ));
182
+ $token-slots: m2.m2-tokens-from-theme($fake-theme);
183
+
184
+ // TODO(mmalerba): Fill in remaining tokens.
185
+ $result: mat.private-deep-merge-all(
186
+ _namespace-tokens(
187
+ (mtx, alert),
188
+ custom-tokens.alert($systems, $exclude-hardcoded),
189
+ $token-slots
190
+ ),
191
+ _namespace-tokens(
192
+ (mtx, colorpicker),
193
+ custom-tokens.colorpicker($systems, $exclude-hardcoded),
194
+ $token-slots
195
+ ),
196
+ _namespace-tokens(
197
+ (mtx, datetimepicker),
198
+ custom-tokens.datetimepicker($systems, $exclude-hardcoded),
199
+ $token-slots
200
+ ),
201
+ _namespace-tokens(
202
+ (mtx, drawer),
203
+ custom-tokens.drawer($systems, $exclude-hardcoded),
204
+ $token-slots
205
+ ),
206
+ _namespace-tokens(
207
+ (mtx, grid),
208
+ custom-tokens.grid($systems, $exclude-hardcoded),
209
+ $token-slots
210
+ ),
211
+ _namespace-tokens(
212
+ (mtx, loader),
213
+ custom-tokens.loader($systems, $exclude-hardcoded),
214
+ $token-slots
215
+ ),
216
+ _namespace-tokens(
217
+ (mtx, popover),
218
+ custom-tokens.popover($systems, $exclude-hardcoded),
219
+ $token-slots
220
+ ),
221
+ _namespace-tokens(
222
+ (mtx, progress),
223
+ custom-tokens.progress($systems, $exclude-hardcoded),
224
+ $token-slots
225
+ ),
226
+ _namespace-tokens(
227
+ (mtx, select),
228
+ custom-tokens.select($systems, $exclude-hardcoded),
229
+ $token-slots
230
+ ),
231
+ _namespace-tokens(
232
+ (mtx, split),
233
+ custom-tokens.split($systems, $exclude-hardcoded),
234
+ $token-slots
235
+ ),
236
+ );
237
+
238
+ // Strip out tokens that are systemized by our made up density system.
239
+ @each $namespace, $tokens in $result {
240
+ @each $token, $value in $tokens {
241
+ @if m3-density.is-systemized($namespace, $token) {
242
+ $tokens: map.remove($tokens, $token);
243
+ }
244
+ }
245
+ $result: map.set($result, $namespace, $tokens);
246
+ }
247
+ @return $result;
248
+ }
249
+
250
+ /// Generates a set of namespaced color tokens for all components.
251
+ /// @param {String} $type The type of theme system (light or dark)
252
+ /// @param {Map} $primary The primary palette
253
+ /// @param {Map} $tertiary The tertiary palette
254
+ /// @param {Map} $error The error palette
255
+ /// @return {Map} A map of namespaced color tokens
256
+ @function generate-color-tokens($type, $primary, $tertiary, $error) {
257
+ $ref: (
258
+ md-ref-palette: _generate-ref-palette-tokens($primary, $tertiary, $error)
259
+ );
260
+ $sys-color: if($type == dark,
261
+ mdc-tokens.md-sys-color-values-dark($ref),
262
+ mdc-tokens.md-sys-color-values-light($ref));
263
+ @return _generate-tokens(map.merge($ref, (
264
+ md-sys-color: $sys-color,
265
+ // Because the elevation values are always combined with color values to create the box shadow,
266
+ // elevation needs to be part of the color dimension.
267
+ md-sys-elevation: mdc-tokens.md-sys-elevation-values(),
268
+ // Because the state values are sometimes combined with color values to create rgba colors,
269
+ // state needs to be part of color dimension.
270
+ // TODO(mmalerba): If at some point we remove the need for these combined values, we can move
271
+ // state to the base dimension.
272
+ md-sys-state: mdc-tokens.md-sys-state-values(),
273
+ )));
274
+ }
275
+
276
+ /// Generates a set of namespaced color tokens for all components.
277
+ /// @param {String|List} $brand The brand font-family
278
+ /// @param {String|List} $plain The plain fort-family
279
+ /// @param {String|Number} $bold The bold font-weight
280
+ /// @param {String|Number} $medium The medium font-weight
281
+ /// @param {String|Number} $regular The regular font-weight
282
+ /// @return {Map} A map of namespaced typography tokens
283
+ @function generate-typography-tokens($brand, $plain, $bold, $medium, $regular) {
284
+ $ref: (
285
+ md-ref-typeface: _generate-ref-typeface-tokens($brand, $plain, $bold, $medium, $regular)
286
+ );
287
+ @return _generate-tokens((
288
+ md-sys-typescale: mdc-tokens.md-sys-typescale-values($ref)
289
+ ));
290
+ }
291
+
292
+ /// Generates a set of namespaced density tokens for all components.
293
+ /// @param {String|Number} $scale The regular font-weight
294
+ /// @return {Map} A map of namespaced density tokens
295
+ @function generate-density-tokens($scale) {
296
+ @return m3-density.get-tokens-for-scale($scale);
297
+ }
298
+
299
+ /// Generates a set of namespaced tokens not related to color, typography, or density for all
300
+ /// components.
301
+ /// @return {Map} A map of namespaced tokens not related to color, typography, or density
302
+ @function generate-base-tokens() {
303
+ // TODO(mmalerba): Exclude density tokens once implemented.
304
+ @return _generate-tokens((
305
+ md-sys-motion: mdc-tokens.md-sys-motion-values(),
306
+ md-sys-shape: mdc-tokens.md-sys-shape-values(),
307
+ ), $include-non-systemized: true);
308
+ }
@@ -1,11 +1,16 @@
1
+ @use 'sass:list';
1
2
  @use 'sass:map';
2
3
  @use '@material/elevation/elevation-theme' as mdc-elevation-theme;
3
4
  @use '@material/theme/custom-properties' as mdc-custom-properties;
4
5
  @use '@material/theme/theme' as mdc-theme;
5
6
  @use '@material/theme/keys' as mdc-keys;
6
7
  @use '@angular/material' as mat;
8
+ @use '../style/sass-utils';
7
9
  @use '../typography/typography';
8
10
 
11
+ // Indicates whether we're building internally. Used for backwards compatibility.
12
+ $private-is-internal-build: false;
13
+
9
14
  $_placeholder-color-palette: mat.define-palette(mat.$red-palette);
10
15
 
11
16
  // Placeholder color config that can be passed to token getter functions when generating token
@@ -107,6 +112,28 @@ $_component-prefix: null;
107
112
  @return mdc-custom-properties.create-varname('#{$_component-prefix}-#{$token}');
108
113
  }
109
114
 
115
+ // TODO(crisbeto): should be able to replace the usages of `get-token-variable` with this.
116
+ // Returns a `var()` reference to a specific token. Intended for declarations
117
+ // where the token has to be referenced as a part of a larger expression.
118
+ @function get-token-variable-reference($token, $emit-fallback: false) {
119
+ @if $_component-prefix == null or $_tokens == null {
120
+ @error '`get-token-variable-reference` must be used within `use-tokens`';
121
+ }
122
+ @if not map.has-key($_tokens, $token) {
123
+ @error 'Token #{$token} does not exist. Configured tokens are: #{map.keys($_tokens)}';
124
+ }
125
+
126
+ $var: get-token-variable($token);
127
+ $fallback: if($emit-fallback, map.get($_tokens, $token), null);
128
+
129
+ @if ($fallback != null) {
130
+ @return var($var, $fallback);
131
+ }
132
+ @else {
133
+ @return var($var);
134
+ }
135
+ }
136
+
110
137
  @mixin create-token-values($prefix, $tokens) {
111
138
  @include _configure-token-prefix($prefix...) {
112
139
  @include mdc-keys.declare-custom-properties($tokens, $_component-prefix);
@@ -124,3 +151,116 @@ $_component-prefix: null;
124
151
  $shadow-color-token: null,
125
152
  ));
126
153
  }
154
+
155
+ /// Checks whether a list starts wih a given prefix
156
+ /// @param {List} $list The list value to check the prefix of.
157
+ /// @param {List} $prefix The prefix to check.
158
+ /// @return {Boolean} Whether the list starts with the prefix.
159
+ @function _is-prefix($list, $prefix) {
160
+ @for $i from 1 through list.length($prefix) {
161
+ @if list.nth($list, $i) != list.nth($prefix, $i) {
162
+ @return false;
163
+ }
164
+ }
165
+ @return true;
166
+ }
167
+
168
+ /// Gets the supported color variants in the given token set for the given prefix.
169
+ /// @param {Map} $tokens The full token map.
170
+ /// @param {List} $prefix The component prefix to get color variants for.
171
+ /// @return {List} The supported color variants.
172
+ @function _supported-color-variants($tokens, $prefix) {
173
+ $result: ();
174
+ @each $namespace in map.keys($tokens) {
175
+ @if list.length($prefix) == list.length($namespace) - 1 and _is-prefix($namespace, $prefix) {
176
+ $result: list.append($result, list.nth($namespace, list.length($namespace)), comma);
177
+ }
178
+ }
179
+ @return $result;
180
+ }
181
+
182
+ /// Gets the token values for the given components prefix with the given options.
183
+ /// @param {Map} $tokens The full token map.
184
+ /// @param {List} $prefix The component prefix to get the token values for.
185
+ /// @param {ArgList} Any additional options
186
+ /// Currently the additional supported options are:
187
+ // - $color-variant - The color variant to use for the component
188
+ // - $emit-overrides-only - Whether to emit *only* the overrides for the
189
+ // specific color variant, or all color styles. Defaults to false.
190
+ /// @throws If given options are invalid
191
+ /// @return {Map} The token values for the requested component.
192
+ @function get-tokens-for($tokens, $prefix, $options...) {
193
+ $options: sass-utils.validate-keyword-args($options, (color-variant, emit-overrides-only));
194
+ @if $tokens == () {
195
+ @return ();
196
+ }
197
+ $values: map.get($tokens, $prefix);
198
+ $color-variant: map.get($options, color-variant);
199
+ $emit-overrides-only: map.get($options, emit-overrides-only);
200
+ @if $color-variant == null {
201
+ @return $values;
202
+ }
203
+ $overrides: map.get($tokens, list.append($prefix, $color-variant));
204
+ @if $overrides == null {
205
+ @error #{'Invalid color variant: '}#{$color-variant}#{'. Supported color variants are: '}#{
206
+ _supported-color-variants($tokens, $prefix)
207
+ }#{'.'};
208
+ }
209
+ @return if($emit-overrides-only, $overrides, map.merge($values, $overrides));
210
+ }
211
+
212
+ /// Emits new token values for the given tokens.
213
+ /// Verifies that the tokens passed in are valid tokens.
214
+ /// New token values are emitted under the current selector or root.
215
+ @mixin batch-create-token-values(
216
+ $tokens: (),
217
+ $mat-prefix: '',
218
+ $mdc-prefix: '',
219
+ $mat-tokens: (),
220
+ $mdc-tokens: ()
221
+ ) {
222
+ $custom-mat-tokens: ();
223
+ $custom-mdc-tokens: ();
224
+
225
+ $mat-token-names: map.keys($mat-tokens);
226
+ $mdc-token-names: map.keys($mdc-tokens);
227
+ $valid-token-names: _get-valid-token-names($mat-tokens, $mdc-tokens);
228
+
229
+ @each $name, $value in $tokens {
230
+ $is-mat-token: list.index($mat-token-names, $name) != null;
231
+ $is-mdc-token: list.index($mdc-token-names, $name) != null;
232
+
233
+ @if ($is-mat-token) {
234
+ $custom-mat-tokens: map.set($custom-mat-tokens, $name, $value);
235
+ }
236
+
237
+ @if ($is-mdc-token) {
238
+ $custom-mdc-tokens: map.set($custom-mdc-tokens, $name, $value);
239
+ }
240
+
241
+ @if (list.index($valid-token-names, $name) == null) {
242
+ @error (
243
+ 'Invalid token: "' + $name + '"'
244
+ 'Valid tokens include: ' $valid-token-names
245
+ );
246
+ }
247
+ }
248
+
249
+ @include sass-utils.current-selector-or-root() {
250
+ @include create-token-values($mat-prefix, $custom-mat-tokens);
251
+ @include create-token-values($mdc-prefix, $custom-mdc-tokens);
252
+ }
253
+ }
254
+
255
+ /// Returns the union of token names whose values are not null.
256
+ @function _get-valid-token-names($mat-tokens, $mdc-tokens) {
257
+ $mat-and-mdc-tokens: map.merge($mat-tokens, $mdc-tokens);
258
+
259
+ @each $name, $value in $mat-and-mdc-tokens {
260
+ @if ($value == null) {
261
+ $mat-and-mdc-tokens: map.remove($mat-and-mdc-tokens, $name);
262
+ }
263
+ }
264
+
265
+ @return map.keys($mat-and-mdc-tokens);
266
+ }
@@ -1,6 +1,17 @@
1
1
  @use 'sass:map';
2
2
  @use 'sass:meta';
3
+ @use '@angular/material' as mat;
3
4
  @use '../../style/sass-utils';
5
+ @use './mtx/alert' as tokens-mtx-alert;
6
+ @use './mtx/colorpicker' as tokens-mtx-colorpicker;
7
+ @use './mtx/datetimepicker' as tokens-mtx-datetimepicker;
8
+ @use './mtx/drawer' as tokens-mtx-drawer;
9
+ @use './mtx/grid' as tokens-mtx-grid;
10
+ @use './mtx/loader' as tokens-mtx-loader;
11
+ @use './mtx/popover' as tokens-mtx-popover;
12
+ @use './mtx/progress' as tokens-mtx-progress;
13
+ @use './mtx/select' as tokens-mtx-select;
14
+ @use './mtx/split' as tokens-mtx-split;
4
15
 
5
16
  /// Gets the tokens for the given theme, m2 tokens module, and theming system.
6
17
  /// @param {Map} $theme The Angular Material theme object to generate token values from.
@@ -14,11 +25,11 @@
14
25
  @return meta.call(
15
26
  meta.get-function(get-#{$system}-tokens, $module: $module));
16
27
  }
17
- @if not map.get($theme, $system) {
28
+ @if not mat.theme-has($theme, $system) {
18
29
  @return ();
19
30
  }
20
31
  @return meta.call(
21
- meta.get-function(get-#{$system}-tokens, $module: $module), map.get($theme, $system));
32
+ meta.get-function(get-#{$system}-tokens, $module: $module), $theme);
22
33
  }
23
34
 
24
35
  /// Gets the fully qualified tokens map for the given theme and m2 tokens module.
@@ -45,5 +56,15 @@
45
56
  /// )
46
57
  @function m2-tokens-from-theme($theme) {
47
58
  @return sass-utils.deep-merge-all(
59
+ _get-tokens-for-module($theme, tokens-mtx-alert),
60
+ _get-tokens-for-module($theme, tokens-mtx-colorpicker),
61
+ _get-tokens-for-module($theme, tokens-mtx-datetimepicker),
62
+ _get-tokens-for-module($theme, tokens-mtx-drawer),
63
+ _get-tokens-for-module($theme, tokens-mtx-grid),
64
+ _get-tokens-for-module($theme, tokens-mtx-loader),
65
+ _get-tokens-for-module($theme, tokens-mtx-popover),
66
+ _get-tokens-for-module($theme, tokens-mtx-progress),
67
+ _get-tokens-for-module($theme, tokens-mtx-select),
68
+ _get-tokens-for-module($theme, tokens-mtx-split),
48
69
  );
49
70
  }
@@ -19,6 +19,7 @@ $prefix: (mtx, alert);
19
19
  $is-dark: mat.get-theme-type($theme) == dark;
20
20
 
21
21
  @return (
22
+ outline-color: transparent,
22
23
  background-color: mat.get-theme-color($theme, background, dialog),
23
24
  text-color: mat.get-theme-color($theme, foreground, text),
24
25
  info-background-color: mat.get-color-from-palette(mat.$blue-palette, if($is-dark, 900, 500)),
@@ -1,6 +1,7 @@
1
1
  @use 'sass:color';
2
2
  @use 'sass:map';
3
3
  @use 'sass:meta';
4
+ @use '@material/elevation/elevation-theme' as mdc-elevation;
4
5
  @use '@angular/material' as mat;
5
6
  @use '../../token-utils';
6
7
  @use '../../../style/sass-utils';
@@ -39,7 +40,7 @@ $_today-fade-amount: .2;
39
40
 
40
41
  time-input-active-state-text-color: $palette-color,
41
42
  time-input-active-state-background-color: sass-utils.safe-color-change($palette-color, $alpha: .2),
42
- time-input-focus-state-border-color: $palette-color,
43
+ time-input-focus-state-outline-color: $palette-color,
43
44
  time-input-focus-state-placeholder-text-color: sass-utils.safe-color-change($palette-color, $alpha: .6),
44
45
 
45
46
  time-ampm-selected-state-background-color: sass-utils.safe-color-change($palette-color, $alpha: .2),
@@ -56,7 +57,11 @@ $_today-fade-amount: .2;
56
57
  // but may be in a future version of the theming API.
57
58
  @function get-unthemable-tokens() {
58
59
  @return (
60
+ container-elevation-shadow: mdc-elevation.elevation-box-shadow(4),
61
+ container-touch-elevation-shadow: mdc-elevation.elevation-box-shadow(24),
59
62
  container-shape: 4px,
63
+ container-touch-shape: 4px,
64
+ selector-container-shape: 4px,
60
65
  );
61
66
  }
62
67
 
@@ -81,7 +86,7 @@ $_today-fade-amount: .2;
81
86
  // calendar-period-button-icon-color: $inactive-icon-color,
82
87
  // calendar-navigation-button-icon-color: $inactive-icon-color,
83
88
  calendar-header-text-color: white,
84
- calendar-header-divider-color: $divider-color,
89
+ calendar-header-divider-color: transparent,
85
90
  calendar-table-header-text-color: $secondary-text-color,
86
91
 
87
92
  // Note: though it's not text, the border is a hint about the fact
@@ -93,8 +98,8 @@ $_today-fade-amount: .2;
93
98
  calendar-date-disabled-state-text-color: $disabled-text-color,
94
99
  // calendar-date-preview-state-outline-color: $preview-outline-color,
95
100
 
96
- calendar-container-background-color: mat.get-theme-color($theme, background, card),
97
- calendar-container-text-color: $text-color,
101
+ container-background-color: mat.get-theme-color($theme, background, card),
102
+ container-text-color: $text-color,
98
103
 
99
104
  clock-dial-background-color: $divider-color,
100
105
  clock-cell-text-color: $text-color,
@@ -104,9 +109,9 @@ $_today-fade-amount: .2;
104
109
  time-input-text-color: $text-color,
105
110
  time-input-background-color: $divider-color,
106
111
  time-input-focus-state-background-color: mat.get-theme-color($theme, background, background),
107
- time-input-warn-state-border-color: mat.get-theme-color($theme, warn),
112
+ time-input-warn-state-outline-color: mat.get-theme-color($theme, warn),
108
113
  time-ampm-text-color: sass-utils.safe-color-change($text-color, $alpha: .75),
109
- time-ampm-border-color: $hint-text-color,
114
+ time-ampm-outline-color: $hint-text-color,
110
115
  time-ampm-selected-state-text-color: $text-color,
111
116
  ));
112
117
  }
@@ -27,8 +27,9 @@ $prefix: (mtx, grid);
27
27
  column-menu-divider-color: $divider-color,
28
28
  table-footer-background-color: mat.get-theme-color($theme, background, app-bar),
29
29
  table-row-striped-background-color: if($is-dark, #3a3a3a, #f5f5f5),
30
- table-row-hover-background-color: if($is-dark, #2a2a2a, #e5e5e5),
31
- table-row-selected-background-color: if($is-dark, #2a2a2a, #e5e5e5),
30
+ table-row-hover-background-color: if($is-dark, #2a2a2a, #eee),
31
+ table-row-selected-background-color: if($is-dark, #2a2a2a, #eee),
32
+ table-row-selected-hover-background-color: if($is-dark, #1a1a1a, #e0e0e0),
32
33
  table-cell-selected-outline-color: mat.get-theme-color($theme, accent),
33
34
  resizable-handle-active-background-color: mat.get-theme-color($theme, primary),
34
35
  resizable-handle-hover-background-color: mat.get-theme-color($theme, primary),
@@ -17,9 +17,9 @@ $prefix: (mtx, popover);
17
17
  // Tokens that can be configured through Angular Material's color theming API.
18
18
  @function get-color-tokens($theme) {
19
19
  @return (
20
+ outline-color: mat.get-theme-color($theme, foreground, divider),
20
21
  background-color: mat.get-theme-color($theme, background, card),
21
22
  text-color: mat.get-theme-color($theme, foreground, text),
22
- arrow-outline-color: mat.get-theme-color($theme, foreground, divider),
23
23
  );
24
24
  }
25
25
 
@@ -40,7 +40,7 @@ $prefix: (mtx, select);
40
40
  disabled-text-color: $hint-text-color,
41
41
 
42
42
  multiple-value-background-color: mat.get-theme-color($theme, background, unselected-chip),
43
- multiple-value-border-color: $divider-color,
43
+ multiple-value-outline-color: $divider-color,
44
44
  multiple-value-icon-hover-background-color: $divider-color,
45
45
 
46
46
  clear-icon-color: $secondary-text-color,