@ng-matero/extensions 20.2.1 → 20.3.1

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 (51) hide show
  1. package/_index.scss +2 -2
  2. package/colorpicker/index.d.ts +4 -3
  3. package/core/m2/_typography.scss +216 -0
  4. package/core/theming/_definition.scss +22 -13
  5. package/core/theming/_m2-inspection.scss +235 -0
  6. package/core/theming/prebuilt/azure-blue.scss +2 -2
  7. package/core/theming/prebuilt/cyan-orange.scss +2 -2
  8. package/core/theming/prebuilt/magenta-violet.scss +2 -2
  9. package/core/theming/prebuilt/rose-red.scss +2 -2
  10. package/core/tokens/_m3-utils.scss +2 -14
  11. package/core/tokens/{_m3-system.scss → _system.scss} +74 -0
  12. package/core/tokens/m2/_index.scss +6 -0
  13. package/core/tokens/m2/_md-sys-color.scss +114 -0
  14. package/core/tokens/m2/_md-sys-elevation.scss +10 -0
  15. package/core/tokens/m2/_md-sys-motion.scss +30 -0
  16. package/core/tokens/m2/_md-sys-shape.scss +16 -0
  17. package/core/tokens/m2/_md-sys-state.scss +8 -0
  18. package/core/tokens/m2/_md-sys-typescale.scss +68 -0
  19. package/core/tokens/m3/_md-sys-color.scss +2 -14
  20. package/core/tokens/m3/_md-sys-typescale.scss +1 -1
  21. package/core/tokens/m3/_theme.scss +14 -26
  22. package/core/typography/_versioning.scss +91 -0
  23. package/datetimepicker/index.d.ts +5 -2
  24. package/fesm2022/mtxAlert.mjs +7 -7
  25. package/fesm2022/mtxButton.mjs +7 -7
  26. package/fesm2022/mtxCheckboxGroup.mjs +7 -7
  27. package/fesm2022/mtxColorpicker.mjs +29 -22
  28. package/fesm2022/mtxColorpicker.mjs.map +1 -1
  29. package/fesm2022/mtxColumnResize.mjs +43 -43
  30. package/fesm2022/mtxCore.mjs +21 -21
  31. package/fesm2022/mtxDatetimepicker.mjs +74 -67
  32. package/fesm2022/mtxDatetimepicker.mjs.map +1 -1
  33. package/fesm2022/mtxDialog.mjs +10 -10
  34. package/fesm2022/mtxDrawer.mjs +10 -10
  35. package/fesm2022/mtxGrid.mjs +69 -69
  36. package/fesm2022/mtxLoader.mjs +7 -7
  37. package/fesm2022/mtxPhotoviewer.mjs +7 -7
  38. package/fesm2022/mtxPopover.mjs +19 -19
  39. package/fesm2022/mtxProgress.mjs +7 -7
  40. package/fesm2022/mtxSelect.mjs +52 -52
  41. package/fesm2022/mtxSplit.mjs +10 -10
  42. package/fesm2022/mtxTooltip.mjs +10 -10
  43. package/package.json +19 -19
  44. package/prebuilt-themes/azure-blue.css +1 -1
  45. package/prebuilt-themes/cyan-orange.css +1 -1
  46. package/prebuilt-themes/deeppurple-amber.css +1 -1
  47. package/prebuilt-themes/indigo-pink.css +1 -1
  48. package/prebuilt-themes/magenta-violet.css +1 -1
  49. package/prebuilt-themes/pink-bluegrey.css +1 -1
  50. package/prebuilt-themes/purple-green.css +1 -1
  51. package/prebuilt-themes/rose-red.css +1 -1
package/_index.scss CHANGED
@@ -27,9 +27,9 @@ tooltip-color, tooltip-typography, tooltip-density, tooltip-base, tooltip-overri
27
27
  define-density;
28
28
  @forward './core/theming/color-api-backwards-compatibility' show color-variants-backwards-compatibility;
29
29
 
30
- @forward './core/tokens/m3-system' show system-level-colors,
30
+ @forward './core/tokens/system' show system-level-colors,
31
31
  system-level-typography, system-level-elevation, system-level-shape,
32
- system-level-motion, system-level-state, theme, theme-overrides;
32
+ system-level-motion, system-level-state, theme, theme-overrides, m2-theme;
33
33
 
34
34
  @forward './core/theming/all-theme' show all-component-themes, all-component-bases;
35
35
  @forward './core/color/all-color' show all-component-colors;
@@ -45,7 +45,7 @@ declare class MtxColorpickerInput implements ControlValueAccessor, AfterViewInit
45
45
  set value(value: string | null);
46
46
  private _value;
47
47
  /** The input and output color format. */
48
- format: ColorFormat;
48
+ format?: ColorFormat | null;
49
49
  /** Emits when a `change` event is fired on this `<input>`. */
50
50
  readonly colorChange: EventEmitter<MtxColorPickerInputEvent>;
51
51
  /** Emits when an `input` event is fired on this `<input>`. */
@@ -178,8 +178,8 @@ declare class MtxColorpicker implements OnChanges, OnDestroy {
178
178
  private _color;
179
179
  /** The input and output color format. */
180
180
  get format(): ColorFormat;
181
- set format(value: ColorFormat);
182
- _format: ColorFormat;
181
+ set format(value: ColorFormat | null | undefined);
182
+ private _format?;
183
183
  /** The currently selected color. */
184
184
  get selected(): string;
185
185
  set selected(value: string);
@@ -201,6 +201,7 @@ declare class MtxColorpicker implements OnChanges, OnDestroy {
201
201
  private _injector;
202
202
  ngOnChanges(): void;
203
203
  ngOnDestroy(): void;
204
+ getColorFormat(): "hex" | "rgb" | "hsl" | "hsv";
204
205
  /** Selects the given color. */
205
206
  select(nextVal: string): void;
206
207
  /**
@@ -156,6 +156,192 @@ $_mdc-levels: (
156
156
  );
157
157
  }
158
158
 
159
+ /// Defines a collection of typography levels to configure typography for an application.
160
+ /// Any level not specified defaults to the values defined in the Material Design specification:
161
+ /// https://material.io/guidelines/style/typography.html.
162
+ ///
163
+ /// Note that the Material Design specification does not describe explicit letter-spacing values.
164
+ /// The values here come from reverse engineering the Material Design examples.
165
+ /// @param {String} $font-family Default font-family for levels that don't specify font-family.
166
+ /// @param {Map} $display-4 Configuration for the "display-4" typographic level.
167
+ /// @param {Map} $display-3 Configuration for the "display-3" typographic level.
168
+ /// @param {Map} $display-2 Configuration for the "display-2" typographic level.
169
+ /// @param {Map} $display-1 Configuration for the "display-1" typographic level.
170
+ /// @param {Map} $headline Configuration for the "headline" typographic level.
171
+ /// @param {Map} $title Configuration for the "title" typographic level.
172
+ /// @param {Map} $subheading-2 Configuration for the "subheading-2" typographic level.
173
+ /// @param {Map} $subheading-1 Configuration for the "subheading-1" typographic level.
174
+ /// @param {Map} $body-2 Configuration for the "body-2" typographic level.
175
+ /// @param {Map} $body-1 Configuration for the "body-1" typographic level.
176
+ /// @param {Map} $caption Configuration for the "caption" typographic level.
177
+ /// @param {Map} $button Configuration for the "button" typographic level.
178
+ /// @param {Map} $input Configuration for the "input" typographic level.
179
+ /// @returns {Map} A typography config for the application.
180
+ ///
181
+ /// @deprecated Use `mat.m2-define-typography-config` instead. See https://v17.material.angular.dev/guide/mdc-migration for information about migrating.
182
+ /// @breaking-change 17.0.0
183
+ @function define-legacy-typography-config(
184
+ $font-family: 'Roboto, "Helvetica Neue", sans-serif',
185
+ $display-4: define-typography-level(112px, 112px, 300, $letter-spacing: -0.05em),
186
+ $display-3: define-typography-level(56px, 56px, 400, $letter-spacing: -0.02em),
187
+ $display-2: define-typography-level(45px, 48px, 400, $letter-spacing: -0.005em),
188
+ $display-1: define-typography-level(34px, 40px, 400),
189
+ $headline: define-typography-level(24px, 32px, 400),
190
+ $title: define-typography-level(20px, 32px, 500),
191
+ $subheading-2: define-typography-level(16px, 28px, 400),
192
+ $subheading-1: define-typography-level(15px, 24px, 400),
193
+ $body-2: define-typography-level(14px, 24px, 500),
194
+ $body-1: define-typography-level(14px, 20px, 400),
195
+ $caption: define-typography-level(12px, 20px, 400),
196
+ $button: define-typography-level(14px, 14px, 500),
197
+ // Line-height must be unit-less fraction of the font-size.
198
+ $input: define-typography-level(inherit, 1.125, 400)
199
+ ) {
200
+
201
+ // Declare an initial map with all of the levels.
202
+ $config: (
203
+ display-4: $display-4,
204
+ display-3: $display-3,
205
+ display-2: $display-2,
206
+ display-1: $display-1,
207
+ headline: $headline,
208
+ title: $title,
209
+ subheading-2: $subheading-2,
210
+ subheading-1: $subheading-1,
211
+ body-2: $body-2,
212
+ body-1: $body-1,
213
+ caption: $caption,
214
+ button: $button,
215
+ input: $input,
216
+ );
217
+
218
+ // Loop through the levels and set the `font-family` of the ones that don't have one to the base.
219
+ // Note that Sass can't modify maps in place, which means that we need to merge and re-assign.
220
+ @each $key, $level in $config {
221
+ @if map.get($level, font-family) == null {
222
+ $new-level: map.merge($level, (font-family: $font-family));
223
+ $config: map.merge($config, ($key: $new-level));
224
+ }
225
+ }
226
+
227
+ // Add the base font family to the config.
228
+ @return map.merge($config, (font-family: $font-family));
229
+ }
230
+
231
+ /// Generates an Angular Material typography config based on values from the official Material
232
+ /// Design spec implementation (MDC Web). All arguments are optional, but may be passed to override
233
+ /// the default values. The `mat-typography-level` function can be used to generate a custom
234
+ /// typography level map which can be passed to this function to override one of the default levels.
235
+ /// All default typography sizing generated by this function is in `px` units.
236
+ ///
237
+ /// @param {String} $font-family The font family to use for levels where it is not explicitly
238
+ /// specified.
239
+ /// @param {Map} $headline-1 The font settings for the headline-1 font level.
240
+ /// @param {Map} $headline-2 The font settings for the headline-2 font level.
241
+ /// @param {Map} $headline-3 The font settings for the headline-3 font level.
242
+ /// @param {Map} $headline-4 The font settings for the headline-4 font level.
243
+ /// @param {Map} $headline-5 The font settings for the headline-5 font level.
244
+ /// @param {Map} $headline-6 The font settings for the headline-6 font level.
245
+ /// @param {Map} $subtitle-1 The font settings for the subtitle-1 font level.
246
+ /// @param {Map} $subtitle-2 The font settings for the subtitle-2 font level.
247
+ /// @param {Map} $body-1 The font settings for the body-1 font level.
248
+ /// @param {Map} $body-2 The font settings for the body-2 font level.
249
+ /// @param {Map} $caption The font settings for the caption font level.
250
+ /// @param {Map} $button The font settings for the button font level.
251
+ /// @param {Map} $overline The font settings for the overline font level.
252
+ /// @return {Map} A map containing font settings for each of the levels in the Material Design spec.
253
+ @function define-typography-config(
254
+ // TODO(mmalerba): rename this function to define-typography-config,
255
+ // and create a predefined px based config for people that need it.
256
+ $font-family: $_default-font-family,
257
+ $headline-1: null,
258
+ $headline-2: null,
259
+ $headline-3: null,
260
+ $headline-4: null,
261
+ $headline-5: null,
262
+ $headline-6: null,
263
+ $subtitle-1: null,
264
+ $subtitle-2: null,
265
+ $body-1: null,
266
+ $body-2: null,
267
+ $caption: null,
268
+ $button: null,
269
+ $overline: null,
270
+ ) {
271
+ @return _apply-font-family($font-family, (
272
+ headline-1: $headline-1 or _rem-to-px(typography-config-level-from-mdc(headline1)),
273
+ headline-2: $headline-2 or _rem-to-px(typography-config-level-from-mdc(headline2)),
274
+ headline-3: $headline-3 or _rem-to-px(typography-config-level-from-mdc(headline3)),
275
+ headline-4: $headline-4 or _rem-to-px(typography-config-level-from-mdc(headline4)),
276
+ headline-5: $headline-5 or _rem-to-px(typography-config-level-from-mdc(headline5)),
277
+ headline-6: $headline-6 or _rem-to-px(typography-config-level-from-mdc(headline6)),
278
+ subtitle-1: $subtitle-1 or _rem-to-px(typography-config-level-from-mdc(subtitle1)),
279
+ subtitle-2: $subtitle-2 or _rem-to-px(typography-config-level-from-mdc(subtitle2)),
280
+ body-1: $body-1 or _rem-to-px(typography-config-level-from-mdc(body1)),
281
+ body-2: $body-2 or _rem-to-px(typography-config-level-from-mdc(body2)),
282
+ caption: $caption or _rem-to-px(typography-config-level-from-mdc(caption)),
283
+ button: $button or _rem-to-px(typography-config-level-from-mdc(button)),
284
+ overline: $overline or _rem-to-px(typography-config-level-from-mdc(overline)),
285
+ ));
286
+ }
287
+
288
+ /// Generates an Angular Material typography config based on values from the official Material
289
+ /// Design spec implementation (MDC Web). All arguments are optional, but may be passed to override
290
+ /// the default values. The `mat-typography-level` function can be used to generate a custom
291
+ /// typography level map which can be passed to this function to override one of the default levels.
292
+ /// All default typography sizing generated by this function is in `rem` units.
293
+ ///
294
+ /// @param {String} $font-family The font family to use for levels where it is not explicitly
295
+ /// specified.
296
+ /// @param {Map} $headline-1 The font settings for the headline-1 font level.
297
+ /// @param {Map} $headline-2 The font settings for the headline-2 font level.
298
+ /// @param {Map} $headline-3 The font settings for the headline-3 font level.
299
+ /// @param {Map} $headline-4 The font settings for the headline-4 font level.
300
+ /// @param {Map} $headline-5 The font settings for the headline-5 font level.
301
+ /// @param {Map} $headline-6 The font settings for the headline-6 font level.
302
+ /// @param {Map} $subtitle-1 The font settings for the subtitle-1 font level.
303
+ /// @param {Map} $subtitle-2 The font settings for the subtitle-2 font level.
304
+ /// @param {Map} $body-1 The font settings for the body-1 font level.
305
+ /// @param {Map} $body-2 The font settings for the body-2 font level.
306
+ /// @param {Map} $caption The font settings for the caption font level.
307
+ /// @param {Map} $button The font settings for the button font level.
308
+ /// @param {Map} $overline The font settings for the overline font level.
309
+ /// @return {Map} A map containing font settings for each of the levels in the Material Design spec.
310
+ @function define-rem-typography-config(
311
+ // TODO(mmalerba): rename this function to define-typography-config,
312
+ // and create a predefined px based config for people that need it.
313
+ $font-family: $_default-font-family,
314
+ $headline-1: null,
315
+ $headline-2: null,
316
+ $headline-3: null,
317
+ $headline-4: null,
318
+ $headline-5: null,
319
+ $headline-6: null,
320
+ $subtitle-1: null,
321
+ $subtitle-2: null,
322
+ $body-1: null,
323
+ $body-2: null,
324
+ $caption: null,
325
+ $button: null,
326
+ $overline: null,
327
+ ) {
328
+ @return _apply-font-family($font-family, (
329
+ headline-1: $headline-1 or typography-config-level-from-mdc(headline1),
330
+ headline-2: $headline-2 or typography-config-level-from-mdc(headline2),
331
+ headline-3: $headline-3 or typography-config-level-from-mdc(headline3),
332
+ headline-4: $headline-4 or typography-config-level-from-mdc(headline4),
333
+ headline-5: $headline-5 or typography-config-level-from-mdc(headline5),
334
+ headline-6: $headline-6 or typography-config-level-from-mdc(headline6),
335
+ subtitle-1: $subtitle-1 or typography-config-level-from-mdc(subtitle1),
336
+ subtitle-2: $subtitle-2 or typography-config-level-from-mdc(subtitle2),
337
+ body-1: $body-1 or typography-config-level-from-mdc(body1),
338
+ body-2: $body-2 or typography-config-level-from-mdc(body2),
339
+ caption: $caption or typography-config-level-from-mdc(caption),
340
+ button: $button or typography-config-level-from-mdc(button),
341
+ overline: $overline or typography-config-level-from-mdc(overline),
342
+ ));
343
+ }
344
+
159
345
  // Converts an MDC typography level config to an Angular Material one.
160
346
  @function typography-config-level-from-mdc($mdc-level, $font-family: null) {
161
347
  $mdc-level-config: map.get($_mdc-levels, $mdc-level);
@@ -170,3 +356,33 @@ $_mdc-levels: (
170
356
  $letter-spacing: map.get($mdc-level-config, letter-spacing)
171
357
  );
172
358
  }
359
+
360
+ // Converts a map containing rem values to a map containing px values.
361
+ @function _rem-to-px($x, $px-per-rem: 16px) {
362
+ @if meta.type-of($x) == 'map' {
363
+ @each $key, $val in $x {
364
+ $x: map.merge($x, ($key: _rem-to-px($val)));
365
+ }
366
+ @return $x;
367
+ }
368
+ @if meta.type-of($x) == 'number' and math.unit($x) == 'rem' {
369
+ @return math.div($x, 1rem) * $px-per-rem;
370
+ }
371
+ @else {
372
+ @return $x;
373
+ }
374
+ }
375
+
376
+ // Applies the default font family to all levels in a typography config.
377
+ @function _apply-font-family($font-family, $initial-config) {
378
+ $config: $initial-config;
379
+
380
+ @each $key, $level in $config {
381
+ @if map.get($level, 'font-family') == null {
382
+ // Sass maps are immutable so we have to re-assign the variable each time.
383
+ $config: map.set($config, $key, map.set($level, 'font-family', $font-family));
384
+ }
385
+ }
386
+
387
+ @return map.set($config, 'font-family', $font-family);
388
+ }
@@ -76,7 +76,29 @@ $theme-version: 1;
76
76
  // density
77
77
  $density-scale: map.get($density-config, scale) or 0;
78
78
 
79
+ $system-maps: (
80
+ m3-tokens.get-sys-color($type, $palettes, $color-system-variables-prefix),
81
+ m3.md-sys-elevation-values(),
82
+ m3.md-sys-motion-values(),
83
+ m3.md-sys-shape-values(),
84
+ m3.md-sys-state-values(),
85
+ (
86
+ // Form field native select option text color
87
+ neutral10: map.get($palettes, neutral, 10),
88
+ // Sidenav scrim (container background shadow when opened),
89
+ neutral-variant20: map.get($palettes, neutral-variant, 20),
90
+ ),
91
+ m3-tokens.get-sys-typeface($typography, $typography-system-variables-prefix),
92
+ );
93
+ $system: (
94
+ density-scale: $density-scale,
95
+ );
96
+ @each $sys-map in $system-maps {
97
+ $system: map.merge($system, $sys-map);
98
+ }
99
+
79
100
  @return (
101
+ _mat-system: $system,
80
102
  $internals: (
81
103
  base-tokens: m3-tokens.generate-base-tokens(),
82
104
  color-system-variables-prefix: $color-system-variables-prefix,
@@ -84,19 +106,6 @@ $theme-version: 1;
84
106
  m3-tokens.generate-color-tokens($type, $palettes, $color-system-variables-prefix),
85
107
  density-scale: $density-scale,
86
108
  font-definition: $typography,
87
- md-sys-color: m3-tokens.get-sys-color($type, $palettes, $color-system-variables-prefix),
88
- md-sys-elevation: m3.md-sys-elevation-values(),
89
- md-sys-motion: m3.md-sys-motion-values(),
90
- md-sys-shape: m3.md-sys-shape-values(),
91
- md-sys-state: m3.md-sys-state-values(),
92
- md-ref-palette: (
93
- // Form field native select option text color
94
- neutral10: map.get($palettes, neutral, 10),
95
- // Sidenav scrim (container background shadow when opened),
96
- neutral-variant20: map.get($palettes, neutral-variant, 20),
97
- ),
98
- md-sys-typescale:
99
- m3-tokens.get-sys-typeface($typography, $typography-system-variables-prefix),
100
109
  palettes: $palettes,
101
110
  theme-type: $type,
102
111
  theme-version: $theme-version,
@@ -0,0 +1,235 @@
1
+ @use 'sass:list';
2
+ @use 'sass:map';
3
+ @use 'sass:meta';
4
+ @use '@angular/material' as mat;
5
+ @use '../typography/versioning' as typography-versioning;
6
+
7
+ /// Key used to access the Angular Material theme internals.
8
+ $_internals: _mat-theming-internals-do-not-access;
9
+
10
+ /// Keys that indicate a config object is a color config.
11
+ $_color-keys: (
12
+ primary,
13
+ accent,
14
+ warn,
15
+ foreground,
16
+ background,
17
+ is-dark,
18
+ color, /* included for themes that incorrectly nest the color config: (color: (color: (....))) */
19
+ );
20
+
21
+ /// Keys that indicate a config object is a typography config.
22
+ $_typography-keys: (
23
+ headline-1,
24
+ headline-2,
25
+ headline-3,
26
+ headline-4,
27
+ headline-5,
28
+ headline-6,
29
+ subtitle-1,
30
+ font-family,
31
+ subtitle-2,
32
+ body-1,
33
+ body-2,
34
+ button,
35
+ caption,
36
+ overline,
37
+ );
38
+
39
+ /// The CSS typography properties supported by the inspection API.
40
+ $_typography-properties: (font, font-family, line-height, font-size, letter-spacing, font-weight);
41
+
42
+ /// Gets the m2-config from the theme.
43
+ @function get-m2-config($theme) {
44
+ // It is possible for a user to pass a "density theme" that is just a number.
45
+ @if meta.type-of($theme) != 'map' {
46
+ @return $theme;
47
+ }
48
+ $internal: map.get($theme, $_internals, m2-config);
49
+ $theme: map.remove($theme, $_internals);
50
+ @return if(_is-error-theme($theme), $internal, $theme);
51
+ }
52
+
53
+ /// Checks whether the given theme contains error values.
54
+ /// @param {*} $theme The theme to check.
55
+ /// @return {Boolean} true if the theme contains error values, else false.
56
+ @function _is-error-theme($theme) {
57
+ @if meta.type-of($theme) != 'map' {
58
+ @return false;
59
+ }
60
+ @if map.get($theme, ERROR) {
61
+ @return true;
62
+ }
63
+ @return _is-error-theme(list.nth(map.values($theme), 1));
64
+ }
65
+
66
+ /// Checks whether the given theme object has any of the given keys.
67
+ /// @param {Map} $theme The theme to check
68
+ /// @param {List} $keys The keys to check for
69
+ /// @return {Boolean} Whether the theme has any of the given keys.
70
+ @function _has-any-key($theme, $keys) {
71
+ @each $key in $keys {
72
+ @if map.has-key($theme, $key) {
73
+ @return true;
74
+ }
75
+ }
76
+ @return false;
77
+ }
78
+
79
+ /// Checks whether the given theme is a density scale value.
80
+ /// @param {*} $theme The theme to check.
81
+ /// @return {Boolean} true if the theme is a density scale value, else false.
82
+ @function _is-density-value($theme) {
83
+ @return $theme == minimum or $theme == maximum or meta.type-of($theme) == 'number';
84
+ }
85
+
86
+ /// Gets the type of theme represented by a theme object (light or dark).
87
+ /// @param {Map} $theme The theme
88
+ /// @return {String} The type of theme (either `light` or `dark`).
89
+ @function get-theme-type($theme) {
90
+ $theme: get-m2-config($theme);
91
+ @if not theme-has($theme, color) {
92
+ @error 'Color information is not available on this theme.';
93
+ }
94
+ $colors: mat.m2-get-color-config($theme);
95
+ // Some apps seem to have mistakenly created nested color themes that somehow work with our old
96
+ // theme normalization logic. This check allows those apps to keep working.
97
+ @if theme-has($colors, color) {
98
+ $colors: mat.m2-get-color-config($colors);
99
+ }
100
+ @return if(map.get($colors, is-dark), dark, light);
101
+ }
102
+
103
+ /// Gets a color from a theme object. This function can take between 2 and 4 arguments. The first
104
+ /// argument is the theme, the second one is the palette from which to extract the color, the third
105
+ /// one is the hue within the palette and the fourth is the opacity of the returned color.
106
+ /// @param {Map} $theme The theme
107
+ /// @param {String} $palette-name The name of a color palette.
108
+ /// @param {Number} $hue The palette hue to get (passing this argument means the second argument is
109
+ /// interpreted as a palette name).
110
+ /// @param {Number} $opacity The alpha channel value for the color.
111
+ /// @return {Color} The requested theme color.
112
+ @function get-theme-color($theme, $palette-name, $args...) {
113
+ $theme: get-m2-config($theme);
114
+ @if not theme-has($theme, color) {
115
+ @error 'Color information is not available on this theme.';
116
+ }
117
+ $colors: mat.m2-get-color-config($theme);
118
+ // Some apps seem to have mistakenly created nested color themes that somehow work with our old
119
+ // theme normalization logic. This check allows those apps to keep working.
120
+ @if theme-has($colors, color) {
121
+ $colors: mat.m2-get-color-config($colors);
122
+ }
123
+ $palette: map.get($colors, $palette-name);
124
+ @if not $palette {
125
+ @error $palette-name $args $theme;
126
+ @error #{'Unrecognized palette name:'} $palette-name;
127
+ }
128
+ @return mat.m2-get-color-from-palette($palette, $args...);
129
+ }
130
+
131
+ /// Gets a typography value from a theme object.
132
+ /// @param {Map} $theme The theme
133
+ /// @param {String} $typescale The typescale name.
134
+ /// @param {String} $property The CSS font property to get
135
+ /// (font, font-family, font-size, font-weight, line-height, or letter-spacing).
136
+ /// @return {*} The value of the requested font property.
137
+ @function get-theme-typography($theme, $typescale, $property) {
138
+ $theme: get-m2-config($theme);
139
+ @if not theme-has($theme, typography) {
140
+ @error 'Typography information is not available on this theme.';
141
+ }
142
+ $typography: typography-versioning.private-typography-to-2018-config(
143
+ mat.m2-get-typography-config($theme));
144
+ @if $property == font {
145
+ $font-weight: mat.m2-font-weight($typography, $typescale);
146
+ $font-size: mat.m2-font-size($typography, $typescale);
147
+ $line-height: mat.m2-line-height($typography, $typescale);
148
+ $font-family: mat.m2-font-family($typography, $typescale);
149
+ @return ($font-weight list.slash($font-size, $line-height) $font-family);
150
+ }
151
+ @else if $property == font-family {
152
+ $result: mat.m2-font-family($typography, $typescale);
153
+ @return $result or mat.m2-font-family($typography);
154
+ }
155
+ @else if $property == font-size {
156
+ @return mat.m2-font-size($typography, $typescale);
157
+ }
158
+ @else if $property == font-weight {
159
+ @return mat.m2-font-weight($typography, $typescale);
160
+ }
161
+ @else if $property == line-height {
162
+ @return mat.m2-line-height($typography, $typescale);
163
+ }
164
+ @else if $property == letter-spacing {
165
+ @return mat.m2-letter-spacing($typography, $typescale);
166
+ }
167
+ @else {
168
+ @error #{'Valid typography properties are: #{$_typography-properties}. Got:'} $property;
169
+ }
170
+ }
171
+
172
+ /// Gets the density scale from a theme object.
173
+ /// @param {Map} $theme The theme
174
+ /// @return {Number} The density scale.
175
+ @function get-theme-density($theme) {
176
+ $theme: get-m2-config($theme);
177
+ @if not theme-has($theme, density) {
178
+ @error 'Density information is not available on this theme.';
179
+ }
180
+ $scale: mat.m2-get-density-config($theme);
181
+ @return mat.private-clamp-density($scale, -5);
182
+ }
183
+
184
+ /// Checks whether the theme has information about given theming system.
185
+ /// @param {Map} $theme The theme
186
+ /// @param {String} $system The system to check
187
+ /// @param {Boolean} Whether the theme has information about the system.
188
+ @function theme-has($theme, $system) {
189
+ $theme: get-m2-config($theme);
190
+ @if $system == base {
191
+ @return true;
192
+ }
193
+ @if $system == color {
194
+ $color: mat.m2-get-color-config($theme);
195
+ @return $color != null and _has-any-key($color, $_color-keys);
196
+ }
197
+ @if $system == typography {
198
+ $typography: mat.m2-get-typography-config($theme);
199
+ @return $typography != null and _has-any-key($typography, $_typography-keys);
200
+ }
201
+ @if $system == density {
202
+ // Backwards compatibility for the case where an explicit, but invalid density is given
203
+ // (this was previously treated as density 0).
204
+ @if meta.type-of($theme) == 'map' and map.get($theme, density) {
205
+ @return true;
206
+ }
207
+ $density: mat.m2-get-density-config($theme);
208
+ @return $density != null and _is-density-value($density);
209
+ }
210
+ @error 'Valid systems are: base, color, typography, density. Got:' $system;
211
+ }
212
+
213
+ /// Removes the information about the given theming system(s) from the given theme.
214
+ /// @param {Map} $theme The theme to remove information from
215
+ /// @param {String...} $systems The systems to remove
216
+ /// @return {Map} A version of the theme without the removed theming systems.
217
+ @function theme-remove($theme, $systems...) {
218
+ $internal: map.get($theme, $_internals, m2-config);
219
+ @each $system in $systems {
220
+ @if $system == color {
221
+ $theme: map.set($theme, color, null);
222
+ }
223
+ @else if $system == typography {
224
+ $theme: map.set($theme, typography, null);
225
+ }
226
+ @else if $system == density {
227
+ $theme: map.set($theme, density, null);
228
+ }
229
+ }
230
+ @if $internal {
231
+ $internal: theme-remove($internal, $systems...);
232
+ $theme: map.set($theme, $_internals, m2-config, $internal);
233
+ }
234
+ @return $theme;
235
+ }
@@ -1,8 +1,8 @@
1
1
  @use '@angular/material' as mat;
2
- @use '../../../core/tokens/m3-system';
2
+ @use '../../../core/tokens/system';
3
3
 
4
4
  html {
5
- @include m3-system.theme((
5
+ @include system.theme((
6
6
  color: (
7
7
  theme-type: light,
8
8
  primary: mat.$azure-palette,
@@ -1,8 +1,8 @@
1
1
  @use '@angular/material' as mat;
2
- @use '../../../core/tokens/m3-system';
2
+ @use '../../../core/tokens/system';
3
3
 
4
4
  html {
5
- @include m3-system.theme((
5
+ @include system.theme((
6
6
  color: (
7
7
  theme-type: dark,
8
8
  primary: mat.$cyan-palette,
@@ -1,8 +1,8 @@
1
1
  @use '@angular/material' as mat;
2
- @use '../../../core/tokens/m3-system';
2
+ @use '../../../core/tokens/system';
3
3
 
4
4
  html {
5
- @include m3-system.theme((
5
+ @include system.theme((
6
6
  color: (
7
7
  theme-type: dark,
8
8
  primary: mat.$magenta-palette,
@@ -1,8 +1,8 @@
1
1
  @use '@angular/material' as mat;
2
- @use '../../../core/tokens/m3-system';
2
+ @use '../../../core/tokens/system';
3
3
 
4
4
  html {
5
- @include m3-system.theme((
5
+ @include system.theme((
6
6
  color: (
7
7
  theme-type: light,
8
8
  primary: mat.$rose-palette,
@@ -8,25 +8,13 @@
8
8
  $system: map.set($system, on-#{$color}-container, map.get($system, on-#{$variant}-container));
9
9
  $system: map.set($system, #{$color}, map.get($system, #{$variant}));
10
10
  $system: map.set($system, #{$color}-container, map.get($system, #{$variant}-container));
11
+ $system: map.set($system, inverse-#{$color}, map.get($system, inverse-#{$variant}));
11
12
  @return $system;
12
13
  }
13
14
 
14
15
  // Gets the theme's system values as a flat map.
15
16
  @function get-system($theme) {
16
- $system: ();
17
- $system: map.merge($system,
18
- map.get($theme, _mat-theming-internals-do-not-access, md-sys-color));
19
- $system: map.merge($system,
20
- map.get($theme, _mat-theming-internals-do-not-access, md-sys-elevation));
21
- $system: map.merge($system,
22
- map.get($theme, _mat-theming-internals-do-not-access, md-sys-shape));
23
- $system: map.merge($system,
24
- map.get($theme, _mat-theming-internals-do-not-access, md-sys-state));
25
- $system: map.merge($system,
26
- map.get($theme, _mat-theming-internals-do-not-access, md-sys-typescale));
27
- $system: map.merge($system,
28
- map.get($theme, _mat-theming-internals-do-not-access, md-ref-palette));
29
- @return $system;
17
+ @return map.get($theme, _mat-system);
30
18
  }
31
19
 
32
20
  // Returns the color with an opacity value using color-mix. If the color is a variable name, it