@angular/material-experimental 18.0.0-next.4 → 18.0.0-next.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/_index.scss +0 -7
  2. package/esm2022/column-resize/column-resize-directives/column-resize-flex.mjs +3 -3
  3. package/esm2022/column-resize/column-resize-directives/column-resize.mjs +3 -3
  4. package/esm2022/column-resize/column-resize-directives/default-enabled-column-resize-flex.mjs +3 -3
  5. package/esm2022/column-resize/column-resize-directives/default-enabled-column-resize.mjs +3 -3
  6. package/esm2022/column-resize/column-resize-module.mjs +12 -12
  7. package/esm2022/column-resize/overlay-handle.mjs +3 -3
  8. package/esm2022/column-resize/resizable-directives/default-enabled-resizable.mjs +3 -3
  9. package/esm2022/column-resize/resizable-directives/resizable.mjs +3 -3
  10. package/esm2022/column-resize/resize-strategy.mjs +3 -3
  11. package/esm2022/menubar/menubar-item.mjs +3 -3
  12. package/esm2022/menubar/menubar-module.mjs +4 -4
  13. package/esm2022/menubar/menubar.mjs +3 -3
  14. package/esm2022/popover-edit/lens-directives.mjs +9 -9
  15. package/esm2022/popover-edit/popover-edit-module.mjs +4 -4
  16. package/esm2022/popover-edit/table-directives.mjs +12 -12
  17. package/esm2022/selection/row-selection.mjs +3 -3
  18. package/esm2022/selection/select-all.mjs +3 -3
  19. package/esm2022/selection/selection-column.mjs +3 -3
  20. package/esm2022/selection/selection-module.mjs +4 -4
  21. package/esm2022/selection/selection-toggle.mjs +3 -3
  22. package/esm2022/selection/selection.mjs +3 -3
  23. package/esm2022/version.mjs +1 -1
  24. package/fesm2022/column-resize.mjs +36 -36
  25. package/fesm2022/material-experimental.mjs +1 -1
  26. package/fesm2022/material-experimental.mjs.map +1 -1
  27. package/fesm2022/menubar.mjs +10 -10
  28. package/fesm2022/popover-edit.mjs +25 -25
  29. package/fesm2022/selection.mjs +19 -19
  30. package/package.json +4 -3
  31. package/theming/_color-api-back-compat.scss +0 -111
  32. package/theming/_config-validation.scss +0 -166
  33. package/theming/_custom-tokens.scss +0 -1918
  34. package/theming/_definition.scss +0 -104
  35. package/theming/_format-tokens.scss +0 -5
  36. package/theming/_m3-density.scss +0 -191
  37. package/theming/_m3-palettes.scss +0 -947
  38. package/theming/_m3-tokens.scss +0 -1042
@@ -1,1042 +0,0 @@
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
-
10
- // TODO(mmalerba): Split up this file into smaller pieces.
11
-
12
- /// Maps the values in a map to new values using the given mapping function
13
- /// @param {Map} $map The maps whose values will be mapped to new values.
14
- /// @param {Function} $fn The value mapping function.
15
- /// @param {Map} A new map with its values updated using the mapping function.
16
- @function _map-values($map, $fn) {
17
- $result: ();
18
- @each $key, $value in $map {
19
- $result: map.set($result, $key, meta.call($fn, $value));
20
- }
21
- @return $result;
22
- }
23
-
24
- /// Picks a submap containing only the given keys out the given map.
25
- /// @param {Map} $map The map to pick from.
26
- /// @param {List} $keys The map keys to pick.
27
- /// @return {Map} A submap containing only the given keys.
28
- @function _pick($map, $keys) {
29
- $result: ();
30
- @each $key in $keys {
31
- @if map.has-key($map, $key) {
32
- $result: map.set($result, $key, map.get($map, $key));
33
- }
34
- }
35
- @return $result;
36
- }
37
-
38
- /// Filters keys with a null value out of the map.
39
- /// @param {Map} $map The map to filter.
40
- /// @return {Map} The given map with all of the null keys filtered out.
41
- @function _filter-nulls($map) {
42
- $result: ();
43
- @each $key, $val in $map {
44
- @if $val != null {
45
- $result: map.set($result, $key, $val);
46
- }
47
- }
48
- @return $result;
49
- }
50
-
51
- /// Renames the keys in a map
52
- /// @param {Map} $map The map whose keys should be renamed
53
- /// @param {Map} $rename-keys A map of original key to renamed key to apply to $map
54
- /// @return {Map} The result of applying the given key renames to the given map.
55
- @function _rename-map-keys($map, $rename-keys) {
56
- $result: $map;
57
- @each $old-key-name, $new-key-name in $rename-keys {
58
- @if map.has-key($map, $old-key-name) {
59
- $result: map.set($result, $new-key-name, map.get($map, $old-key-name));
60
- }
61
- }
62
- @return $result;
63
- }
64
-
65
- /// Gets the MDC tokens for the given prefix, M3 token values, and supported token slots.
66
- /// @param {List} $prefix The token prefix for the given tokens.
67
- /// @param {Map|(Map, Map)} $m3-values A map of M3 token values for the given prefix.
68
- /// This param may also be a tuple of maps, the first one representing the default M3 token values,
69
- // and the second containing overrides for different color variants.
70
- // Single map example:
71
- // (token1: green, token2: 2px)
72
- // Tuple example:
73
- // (
74
- // (token1: green, token2: 2px),
75
- // (
76
- // secondary: (token1: blue),
77
- // error: (token1: red),
78
- // )
79
- // )
80
- /// @param {Map} $slots A map of token slots, with null value indicating the token is not supported.
81
- /// @param {String|null} $variant The name of the variant the token values are for.
82
- /// @return {Map} A map of fully qualified token names to values, for only the supported tokens.
83
- @function _namespace-tokens($prefix, $m3-values, $slots, $variant: null) {
84
- $result: ();
85
- @if $variant == null and meta.type-of($m3-values) == 'list' and list.length($m3-values == 2) {
86
- $variants: list.nth($m3-values, 2);
87
- $m3-values: list.nth($m3-values, 1);
88
- @each $variant, $overrides in $variants {
89
- $result: map.merge($result, _namespace-tokens($prefix, $overrides, $slots, $variant));
90
- }
91
- }
92
- $used-token-names: map.keys(_filter-nulls(map.get($slots, $prefix)));
93
- $used-m3-tokens: _pick(_filter-nulls($m3-values), $used-token-names);
94
- $prefix: if($variant == null, $prefix, list.append($prefix, $variant));
95
- @return map.merge($result, ($prefix: $used-m3-tokens));
96
- }
97
-
98
- /// Generates tokens for the given palette with the given prefix.
99
- /// @param {Map} $palette The palette to generate tokens for
100
- /// @param {String} $prefix The key prefix used to name the tokens
101
- /// @return {Map} A set of tokens for the given palette
102
- @function _generate-palette-tokens($palette, $prefix) {
103
- $palette: map.remove($palette, neutral, neutral-variant);
104
- $result: ();
105
- @each $hue, $value in $palette {
106
- $result: map.set($result, '#{$prefix}#{$hue}', $value);
107
- }
108
- @return $result;
109
- }
110
-
111
- /// Creates a set of `md-ref-palette` tokens from the given palettes. (See
112
- /// https://github.com/material-components/material-components-web/blob/master/packages/mdc-tokens/v0_161/_md-ref-palette.scss)
113
- /// @param {Map} $primary The primary palette
114
- /// @param {Map} $secondary The secondary palette
115
- /// @param {Map} $tertiary The tertiary palette
116
- /// @param {Map} $error The error palette
117
- /// @return {Map} A set of `md-ref-palette` tokens
118
- @function _generate-ref-palette-tokens($primary, $tertiary, $error) {
119
- @return mat.private-merge-all(
120
- (black: #000, white: #fff),
121
- _generate-palette-tokens($primary, primary),
122
- _generate-palette-tokens(map.get($primary, secondary), secondary),
123
- _generate-palette-tokens($tertiary, tertiary),
124
- _generate-palette-tokens(map.get($primary, neutral), neutral),
125
- _generate-palette-tokens(map.get($primary, neutral-variant), neutral-variant),
126
- _generate-palette-tokens($error, error),
127
- );
128
- }
129
-
130
- /// Creates a set of `md-ref-typeface` tokens from the given palettes. (See
131
- /// https://github.com/material-components/material-components-web/blob/master/packages/mdc-tokens/v0_161/_md-ref-typeface.scss)
132
- /// @param {List|String} $brand The font-family to use for brand text
133
- /// @param {List|String} $plain The font-family to use for plain text
134
- /// @param {String} $bold The font-weight to use for bold text
135
- /// @param {String} $medium The font-weight to use for medium text
136
- /// @param {String} $regular The font-weight to use for regular text
137
- /// @return {Map} A set of `md-ref-typeface` tokens
138
- @function _generate-ref-typeface-tokens($brand, $plain, $bold, $medium, $regular) {
139
- @return (
140
- brand: $brand,
141
- plain: $plain,
142
- weight-bold: $bold,
143
- weight-medium: $medium,
144
- weight-regular: $regular,
145
- );
146
- }
147
-
148
- /// At the time of writing, some color tokens (e.g. disabled state) are defined as a solid color
149
- /// token and a separate opacity token. This function applies the opacity to the color and drops the
150
- /// opacity key from the map. Can be removed once b/213331407 is resolved.
151
- /// @param {Map} $tokens The map of tokens currently being generated
152
- /// @param {Map} $all-tokens A map of all tokens, including hardcoded values
153
- /// @param {List} $pairs Pairs of color token names and their opacities. Should be in the shape of
154
- /// `((color: 'color-key', opacity: 'opacity-key'))`.
155
- /// @return {Map} The initial tokens with the combined color values.
156
- @function _combine-color-tokens($tokens, $opacity-lookup, $pairs) {
157
- $result: $tokens;
158
-
159
- @each $pair in $pairs {
160
- $color-key: map.get($pair, color);
161
- $opacity-key: map.get($pair, opacity);
162
- $color: map.get($tokens, $color-key);
163
- $opacity: map.get($opacity-lookup, $opacity-key);
164
-
165
- @if meta.type-of($color) == 'color' {
166
- @if meta.type-of($opacity) != 'number' {
167
- @error 'Cannot find valid opacity value for color token "#{$color-key}"';
168
- }
169
-
170
- $result: map.remove($result, $opacity-key);
171
- $result: map.set($result, $color-key, rgba($color, $opacity));
172
- }
173
- }
174
-
175
- @return $result;
176
- }
177
-
178
- /// Renames the official checkbox tokens to match the names actually used in MDC's code (which are
179
- /// different). This is a temporary workaround until MDC updates to use the correct names for the
180
- /// tokens.
181
- /// @param {Map} $tokens The map of checkbox tokens with the official tokens names
182
- /// @param {Map} $all-tokens Map of all checkbox tokens, including hardcoded values.
183
- /// This is necessary in order to do opacity lookups.
184
- /// @return {Map} The given tokens, renamed to be compatible with MDC's token implementation.
185
- @function _fix-checkbox-tokens($tokens) {
186
- // Need to get the hardcoded values, because they include opacities that are used for the disabled
187
- // state.
188
- $hardcoded-tokens: mdc-tokens.md-comp-checkbox-values((), false);
189
-
190
- $rename-keys: (
191
- selected-icon-color: selected-checkmark-color,
192
- selected-disabled-icon-color: disabled-selected-checkmark-color,
193
- selected-container-color: selected-icon-color,
194
- selected-hover-container-color: selected-hover-icon-color,
195
- selected-disabled-container-color: disabled-selected-icon-color,
196
- selected-disabled-container-opacity: disabled-selected-icon-opacity,
197
- selected-focus-container-color: selected-focus-icon-color,
198
- selected-pressed-container-color: selected-pressed-icon-color,
199
- unselected-disabled-outline-color: disabled-unselected-icon-color,
200
- unselected-disabled-container-opacity: disabled-unselected-icon-opacity,
201
- unselected-focus-outline-color: unselected-focus-icon-color,
202
- unselected-hover-outline-color: unselected-hover-icon-color,
203
- unselected-outline-color: unselected-icon-color,
204
- unselected-pressed-outline-color: unselected-pressed-icon-color
205
- );
206
-
207
- $remapped-tokens: _rename-map-keys($tokens, $rename-keys);
208
- $remapped-hardcoded-tokens: _rename-map-keys($hardcoded-tokens, $rename-keys);
209
-
210
- @return _combine-color-tokens($remapped-tokens, $remapped-hardcoded-tokens, (
211
- (
212
- color: disabled-selected-icon-color,
213
- opacity: disabled-selected-icon-opacity,
214
- ),
215
- (
216
- color: disabled-unselected-icon-color,
217
- opacity: disabled-unselected-icon-opacity,
218
- ),
219
- ));
220
- }
221
-
222
- /// Fixes inconsistent values in the filled text field tokens so that they can produce valid
223
- /// styles.
224
- /// @param {Map} $initial-tokens Map of filled text field tokens currently being generated.
225
- /// @return {Map} The given tokens, with the invalid values replaced with valid ones.
226
- @function _fix-filled-text-field-tokens($initial-tokens) {
227
- // Need to get the hardcoded values, because they include opacities that are used for the disabled
228
- // state.
229
- $hardcoded-tokens: mdc-tokens.md-comp-filled-text-field-values((), false);
230
-
231
- $tokens: _combine-color-tokens($initial-tokens, $hardcoded-tokens, (
232
- (
233
- color: disabled-active-indicator-color,
234
- opacity: disabled-active-indicator-opacity
235
- ),
236
- (
237
- color: disabled-container-color,
238
- opacity: disabled-container-opacity
239
- ),
240
- (
241
- color: disabled-input-text-color,
242
- opacity: disabled-input-text-opacity
243
- ),
244
- (
245
- color: disabled-label-text-color,
246
- opacity: disabled-label-text-opacity
247
- ),
248
- (
249
- color: disabled-leading-icon-color,
250
- opacity: disabled-leading-icon-opacity
251
- ),
252
- (
253
- color: disabled-supporting-text-color,
254
- opacity: disabled-supporting-text-opacity
255
- ),
256
- (
257
- color: disabled-trailing-icon-color,
258
- opacity: disabled-trailing-icon-opacity
259
- )
260
- ));
261
-
262
- $container-shape: map.get($tokens, container-shape);
263
-
264
- // The M2 token slots define a single `container-shape` slot while the M3 tokens provide a list
265
- // of shapes (e.g. top/bottom/left/right). Extract the first value so it matches the expected
266
- // token slot in M2.
267
- @if meta.type-of($container-shape) == 'list' {
268
- $tokens: map.set($tokens, container-shape, list.nth($container-shape, 1));
269
- }
270
-
271
- @return $tokens;
272
- }
273
-
274
-
275
- /// Fixes inconsistent values in the text button tokens so that they can produce valid styles.
276
- /// @param {Map} $initial-tokens Map of text button tokens currently being generated.
277
- /// @return {Map} The given tokens, with the invalid values replaced with valid ones.
278
- @function _fix-text-button-tokens($initial-tokens) {
279
- // Need to get the hardcoded values, because they include opacities that are used for the disabled
280
- // state.
281
- $hardcoded-tokens: mdc-tokens.md-comp-text-button-values((), false);
282
-
283
- @return _combine-color-tokens($initial-tokens, $hardcoded-tokens, (
284
- (
285
- color: disabled-label-text-color,
286
- opacity: disabled-label-text-opacity,
287
- ),
288
- ));
289
- }
290
-
291
- /// Fixes inconsistent values in the filled button tokens so that they can produce valid styles.
292
- /// @param {Map} $initial-tokens Map of filled button tokens currently being generated.
293
- /// @return {Map} The given tokens, with the invalid values replaced with valid ones.
294
- @function _fix-filled-button-tokens($initial-tokens) {
295
- // Need to get the hardcoded values, because they include opacities that are used for the disabled
296
- // state.
297
- $hardcoded-tokens: mdc-tokens.md-comp-filled-button-values((), false);
298
-
299
- @return _combine-color-tokens($initial-tokens, $hardcoded-tokens, (
300
- (
301
- color: disabled-label-text-color,
302
- opacity: disabled-label-text-opacity,
303
- ),
304
- (
305
- color: disabled-container-color,
306
- opacity: disabled-container-opacity,
307
- )
308
- ));
309
- }
310
-
311
- /// Fixes inconsistent values in the protected button tokens so that they can produce valid styles.
312
- /// @param {Map} $initial-tokens Map of protected button tokens currently being generated.
313
- /// @return {Map} The given tokens, with the invalid values replaced with valid ones.
314
- @function _fix-protected-button-tokens($initial-tokens) {
315
- // Need to get the hardcoded values, because they include opacities that are used for the disabled
316
- // state.
317
- $hardcoded-tokens: mdc-tokens.md-comp-elevated-button-values((), false);
318
-
319
- @return _combine-color-tokens($initial-tokens, $hardcoded-tokens, (
320
- (
321
- color: disabled-label-text-color,
322
- opacity: disabled-label-text-opacity,
323
- ),
324
- (
325
- color: disabled-container-color,
326
- opacity: disabled-container-opacity,
327
- )
328
- ));
329
- }
330
-
331
- /// Fixes inconsistent values in the outlined button tokens so that they can produce valid styles.
332
- /// @param {Map} $initial-tokens Map of outlined button tokens currently being generated.
333
- /// @return {Map} The given tokens, with the invalid values replaced with valid ones.
334
- @function _fix-outlined-button-tokens($initial-tokens) {
335
- $hardcoded-tokens: mdc-tokens.md-comp-outlined-button-values((), false);
336
-
337
- @return _combine-color-tokens($initial-tokens, $hardcoded-tokens, (
338
- (
339
- color: disabled-label-text-color,
340
- opacity: disabled-label-text-opacity,
341
- ),
342
- (
343
- color: disabled-outline-color,
344
- opacity: disabled-outline-opacity,
345
- )
346
- ));
347
- }
348
-
349
- /// Fixes inconsistent values in the outlined text field tokens so that they can produce valid
350
- /// styles.
351
- /// @param {Map} $initial-tokens Map of outlined text field tokens currently being generated.
352
- /// @param {Map} $all-tokens Map of all outlined text field tokens, including hardcoded values.
353
- /// This is necessary in order to do opacity lookups.
354
- /// @return {Map} The given tokens, with the invalid values replaced with valid ones.
355
- @function _fix-outlined-text-field-tokens($initial-tokens) {
356
- // Need to get the hardcoded values, because they include opacities that are used for the disabled
357
- // state.
358
- $hardcoded-tokens: mdc-tokens.md-comp-outlined-text-field-values((), false);
359
-
360
- @return _combine-color-tokens($initial-tokens, $hardcoded-tokens, (
361
- (
362
- color: disabled-outline-color,
363
- opacity: disabled-outline-opacity
364
- ),
365
- (
366
- color: disabled-active-indicator-color,
367
- opacity: disabled-active-indicator-opacity
368
- ),
369
- (
370
- color: disabled-container-color,
371
- opacity: disabled-container-opacity
372
- ),
373
- (
374
- color: disabled-input-text-color,
375
- opacity: disabled-input-text-opacity
376
- ),
377
- (
378
- color: disabled-label-text-color,
379
- opacity: disabled-label-text-opacity
380
- ),
381
- (
382
- color: disabled-leading-icon-color,
383
- opacity: disabled-leading-icon-opacity
384
- ),
385
- (
386
- color: disabled-supporting-text-color,
387
- opacity: disabled-supporting-text-opacity
388
- ),
389
- (
390
- color: disabled-trailing-icon-color,
391
- opacity: disabled-trailing-icon-opacity
392
- )
393
- ));
394
- }
395
-
396
- /// Gets the token values for the MDC form field.
397
- /// @param {Map} $systems The MDC system tokens.
398
- /// @return {Map} The form field tokens.
399
- @function _get-form-field-tokens($systems) {
400
- @return (
401
- // TODO: MDC currently doesn't provide tokens for the form field so we need to
402
- // define them ourselves. Clean this up once b/246297033 is resolved.
403
- label-text-color: map.get($systems, 'md-sys-color', 'on-surface'),
404
- label-text-font: map.get($systems, 'md-sys-typescale', 'body-medium-font'),
405
- label-text-line-height: map.get($systems, 'md-sys-typescale', 'body-medium-line-height'),
406
- label-text-size: map.get($systems, 'md-sys-typescale', 'body-medium-size'),
407
- label-text-tracking: map.get($systems, 'md-sys-typescale', 'body-medium-tracking'),
408
- label-text-weight: map.get($systems, 'md-sys-typescale', 'body-medium-weight'),
409
- );
410
- }
411
-
412
- /// Fixes inconsistent values in the icon button tokens so that they can produce valid styles.
413
- /// @param {Map} $initial-tokens Map of icon button tokens currently being generated.
414
- /// @param {Map} $all-tokens Map of all icon button tokens, including hardcoded values.
415
- /// @return {Map} The given tokens, with the invalid values replaced with valid ones.
416
- @function _fix-icon-button-tokens($tokens) {
417
- // Need to get the hardcoded values, because they include opacities that are used for the disabled
418
- // state.
419
- $hardcoded-tokens: mdc-tokens.md-comp-icon-button-values((), false);
420
-
421
- $rename-keys: (
422
- unselected-icon-color: icon-color,
423
- );
424
-
425
- $remapped-tokens: _rename-map-keys($tokens, $rename-keys);
426
- $remapped-hardcoded-tokens: _rename-map-keys($hardcoded-tokens, $rename-keys);
427
-
428
- @return _combine-color-tokens($remapped-tokens, $remapped-hardcoded-tokens, (
429
- (
430
- color: disabled-icon-color,
431
- opacity: disabled-icon-opacity,
432
- ),
433
- ));
434
- }
435
-
436
- /// Fixes inconsistent values in the dialog tokens so that they can produce valid styles.
437
- /// @param {Map} $initial-tokens Map of dialog tokens currently being generated.
438
- /// @param {Map} $all-tokens Map of all dialog tokens, including hardcoded values.
439
- /// @return {Map} The given tokens, with the invalid values replaced with valid ones.
440
- @function _fix-dialog-tokens($systems, $tokens) {
441
- $tokens: _rename-map-keys($tokens, (
442
- headline-color: subhead-color,
443
- headline-font: subhead-font,
444
- headline-line-height: subhead-line-height,
445
- headline-size: subhead-size,
446
- headline-tracking: subhead-tracking,
447
- headline-weight: subhead-weight,
448
- ));
449
-
450
- @if map.get($tokens, container-elevation) != null {
451
- $tokens: map.merge($tokens, (
452
- // The spec has the dialog at an elevation of 3 which is consistent with the current
453
- // version of the tokens (0_161), however both the designs and MDC's implementation
454
- // have the elevation set to 0. Set it manually to 0 here since the value in the
455
- // exported tokens is likely outdated.
456
- container-elevation: 0,
457
-
458
- // This color needs to be supplied for MDC to produce the shadow. Technically we don't
459
- // have to provide it since the elevation is set to 0 above, but we do it in case
460
- // the value changes in the future.
461
- container-shadow-color: #000,
462
- ));
463
- }
464
-
465
- @return $tokens;
466
- }
467
-
468
- /// Fixes values in the list tokens that are inconsistent with its usage.
469
- /// @param {Map} $initial-tokens Map of list tokens currently being generated.
470
- /// @return {Map} The given tokens, with the inconsistent values replaced with valid ones.
471
- @function _fix-list-tokens($tokens) {
472
- // This does not match the spec, which defines this to be `md.sys.color.surface`.
473
- // However, this interferes with the use case of placing a list on other components. For example,
474
- // the bottom sheet's container color is `md.sys.color.surface-container-low`. Instead, allow the
475
- // list to just display the colors for its background.
476
- @if map.get($tokens, list-item-container-color) != null {
477
- $tokens: map.set($tokens, list-item-container-color, transparent);
478
- }
479
-
480
- // Match spec, which has list-item-leading-icon-size of 24px. Current version of tokens (0_161)
481
- // has 18px.
482
- @if map.get($tokens, list-item-leading-icon-size) != null {
483
- $tokens: map.set($tokens, list-item-leading-icon-size, 24px);
484
- }
485
-
486
- @return $tokens;
487
- }
488
-
489
- /// Generates a set of namespaced tokens for all components.
490
- /// @param {Map} $systems The MDC system tokens
491
- /// @param {Boolean} $include-non-systemized Whether to include non-systemized tokens
492
- /// @return {Map} A map of namespaced tokens
493
- @function _generate-tokens($systems, $include-non-systemized: false) {
494
- $systems: map.merge((
495
- md-sys-color: (),
496
- md-sys-elevation: (),
497
- md-sys-motion: (),
498
- md-sys-shape: (),
499
- md-sys-state: (),
500
- md-sys-typescale: ()
501
- ), $systems);
502
- $exclude-hardcoded: not $include-non-systemized;
503
-
504
- // DO NOT REMOVE
505
- // This function is used internally.
506
- $systems: format-tokens.private-format-tokens($systems);
507
-
508
- // TODO(mmalerba): Refactor this to not depend on the legacy theme when moving out of
509
- // material-experimental. This is a hack for now because there is no good way to get the token
510
- // slots in material-experimental without exposing them all from material.
511
- $fake-theme: mat.define-light-theme((
512
- color: (
513
- primary: mat.define-palette(mat.$red-palette),
514
- accent: mat.define-palette(mat.$red-palette),
515
- warn: mat.define-palette(mat.$red-palette),
516
- ),
517
- typography: mat.define-typography-config(),
518
- density: 0
519
- ));
520
- $token-slots: mat.m2-tokens-from-theme($fake-theme);
521
-
522
- // TODO(mmalerba): Fill in remaining tokens.
523
- $result: mat.private-deep-merge-all(
524
- // Add the system color & typography tokens (so we can give users access via an API).
525
- (
526
- (mdc, theme): map.get($systems, md-sys-color),
527
- (mdc, typography): map.get($systems, md-sys-typescale),
528
- ),
529
- // Get the official MDC component tokens
530
- _namespace-tokens(
531
- (mdc, checkbox),
532
- (
533
- _fix-checkbox-tokens(mdc-tokens.md-comp-checkbox-values($systems, $exclude-hardcoded)),
534
- _map-values(
535
- custom-tokens.mdc-checkbox-color-variants($systems, $exclude-hardcoded),
536
- meta.get-function(_fix-checkbox-tokens)
537
- )
538
- ),
539
- $token-slots
540
- ),
541
- _namespace-tokens(
542
- (mdc, chip),
543
- custom-tokens.mdc-chip($systems, $exclude-hardcoded),
544
- $token-slots
545
- ),
546
- _namespace-tokens(
547
- (mdc, circular-progress),
548
- (
549
- mdc-tokens.md-comp-circular-progress-indicator-values($systems, $exclude-hardcoded),
550
- custom-tokens.mdc-circular-progress-color-variants($systems, $exclude-hardcoded),
551
- ),
552
- $token-slots
553
- ),
554
- _namespace-tokens(
555
- (mdc, dialog),
556
- _fix-dialog-tokens($systems, mdc-tokens.md-comp-dialog-values($systems, $exclude-hardcoded)),
557
- $token-slots
558
- ),
559
- _namespace-tokens(
560
- (mdc, elevated-card),
561
- mdc-tokens.md-comp-elevated-card-values($systems, $exclude-hardcoded),
562
- $token-slots
563
- ),
564
- _namespace-tokens(
565
- (mdc, fab),
566
- (
567
- mdc-tokens.md-comp-fab-primary-values($systems, $exclude-hardcoded),
568
- (
569
- // Color variants
570
- primary: (), // Default, no overrides needed.
571
- secondary: mdc-tokens.md-comp-fab-secondary-values($systems, $exclude-hardcoded),
572
- tertiary: mdc-tokens.md-comp-fab-tertiary-values($systems, $exclude-hardcoded)
573
- )
574
- ),
575
- $token-slots
576
- ),
577
- _namespace-tokens(
578
- (mdc, fab-small),
579
- (
580
- mdc-tokens.md-comp-fab-primary-small-values($systems, $exclude-hardcoded),
581
- (
582
- // Color variants
583
- primary: (), // Default, no overrides needed.
584
- secondary: mdc-tokens.md-comp-fab-secondary-small-values($systems, $exclude-hardcoded),
585
- tertiary: mdc-tokens.md-comp-fab-tertiary-small-values($systems, $exclude-hardcoded)
586
- )
587
- ),
588
- $token-slots
589
- ),
590
- _namespace-tokens(
591
- (mdc, extended-fab),
592
- (
593
- mdc-tokens.md-comp-extended-fab-primary-values($systems, $exclude-hardcoded),
594
- (
595
- // Color variants
596
- primary: (), // Default, no overrides needed.
597
- secondary: mdc-tokens.md-comp-extended-fab-secondary-values($systems, $exclude-hardcoded),
598
- tertiary: mdc-tokens.md-comp-extended-fab-tertiary-values($systems, $exclude-hardcoded)
599
- ),
600
- ),
601
- $token-slots
602
- ),
603
- _namespace-tokens(
604
- (mdc, filled-text-field),
605
- (
606
- _fix-filled-text-field-tokens(
607
- mdc-tokens.md-comp-filled-text-field-values($systems, $exclude-hardcoded)
608
- ),
609
- _map-values(
610
- custom-tokens.mdc-filled-text-field-color-variants($systems, $exclude-hardcoded),
611
- meta.get-function(_fix-filled-text-field-tokens)
612
- )
613
- ),
614
- $token-slots
615
- ),
616
- _namespace-tokens(
617
- (mdc, form-field),
618
- _get-form-field-tokens($systems),
619
- $token-slots
620
- ),
621
- _namespace-tokens(
622
- (mdc, icon-button),
623
- _fix-icon-button-tokens(mdc-tokens.md-comp-icon-button-values($systems, $exclude-hardcoded)),
624
- $token-slots
625
- ),
626
- _namespace-tokens(
627
- (mdc, text-button),
628
- (
629
- _fix-text-button-tokens(
630
- mdc-tokens.md-comp-text-button-values($systems, $exclude-hardcoded)
631
- ),
632
- _map-values(
633
- custom-tokens.mdc-text-button-color-variants($systems, $exclude-hardcoded),
634
- meta.get-function(_fix-text-button-tokens)
635
- )
636
- ),
637
- $token-slots
638
- ),
639
- _namespace-tokens(
640
- // Note: in M3 the "protected" button is called "elevated".
641
- (mdc, protected-button),
642
- (
643
- _fix-protected-button-tokens(
644
- mdc-tokens.md-comp-elevated-button-values($systems, $exclude-hardcoded)
645
- ),
646
- _map-values(
647
- custom-tokens.mdc-elevated-button-color-variants($systems, $exclude-hardcoded),
648
- meta.get-function(_fix-protected-button-tokens)
649
- )
650
- ),
651
- $token-slots
652
- ),
653
- _namespace-tokens(
654
- (mdc, filled-button),
655
- (
656
- _fix-filled-button-tokens(
657
- mdc-tokens.md-comp-filled-button-values($systems, $exclude-hardcoded),
658
- ),
659
- _map-values(
660
- custom-tokens.mdc-filled-button-color-variants($systems, $exclude-hardcoded),
661
- meta.get-function(_fix-filled-button-tokens)
662
- )
663
- ),
664
- $token-slots
665
- ),
666
- _namespace-tokens(
667
- (mdc, outlined-button),
668
- (
669
- _fix-outlined-button-tokens(
670
- mdc-tokens.md-comp-outlined-button-values($systems, $exclude-hardcoded),
671
- ),
672
- _map-values(
673
- custom-tokens.mdc-outlined-button-color-variants($systems, $exclude-hardcoded),
674
- meta.get-function(_fix-outlined-button-tokens)
675
- )
676
- ),
677
- $token-slots
678
- ),
679
- _namespace-tokens(
680
- (mdc, linear-progress),
681
- (
682
- mdc-tokens.md-comp-linear-progress-indicator-values($systems, $exclude-hardcoded),
683
- custom-tokens.mdc-linear-progress-color-variants($systems, $exclude-hardcoded),
684
- ),
685
- $token-slots
686
- ),
687
- _namespace-tokens(
688
- (mdc, list),
689
- _fix-list-tokens(
690
- mdc-tokens.md-comp-list-values($systems, $exclude-hardcoded)
691
- ),
692
- $token-slots
693
- ),
694
- _namespace-tokens(
695
- (mdc, outlined-card),
696
- mdc-tokens.md-comp-outlined-card-values($systems, $exclude-hardcoded),
697
- $token-slots
698
- ),
699
- _namespace-tokens(
700
- (mdc, outlined-text-field),
701
- (
702
- _fix-outlined-text-field-tokens(
703
- mdc-tokens.md-comp-outlined-text-field-values($systems, $exclude-hardcoded)
704
- ),
705
- _map-values(
706
- custom-tokens.mdc-outlined-text-field-color-variants($systems, $exclude-hardcoded),
707
- meta.get-function(_fix-outlined-text-field-tokens)
708
- )
709
- ),
710
- $token-slots
711
- ),
712
- _namespace-tokens(
713
- (mdc, plain-tooltip),
714
- mdc-tokens.md-comp-plain-tooltip-values($systems, $exclude-hardcoded),
715
- $token-slots
716
- ),
717
- _namespace-tokens(
718
- (mdc, radio),
719
- (
720
- mdc-tokens.md-comp-radio-button-values($systems, $exclude-hardcoded),
721
- custom-tokens.mdc-radio-color-variants($systems, $exclude-hardcoded)
722
- ),
723
- $token-slots
724
- ),
725
- _namespace-tokens(
726
- (mdc, slider),
727
- (
728
- mdc-tokens.md-comp-slider-values($systems, $exclude-hardcoded),
729
- custom-tokens.mdc-slider-color-variants($systems, $exclude-hardcoded)
730
- ),
731
- $token-slots
732
- ),
733
- _namespace-tokens(
734
- (mdc, snackbar),
735
- mdc-tokens.md-comp-snackbar-values($systems, $exclude-hardcoded),
736
- $token-slots,
737
- ),
738
- _namespace-tokens(
739
- (mdc, switch),
740
- (
741
- mdc-tokens.md-comp-switch-values($systems, $exclude-hardcoded),
742
- custom-tokens.mdc-switch-color-variants($systems, $exclude-hardcoded)
743
- ),
744
- $token-slots
745
- ),
746
- _namespace-tokens(
747
- (mdc, tab),
748
- mdc-tokens.md-comp-secondary-navigation-tab-values($systems, $exclude-hardcoded),
749
- $token-slots
750
- ),
751
-
752
- // Choose values for our made up tokens based on MDC system tokens or sensible hardcoded
753
- // values.
754
- _namespace-tokens(
755
- (mat, app),
756
- custom-tokens.app($systems, $exclude-hardcoded),
757
- $token-slots
758
- ),
759
- _namespace-tokens(
760
- (mdc, tab-indicator),
761
- custom-tokens.tab-indicator($systems, $exclude-hardcoded),
762
- $token-slots
763
- ),
764
- _namespace-tokens(
765
- (mat, autocomplete),
766
- custom-tokens.autocomplete($systems, $exclude-hardcoded),
767
- $token-slots
768
- ),
769
- _namespace-tokens(
770
- (mat, badge),
771
- custom-tokens.badge($systems, $exclude-hardcoded),
772
- $token-slots
773
- ),
774
- _namespace-tokens(
775
- (mat, bottom-sheet),
776
- custom-tokens.bottom-sheet($systems, $exclude-hardcoded),
777
- $token-slots
778
- ),
779
- _namespace-tokens(
780
- (mat, card),
781
- custom-tokens.card($systems, $exclude-hardcoded),
782
- $token-slots
783
- ),
784
- _namespace-tokens(
785
- (mat, chip),
786
- custom-tokens.chip($systems, $exclude-hardcoded),
787
- $token-slots
788
- ),
789
- _namespace-tokens(
790
- (mat, datepicker),
791
- custom-tokens.datepicker($systems, $exclude-hardcoded),
792
- $token-slots
793
- ),
794
- _namespace-tokens(
795
- (mat, dialog),
796
- custom-tokens.dialog($systems, $exclude-hardcoded),
797
- $token-slots
798
- ),
799
- _namespace-tokens(
800
- (mat, divider),
801
- custom-tokens.divider($systems, $exclude-hardcoded),
802
- $token-slots
803
- ),
804
- _namespace-tokens(
805
- (mat, fab),
806
- custom-tokens.fab($systems, $exclude-hardcoded),
807
- $token-slots
808
- ),
809
- _namespace-tokens(
810
- (mat, fab-small),
811
- custom-tokens.fab-small($systems, $exclude-hardcoded),
812
- $token-slots
813
- ),
814
- _namespace-tokens(
815
- (mat, form-field),
816
- custom-tokens.form-field($systems, $exclude-hardcoded),
817
- $token-slots
818
- ),
819
- _namespace-tokens(
820
- (mat, expansion),
821
- custom-tokens.expansion($systems, $exclude-hardcoded),
822
- $token-slots
823
- ),
824
- _namespace-tokens(
825
- (mat, grid-list),
826
- custom-tokens.grid-list($systems, $exclude-hardcoded),
827
- $token-slots
828
- ),
829
- _namespace-tokens(
830
- (mat, icon),
831
- custom-tokens.icon($systems, $exclude-hardcoded),
832
- $token-slots
833
- ),
834
- _namespace-tokens(
835
- (mat, text-button),
836
- custom-tokens.text-button($systems, $exclude-hardcoded),
837
- $token-slots
838
- ),
839
- _namespace-tokens(
840
- (mat, filled-button),
841
- custom-tokens.filled-button($systems, $exclude-hardcoded),
842
- $token-slots
843
- ),
844
- _namespace-tokens(
845
- (mat, list),
846
- custom-tokens.list($systems, $exclude-hardcoded),
847
- $token-slots
848
- ),
849
- _namespace-tokens(
850
- // Note: in M3 the "protected" button is called "elevated".
851
- (mat, protected-button),
852
- custom-tokens.elevated-button($systems, $exclude-hardcoded),
853
- $token-slots
854
- ),
855
- _namespace-tokens(
856
- (mat, outlined-button),
857
- custom-tokens.outlined-button($systems, $exclude-hardcoded),
858
- $token-slots
859
- ),
860
- _namespace-tokens(
861
- (mat, icon-button),
862
- custom-tokens.icon-button($systems, $exclude-hardcoded),
863
- $token-slots
864
- ),
865
- _namespace-tokens(
866
- (mat, menu),
867
- custom-tokens.menu($systems, $exclude-hardcoded),
868
- $token-slots
869
- ),
870
- _namespace-tokens(
871
- (mat, optgroup),
872
- custom-tokens.optgroup($systems, $exclude-hardcoded),
873
- $token-slots
874
- ),
875
- _namespace-tokens(
876
- (mat, option),
877
- custom-tokens.option($systems, $exclude-hardcoded),
878
- $token-slots
879
- ),
880
- _namespace-tokens(
881
- (mat, paginator),
882
- custom-tokens.paginator($systems, $exclude-hardcoded),
883
- $token-slots
884
- ),
885
- _namespace-tokens(
886
- (mat, full-pseudo-checkbox),
887
- custom-tokens.full-pseudo-checkbox($systems, $exclude-hardcoded),
888
- $token-slots
889
- ),
890
- _namespace-tokens(
891
- (mat, minimal-pseudo-checkbox),
892
- custom-tokens.minimal-pseudo-checkbox($systems, $exclude-hardcoded),
893
- $token-slots
894
- ),
895
- _namespace-tokens(
896
- (mat, checkbox),
897
- custom-tokens.checkbox($systems, $exclude-hardcoded),
898
- $token-slots
899
- ),
900
- _namespace-tokens(
901
- (mat, radio),
902
- custom-tokens.radio($systems, $exclude-hardcoded),
903
- $token-slots
904
- ),
905
- _namespace-tokens(
906
- (mat, ripple),
907
- custom-tokens.ripple($systems, $exclude-hardcoded),
908
- $token-slots
909
- ),
910
- _namespace-tokens(
911
- (mat, select),
912
- custom-tokens.select($systems, $exclude-hardcoded),
913
- $token-slots
914
- ),
915
- _namespace-tokens(
916
- (mat, sidenav),
917
- custom-tokens.sidenav($systems, $exclude-hardcoded),
918
- $token-slots
919
- ),
920
- _namespace-tokens(
921
- (mat, slider),
922
- custom-tokens.slider($systems, $exclude-hardcoded),
923
- $token-slots
924
- ),
925
- _namespace-tokens(
926
- (mat, snack-bar),
927
- custom-tokens.snack-bar($systems, $exclude-hardcoded),
928
- $token-slots
929
- ),
930
- _namespace-tokens(
931
- (mat, sort),
932
- custom-tokens.sort($systems, $exclude-hardcoded),
933
- $token-slots
934
- ),
935
- _namespace-tokens(
936
- (mat, standard-button-toggle),
937
- custom-tokens.button-toggle($systems, $exclude-hardcoded),
938
- $token-slots
939
- ),
940
- _namespace-tokens(
941
- (mat, stepper),
942
- custom-tokens.stepper($systems, $exclude-hardcoded),
943
- $token-slots
944
- ),
945
- _namespace-tokens(
946
- (mat, switch),
947
- custom-tokens.switch($systems, $exclude-hardcoded),
948
- $token-slots
949
- ),
950
- _namespace-tokens(
951
- (mat, tab-header),
952
- custom-tokens.tab-header($systems, $exclude-hardcoded),
953
- $token-slots
954
- ),
955
- _namespace-tokens(
956
- (mat, table),
957
- custom-tokens.table($systems, $exclude-hardcoded),
958
- $token-slots
959
- ),
960
- _namespace-tokens(
961
- (mat, toolbar),
962
- custom-tokens.toolbar($systems, $exclude-hardcoded),
963
- $token-slots,
964
- ),
965
- _namespace-tokens(
966
- (mat, tree),
967
- custom-tokens.tree($systems, $exclude-hardcoded),
968
- $token-slots
969
- ),
970
- );
971
-
972
- // Strip out tokens that are systemized by our made up density system.
973
- @each $namespace, $tokens in $result {
974
- @each $token, $value in $tokens {
975
- @if m3-density.is-systemized($namespace, $token) {
976
- $tokens: map.remove($tokens, $token);
977
- }
978
- }
979
- $result: map.set($result, $namespace, $tokens);
980
- }
981
- @return $result;
982
- }
983
-
984
- /// Generates a set of namespaced color tokens for all components.
985
- /// @param {String} $type The type of theme system (light or dark)
986
- /// @param {Map} $primary The primary palette
987
- /// @param {Map} $tertiary The tertiary palette
988
- /// @param {Map} $error The error palette
989
- /// @return {Map} A map of namespaced color tokens
990
- @function generate-color-tokens($type, $primary, $tertiary, $error) {
991
- $ref: (
992
- md-ref-palette: _generate-ref-palette-tokens($primary, $tertiary, $error)
993
- );
994
- $sys-color: if($type == dark,
995
- mdc-tokens.md-sys-color-values-dark($ref),
996
- mdc-tokens.md-sys-color-values-light($ref));
997
- @return _generate-tokens(map.merge($ref, (
998
- md-sys-color: $sys-color,
999
- // Because the elevation values are always combined with color values to create the box shadow,
1000
- // elevation needs to be part of the color dimension.
1001
- md-sys-elevation: mdc-tokens.md-sys-elevation-values(),
1002
- // Because the state values are sometimes combined with color values to create rgba colors,
1003
- // state needs to be part of color dimension.
1004
- // TODO(mmalerba): If at some point we remove the need for these combined values, we can move
1005
- // state to the base dimension.
1006
- md-sys-state: mdc-tokens.md-sys-state-values(),
1007
- )));
1008
- }
1009
-
1010
- /// Generates a set of namespaced color tokens for all components.
1011
- /// @param {String|List} $brand The brand font-family
1012
- /// @param {String|List} $plain The plain fort-family
1013
- /// @param {String|Number} $bold The bold font-weight
1014
- /// @param {String|Number} $medium The medium font-weight
1015
- /// @param {String|Number} $regular The regular font-weight
1016
- /// @return {Map} A map of namespaced typography tokens
1017
- @function generate-typography-tokens($brand, $plain, $bold, $medium, $regular) {
1018
- $ref: (
1019
- md-ref-typeface: _generate-ref-typeface-tokens($brand, $plain, $bold, $medium, $regular)
1020
- );
1021
- @return _generate-tokens((
1022
- md-sys-typescale: mdc-tokens.md-sys-typescale-values($ref)
1023
- ));
1024
- }
1025
-
1026
- /// Generates a set of namespaced density tokens for all components.
1027
- /// @param {String|Number} $scale The regular font-weight
1028
- /// @return {Map} A map of namespaced density tokens
1029
- @function generate-density-tokens($scale) {
1030
- @return m3-density.get-tokens-for-scale($scale);
1031
- }
1032
-
1033
- /// Generates a set of namespaced tokens not related to color, typography, or density for all
1034
- /// components.
1035
- /// @return {Map} A map of namespaced tokens not related to color, typography, or density
1036
- @function generate-base-tokens() {
1037
- // TODO(mmalerba): Exclude density tokens once implemented.
1038
- @return _generate-tokens((
1039
- md-sys-motion: mdc-tokens.md-sys-motion-values(),
1040
- md-sys-shape: mdc-tokens.md-sys-shape-values(),
1041
- ), $include-non-systemized: true);
1042
- }