@angular/material-experimental 16.2.0-next.3 → 16.2.0-next.5

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.
package/_index.scss CHANGED
@@ -5,8 +5,9 @@
5
5
  popover-edit-typography, popover-edit-density, popover-edit-theme;
6
6
 
7
7
  // Token-based theming API
8
- @forward './theming/theming' show theme, retheme;
8
+ @forward './theming/theming' show theme, token-defaults;
9
9
  @forward './theming/checkbox' show checkbox;
10
10
  @forward './theming/card' show card;
11
+ @forward './theming/m3-tokens' show get-m3-tokens;
11
12
 
12
13
  // Additional public APIs for individual components
@@ -7,5 +7,5 @@
7
7
  */
8
8
  import { Version } from '@angular/core';
9
9
  /** Current version of the Material experimental package. */
10
- export const VERSION = new Version('16.2.0-next.3');
10
+ export const VERSION = new Version('16.2.0-next.5');
11
11
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC1leHBlcmltZW50YWwvdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQUMsT0FBTyxFQUFDLE1BQU0sZUFBZSxDQUFDO0FBRXRDLDREQUE0RDtBQUM1RCxNQUFNLENBQUMsTUFBTSxPQUFPLEdBQUcsSUFBSSxPQUFPLENBQUMsbUJBQW1CLENBQUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQGxpY2Vuc2VcbiAqIENvcHlyaWdodCBHb29nbGUgTExDIEFsbCBSaWdodHMgUmVzZXJ2ZWQuXG4gKlxuICogVXNlIG9mIHRoaXMgc291cmNlIGNvZGUgaXMgZ292ZXJuZWQgYnkgYW4gTUlULXN0eWxlIGxpY2Vuc2UgdGhhdCBjYW4gYmVcbiAqIGZvdW5kIGluIHRoZSBMSUNFTlNFIGZpbGUgYXQgaHR0cHM6Ly9hbmd1bGFyLmlvL2xpY2Vuc2VcbiAqL1xuXG5pbXBvcnQge1ZlcnNpb259IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuXG4vKiogQ3VycmVudCB2ZXJzaW9uIG9mIHRoZSBNYXRlcmlhbCBleHBlcmltZW50YWwgcGFja2FnZS4gKi9cbmV4cG9ydCBjb25zdCBWRVJTSU9OID0gbmV3IFZlcnNpb24oJzAuMC4wLVBMQUNFSE9MREVSJyk7XG4iXX0=
@@ -1,7 +1,7 @@
1
1
  import { Version } from '@angular/core';
2
2
 
3
3
  /** Current version of the Material experimental package. */
4
- const VERSION = new Version('16.2.0-next.3');
4
+ const VERSION = new Version('16.2.0-next.5');
5
5
 
6
6
  export { VERSION };
7
7
  //# sourceMappingURL=material-experimental.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"material-experimental.mjs","sources":["../../../../../../src/material-experimental/version.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Material experimental package. */\nexport const VERSION = new Version('16.2.0-next.3');\n"],"names":[],"mappings":";;AAUA;MACa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;;;"}
1
+ {"version":3,"file":"material-experimental.mjs","sources":["../../../../../../src/material-experimental/version.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Material experimental package. */\nexport const VERSION = new Version('16.2.0-next.5');\n"],"names":[],"mappings":";;AAUA;MACa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/material-experimental",
3
- "version": "16.2.0-next.3",
3
+ "version": "16.2.0-next.5",
4
4
  "description": "Experimental components for Angular Material",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,12 +49,12 @@
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@angular/animations": "^16.0.0-0 || ^16.1.0-0 || ^16.2.0-0 || ^16.3.0-0 || ^17.0.0-0",
52
- "@angular/cdk": "16.2.0-next.3",
52
+ "@angular/cdk": "16.2.0-next.5",
53
53
  "@angular/core": "^16.0.0-0 || ^16.1.0-0 || ^16.2.0-0 || ^16.3.0-0 || ^17.0.0-0",
54
54
  "@angular/common": "^16.0.0-0 || ^16.1.0-0 || ^16.2.0-0 || ^16.3.0-0 || ^17.0.0-0",
55
55
  "@angular/forms": "^16.0.0-0 || ^16.1.0-0 || ^16.2.0-0 || ^16.3.0-0 || ^17.0.0-0",
56
56
  "@angular/platform-browser": "^16.0.0-0 || ^16.1.0-0 || ^16.2.0-0 || ^16.3.0-0 || ^17.0.0-0",
57
- "@angular/material": "16.2.0-next.3"
57
+ "@angular/material": "16.2.0-next.5"
58
58
  },
59
59
  "dependencies": {
60
60
  "tslib": "^2.3.0",
@@ -0,0 +1,146 @@
1
+ @use 'sass:map';
2
+ @use '@angular/material' as mat;
3
+ @use '@material/tokens/v0_161' as mdc-tokens;
4
+
5
+ /// Picks a submap containing only the given keys out the given map.
6
+ /// @param {Map} $map The map to pick from.
7
+ /// @param {List} $keys The map keys to pick.
8
+ /// @return {Map} A submap containing only the given keys.
9
+ @function _pick($map, $keys) {
10
+ $result: ();
11
+ @each $key in $keys {
12
+ @if map.has-key($map, $key) {
13
+ $result: map.set($result, $key, map.get($map, $key));
14
+ }
15
+ }
16
+ @return $result;
17
+ }
18
+
19
+ /// Filters keys with a null value out of the map.
20
+ /// @param {Map} $map The map to filter.
21
+ /// @return {Map} The given map with all of the null keys filtered out.
22
+ @function _filter-nulls($map) {
23
+ $result: ();
24
+ @each $key, $val in $map {
25
+ @if $val != null {
26
+ $result: map.set($result, $key, $val);
27
+ }
28
+ }
29
+ @return $result;
30
+ }
31
+
32
+ /// Gets the MDC tokens for the given prefix, M3 token values, and supported token slots.
33
+ /// @param {List} $prefix The token prefix for the given tokens.
34
+ /// @param {Map} $m3-values A map of M3 token values for the given prefix.
35
+ /// @param {Map} $slots A map of token slots, with null value indicating the token is not supported.
36
+ /// @return {Map} A map of fully qualified token names to values, for only the supported tokens.
37
+ @function _get-mdc-tokens($prefix, $m3-values, $slots) {
38
+ $used-token-names: map.keys(_filter-nulls(map.get($slots, $prefix)));
39
+ $used-m3-tokens: _pick($m3-values, $used-token-names);
40
+ @return (
41
+ $prefix: $used-m3-tokens,
42
+ );
43
+ }
44
+
45
+ /// Sets all of the standard typography tokens for the given token base name to the given typography
46
+ /// level.
47
+ /// @param {Map} $typography-tokens The MDC system-typescale tokens.
48
+ /// @param {String} $base-name The token base name to get the typography tokens for
49
+ /// @param {String} $typography-level The typography level to base the token values on.
50
+ /// @return {Map} A map containing the typography tokens for the given base token name.
51
+ @function _get-typography-tokens($typography-tokens, $base-name, $typography-level) {
52
+ $result: ();
53
+ @each $prop in (font, line-height, size, tracking, weight) {
54
+ $result: map.set(
55
+ $result,
56
+ #{$base-name}-#{$prop},
57
+ map.get($typography-tokens, #{$typography-level}-#{$prop}
58
+ ));
59
+ }
60
+ @return $result;
61
+ }
62
+
63
+ /// Renames the keys in a map
64
+ /// @param {Map} $map The map whose keys should be renamed
65
+ /// @param {Map} $rename-keys A map of original key to renamed key to apply to $map
66
+ /// @return {Map} The result of applying the given key renames to the given map.
67
+ @function _rename-map-keys($map, $rename-keys) {
68
+ $result: $map;
69
+ @each $old-key-name, $new-key-name in $rename-keys {
70
+ @if map.has-key($map, $old-key-name) {
71
+ $result: map.set($result, $new-key-name, map.get($map, $old-key-name));
72
+ }
73
+ }
74
+ @return $result;
75
+ }
76
+
77
+ /// Renames the official checkbox tokens to match the names actually used in MDC's code (which are
78
+ /// different). This is a temporary workaround until MDC updates to use the correct names for the
79
+ /// tokens.
80
+ /// @param {Map} $tokens The map of checkbox tokens with the official tokens names
81
+ /// @return {Map} The given tokens, renamed to be compatible with MDC's token implementation.
82
+ @function _fix-checkbox-token-names($tokens) {
83
+ $rename-keys: (
84
+ 'selected-icon-color': 'selected-checkmark-color',
85
+ 'selected-disabled-icon-color': 'disabled-selected-checkmark-color',
86
+ 'selected-container-color': 'selected-icon-color',
87
+ 'selected-hover-container-color': 'selected-hover-icon-color',
88
+ 'selected-disabled-container-color': 'disabled-selected-icon-color',
89
+ 'selected-disabled-container-opacity': 'disabled-selected-icon-opacity',
90
+ 'selected-focus-container-color': 'selected-focus-icon-color',
91
+ 'selected-pressed-container-color': 'selected-pressed-icon-color',
92
+ 'unselected-disabled-outline-color': 'disabled-unselected-icon-color',
93
+ 'unselected-disabled-container-opacity': 'disabled-unselected-icon-opacity',
94
+ 'unselected-focus-outline-color': 'unselected-focus-icon-color',
95
+ 'unselected-hover-outline-color': 'unselected-hover-icon-color',
96
+ 'unselected-outline-color': 'unselected-icon-color',
97
+ 'unselected-pressed-outline-color': 'unselected-pressed-icon-color'
98
+ );
99
+ @return _rename-map-keys($tokens, $rename-keys);
100
+ }
101
+
102
+ // TODO(mmalerba): We need a way to accept custom M3 token values generated from MDCs theme builder
103
+ // or other means. We can't just use them directly without processing them first because we need to
104
+ // add our made up tokens,
105
+ /// Gets the default token values for M3.
106
+ /// @return The default set of M3 tokens.
107
+ @function get-m3-tokens() {
108
+ $typography: mdc-tokens.md-sys-typescale-values();
109
+ $colors: mdc-tokens.md-sys-color-values-light();
110
+
111
+ // TODO(mmalerba): Refactor this to not depend on the legacy theme. This is a hack for now because
112
+ // there is no good way to get the token slots in material-experimental without exposing them all
113
+ // from material.
114
+ $fake-theme: mat.define-light-theme((
115
+ color: (
116
+ primary: mat.define-palette(mat.$red-palette),
117
+ accent: mat.define-palette(mat.$red-palette),
118
+ warn: mat.define-palette(mat.$red-palette),
119
+ ),
120
+ typography: mat.define-typography-config(),
121
+ density: 0
122
+ ));
123
+ $token-slots: mat.m2-tokens-from-theme($fake-theme);
124
+
125
+ // TODO(mmalerba): Fill in remaining tokens.
126
+ @return mat.private-merge-all(
127
+ // Fill in official MDC tokens.
128
+ _get-mdc-tokens((mdc, checkbox),
129
+ _fix-checkbox-token-names(mdc-tokens.md-comp-checkbox-values()), $token-slots),
130
+ _get-mdc-tokens((mdc, elevated-card), mdc-tokens.md-comp-elevated-card-values(),
131
+ $token-slots),
132
+ _get-mdc-tokens((mdc, outlined-card), mdc-tokens.md-comp-outlined-card-values(),
133
+ $token-slots),
134
+ // Choose values for our made up tokens based on MDC system tokens or sensible hardcoded
135
+ // values.
136
+ (
137
+ (mat, card): mat.private-merge-all(
138
+ _get-typography-tokens($typography, title-text, title-large),
139
+ _get-typography-tokens($typography, subtitle-text, title-medium),
140
+ (
141
+ subtitle-text-color: map.get($colors, on-surface)
142
+ )
143
+ )
144
+ ),
145
+ );
146
+ }
@@ -88,27 +88,43 @@ $_error-on-missing-dep: false;
88
88
  }
89
89
  }
90
90
 
91
- /// Takes the full list of tokens and a list of components to configure, and outputs all theme
92
- /// tokens for the configured components.
93
- /// @param {Map} $tokens A map of all tokens for the current design system.
91
+ /// Takes a list of components to configure, and outputs theme tokens for the configured components.
94
92
  /// @param {List} $components The list of component configurations to emit tokens for.
95
93
  /// @output CSS variables representing the theme tokens for the given component configs.
96
- // TODO(mmalerba): Consider an alternate API where `$tokens` is not a separate argument,
97
- // but one of the configs in the `$components` list
98
- @mixin theme($tokens, $components) {
99
- @include _theme($tokens, _get-transitive-deps(mat.private-coerce-to-list($components)));
94
+ @mixin theme($components...) {
95
+ $filtered-components: ();
96
+ $tokens: null;
97
+ @each $component in $components {
98
+ @if (map.get($component, id) == 'mat.token-defaults') {
99
+ @if $tokens == null {
100
+ $tokens: map.get($component, tokens);
101
+ }
102
+ @else {
103
+ @error 'mat.token-defaults specified multiple times in call to mat.theme';
104
+ }
105
+ }
106
+ @else {
107
+ $filtered-components: list.append($filtered-components, $component);
108
+ }
109
+ }
110
+ $tokens: $tokens or ();
111
+ @if $tokens == () {
112
+ @each $component in $filtered-components {
113
+ @if (map.get($component, customizations) or ()) == () {
114
+ $component-id: map.get($component, id);
115
+ @warn 'Call to `#{$component-id}()` will produce no output, this is likely a mistake.' +
116
+ ' Did you mean to:'+
117
+ '\a 1. Provide default token values with `mat.token-defaults`?' +
118
+ '\a 2. Specify customizations in the call to `#{$component-id}`?';
119
+ }
120
+ }
121
+ }
122
+ @include _theme($tokens, $filtered-components);
100
123
  }
101
124
 
102
- /// Takes a list of components to configure, and outputs only the theme tokens that are explicitly
103
- /// customized by the configurations.
104
- /// @param {List} $components The list of component configurations to emit tokens for.
105
- /// @output CSS variables representing the theme tokens for the given component configs.
106
- // TODO(mmalerba): What should we call this?
107
- // - update-theme
108
- // - adjust-theme
109
- // - edit-theme
110
- // - override-theme
111
- // - retheme
112
- @mixin retheme($components) {
113
- @include _theme((), mat.private-coerce-to-list($components));
125
+ @function token-defaults($tokens) {
126
+ @return (
127
+ id: 'mat.token-defaults',
128
+ tokens: $tokens
129
+ );
114
130
  }