@ng-matero/extensions 18.1.3 → 18.2.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 (151) hide show
  1. package/alert/alert.scss +1 -1
  2. package/core/theming/_definition.scss +16 -5
  3. package/core/tokens/_m3-tokens.scss +311 -153
  4. package/core/tokens/_token-definition.scss +271 -0
  5. package/core/tokens/_token-utils.scss +70 -301
  6. package/core/tokens/m2/mdc/_plain-tooltip.scss +4 -4
  7. package/core/tokens/m2/mtx/_alert.scss +4 -4
  8. package/core/tokens/m2/mtx/_colorpicker.scss +4 -4
  9. package/core/tokens/m2/mtx/_datetimepicker.scss +4 -4
  10. package/core/tokens/m2/mtx/_drawer.scss +4 -4
  11. package/core/tokens/m2/mtx/_grid.scss +4 -4
  12. package/core/tokens/m2/mtx/_loader.scss +4 -4
  13. package/core/tokens/m2/mtx/_popover.scss +4 -4
  14. package/core/tokens/m2/mtx/_progress.scss +4 -4
  15. package/core/tokens/m2/mtx/_select.scss +4 -4
  16. package/core/tokens/m2/mtx/_split.scss +4 -4
  17. package/core/tokens/m3/mtx/_alert.scss +2 -2
  18. package/core/tokens/m3/mtx/_colorpicker.scss +2 -2
  19. package/core/tokens/m3/mtx/_datetimepicker.scss +6 -6
  20. package/core/tokens/m3/mtx/_drawer.scss +3 -3
  21. package/core/tokens/m3/mtx/_grid.scss +3 -3
  22. package/core/tokens/m3/mtx/_loader.scss +2 -2
  23. package/core/tokens/m3/mtx/_popover.scss +3 -3
  24. package/core/tokens/m3/mtx/_progress.scss +7 -6
  25. package/core/tokens/m3/mtx/_select.scss +4 -4
  26. package/core/tokens/m3/mtx/_split.scss +2 -2
  27. package/datetimepicker/calendar-body.scss +1 -1
  28. package/datetimepicker/calendar.scss +5 -5
  29. package/esm2022/alert/alert-module.mjs +4 -4
  30. package/esm2022/alert/alert.mjs +5 -5
  31. package/esm2022/button/button-loading.mjs +3 -3
  32. package/esm2022/button/button-module.mjs +4 -4
  33. package/esm2022/checkbox-group/checkbox-group-module.mjs +4 -4
  34. package/esm2022/checkbox-group/checkbox-group.mjs +5 -5
  35. package/esm2022/colorpicker/colorpicker-input.mjs +3 -3
  36. package/esm2022/colorpicker/colorpicker-module.mjs +4 -4
  37. package/esm2022/colorpicker/colorpicker-toggle.mjs +8 -8
  38. package/esm2022/colorpicker/colorpicker.mjs +6 -6
  39. package/esm2022/column-resize/column-resize-directives/column-resize-flex.mjs +3 -3
  40. package/esm2022/column-resize/column-resize-directives/column-resize.mjs +3 -3
  41. package/esm2022/column-resize/column-resize-module.mjs +4 -4
  42. package/esm2022/column-resize/column-resize-notifier.mjs +6 -6
  43. package/esm2022/column-resize/column-resize.mjs +3 -3
  44. package/esm2022/column-resize/column-size-store.mjs +3 -3
  45. package/esm2022/column-resize/event-dispatcher.mjs +3 -3
  46. package/esm2022/column-resize/overlay-handle.mjs +3 -3
  47. package/esm2022/column-resize/resizable.mjs +3 -3
  48. package/esm2022/column-resize/resize-strategy.mjs +9 -9
  49. package/esm2022/core/datetime/datetime.module.mjs +8 -8
  50. package/esm2022/core/datetime/native-datetime-adapter.mjs +3 -3
  51. package/esm2022/core/pipes/is-template-ref.pipe.mjs +3 -3
  52. package/esm2022/core/pipes/pipes.module.mjs +4 -4
  53. package/esm2022/core/pipes/to-observable.pipe.mjs +3 -3
  54. package/esm2022/datetimepicker/calendar-body.mjs +4 -4
  55. package/esm2022/datetimepicker/calendar.mjs +5 -5
  56. package/esm2022/datetimepicker/clock.mjs +4 -4
  57. package/esm2022/datetimepicker/datetimepicker-actions.mjs +12 -12
  58. package/esm2022/datetimepicker/datetimepicker-input.mjs +3 -3
  59. package/esm2022/datetimepicker/datetimepicker-intl.mjs +3 -3
  60. package/esm2022/datetimepicker/datetimepicker-module.mjs +4 -4
  61. package/esm2022/datetimepicker/datetimepicker-toggle.mjs +8 -8
  62. package/esm2022/datetimepicker/datetimepicker.mjs +8 -8
  63. package/esm2022/datetimepicker/month-view.mjs +3 -3
  64. package/esm2022/datetimepicker/multi-year-view.mjs +3 -3
  65. package/esm2022/datetimepicker/time.mjs +8 -8
  66. package/esm2022/datetimepicker/year-view.mjs +3 -3
  67. package/esm2022/dialog/dialog-container.mjs +3 -3
  68. package/esm2022/dialog/dialog-module.mjs +4 -4
  69. package/esm2022/dialog/dialog.mjs +3 -3
  70. package/esm2022/drawer/drawer-container.mjs +5 -5
  71. package/esm2022/drawer/drawer-module.mjs +4 -4
  72. package/esm2022/drawer/drawer.mjs +3 -3
  73. package/esm2022/grid/cell.mjs +4 -4
  74. package/esm2022/grid/column-menu.mjs +5 -5
  75. package/esm2022/grid/column-resize/column-resize-directives/column-resize-flex.mjs +3 -3
  76. package/esm2022/grid/column-resize/column-resize-directives/column-resize.mjs +3 -3
  77. package/esm2022/grid/column-resize/column-resize-module.mjs +8 -8
  78. package/esm2022/grid/column-resize/overlay-handle.mjs +3 -3
  79. package/esm2022/grid/column-resize/resizable-directives/resizable.mjs +3 -3
  80. package/esm2022/grid/column-resize/resize-strategy.mjs +3 -3
  81. package/esm2022/grid/expansion-toggle.mjs +3 -3
  82. package/esm2022/grid/grid-module.mjs +4 -4
  83. package/esm2022/grid/grid-pipes.mjs +21 -21
  84. package/esm2022/grid/grid-utils.mjs +3 -3
  85. package/esm2022/grid/grid.mjs +5 -5
  86. package/esm2022/grid/selectable-cell.mjs +3 -3
  87. package/esm2022/loader/loader-module.mjs +4 -4
  88. package/esm2022/loader/loader.mjs +5 -5
  89. package/esm2022/photoviewer/photoviewer-module.mjs +4 -4
  90. package/esm2022/photoviewer/photoviewer.mjs +3 -3
  91. package/esm2022/popover/popover-content.mjs +6 -6
  92. package/esm2022/popover/popover-module.mjs +4 -4
  93. package/esm2022/popover/popover-target.mjs +3 -3
  94. package/esm2022/popover/popover-trigger.mjs +5 -4
  95. package/esm2022/popover/popover.mjs +5 -5
  96. package/esm2022/progress/progress-module.mjs +4 -4
  97. package/esm2022/progress/progress.mjs +4 -4
  98. package/esm2022/select/option.mjs +3 -3
  99. package/esm2022/select/select-module.mjs +12 -8
  100. package/esm2022/select/select.mjs +9 -6
  101. package/esm2022/select/templates.mjs +45 -34
  102. package/esm2022/split/split-module.mjs +4 -4
  103. package/esm2022/split/split-pane.mjs +3 -3
  104. package/esm2022/split/split.mjs +4 -4
  105. package/esm2022/tooltip/tooltip-module.mjs +4 -4
  106. package/esm2022/tooltip/tooltip.mjs +6 -6
  107. package/fesm2022/mtxAlert.mjs +8 -8
  108. package/fesm2022/mtxAlert.mjs.map +1 -1
  109. package/fesm2022/mtxButton.mjs +7 -7
  110. package/fesm2022/mtxCheckboxGroup.mjs +8 -8
  111. package/fesm2022/mtxCheckboxGroup.mjs.map +1 -1
  112. package/fesm2022/mtxColorpicker.mjs +20 -20
  113. package/fesm2022/mtxColorpicker.mjs.map +1 -1
  114. package/fesm2022/mtxColumnResize.mjs +40 -40
  115. package/fesm2022/mtxCore.mjs +21 -21
  116. package/fesm2022/mtxDatetimepicker.mjs +64 -64
  117. package/fesm2022/mtxDatetimepicker.mjs.map +1 -1
  118. package/fesm2022/mtxDialog.mjs +10 -10
  119. package/fesm2022/mtxDrawer.mjs +11 -11
  120. package/fesm2022/mtxDrawer.mjs.map +1 -1
  121. package/fesm2022/mtxGrid.mjs +68 -68
  122. package/fesm2022/mtxGrid.mjs.map +1 -1
  123. package/fesm2022/mtxLoader.mjs +8 -8
  124. package/fesm2022/mtxLoader.mjs.map +1 -1
  125. package/fesm2022/mtxPhotoviewer.mjs +7 -7
  126. package/fesm2022/mtxPopover.mjs +21 -20
  127. package/fesm2022/mtxPopover.mjs.map +1 -1
  128. package/fesm2022/mtxProgress.mjs +8 -8
  129. package/fesm2022/mtxProgress.mjs.map +1 -1
  130. package/fesm2022/mtxSelect.mjs +65 -47
  131. package/fesm2022/mtxSelect.mjs.map +1 -1
  132. package/fesm2022/mtxSplit.mjs +11 -11
  133. package/fesm2022/mtxSplit.mjs.map +1 -1
  134. package/fesm2022/mtxTooltip.mjs +10 -10
  135. package/grid/column-menu.scss +3 -3
  136. package/grid/column-resize/_column-resize.scss +2 -2
  137. package/grid/grid.scss +8 -8
  138. package/loader/loader.scss +2 -2
  139. package/package.json +25 -13
  140. package/prebuilt-themes/azure-blue.css +1 -1
  141. package/prebuilt-themes/cyan-orange.css +1 -1
  142. package/prebuilt-themes/deeppurple-amber.css +1 -1
  143. package/prebuilt-themes/indigo-pink.css +1 -1
  144. package/prebuilt-themes/magenta-violet.css +1 -1
  145. package/prebuilt-themes/pink-bluegrey.css +1 -1
  146. package/prebuilt-themes/purple-green.css +1 -1
  147. package/prebuilt-themes/rose-red.css +1 -1
  148. package/select/select-module.d.ts +1 -1
  149. package/select/select.d.ts +2 -1
  150. package/select/select.scss +8 -8
  151. package/select/templates.d.ts +6 -0
@@ -0,0 +1,271 @@
1
+ @use 'sass:color';
2
+ @use 'sass:list';
3
+ @use 'sass:map';
4
+ @use 'sass:meta';
5
+ @use 'sass:math';
6
+ @use '@angular/material' as mat;
7
+ @use '../m2/typography' as m2-typography;
8
+ @use './m3/definitions' as m3-token-definitions;
9
+
10
+ // Indicates whether we're building internally. Used for backwards compatibility.
11
+ $private-is-internal-build: false;
12
+
13
+ $_placeholder-color-palette: mat.m2-define-palette(mat.$m2-red-palette);
14
+
15
+ // Placeholder color config that can be passed to token getter functions when generating token
16
+ // slots.
17
+ $placeholder-color-config: (
18
+ primary: $_placeholder-color-palette,
19
+ accent: $_placeholder-color-palette,
20
+ warn: $_placeholder-color-palette,
21
+ is-dark: false,
22
+ foreground: mat.$m2-light-theme-foreground-palette,
23
+ background: mat.$m2-light-theme-background-palette,
24
+ );
25
+
26
+ $_placeholder-typography-level-config: m2-typography.typography-config-level-from-mdc(body1);
27
+
28
+ // Placeholder typography config that can be passed to token getter functions when generating token
29
+ // slots.
30
+ $placeholder-typography-config: (
31
+ font-family: 'Roboto, sans-serif',
32
+ headline-1: $_placeholder-typography-level-config,
33
+ headline-2: $_placeholder-typography-level-config,
34
+ headline-3: $_placeholder-typography-level-config,
35
+ headline-4: $_placeholder-typography-level-config,
36
+ headline-5: $_placeholder-typography-level-config,
37
+ headline-6: $_placeholder-typography-level-config,
38
+ subtitle-1: $_placeholder-typography-level-config,
39
+ subtitle-2: $_placeholder-typography-level-config,
40
+ body-1: $_placeholder-typography-level-config,
41
+ body-2: $_placeholder-typography-level-config,
42
+ caption: $_placeholder-typography-level-config,
43
+ button: $_placeholder-typography-level-config,
44
+ overline: $_placeholder-typography-level-config,
45
+ subheading-1: $_placeholder-typography-level-config,
46
+ title: $_placeholder-typography-level-config,
47
+ );
48
+
49
+ // Placeholder density config that can be passed to token getter functions when generating token
50
+ // slots.
51
+ $placeholder-density-config: 0;
52
+
53
+ $_tokens: null;
54
+ $_component-prefix: null;
55
+ $_system-fallbacks: null;
56
+
57
+ /// Gets all the MDC token values for a specific component. This function serves as single
58
+ /// point at which we directly reference a specific version of the MDC tokens.
59
+ /// @param {String} $component Name of the component for which to get the tokens
60
+ /// @param {Map} $systems The MDC system tokens
61
+ /// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values
62
+ /// @return {List} Map of token names to values
63
+ @function get-mdc-tokens($component, $systems, $exclude-hardcoded) {
64
+ $full-name: 'md-comp-' + $component + '-values';
65
+ $fn: meta.get-function($name: $full-name, $module: 'm3-token-definitions');
66
+ @return meta.call($fn, $systems, $exclude-hardcoded);
67
+ }
68
+
69
+ /// Gets the MDC tokens for the given prefix, M3 token values, and supported token slots.
70
+ /// @param {List} $prefix The token prefix for the given tokens.
71
+ /// @param {Map|(Map, Map)} $values A map of M3 token values for the given prefix.
72
+ /// This param may also be a tuple of maps, the first one representing the default M3 token values,
73
+ // and the second containing overrides for different color variants.
74
+ // Single map example:
75
+ // (token1: green, token2: 2px)
76
+ // Tuple example:
77
+ // (
78
+ // (token1: green, token2: 2px),
79
+ // (
80
+ // secondary: (token1: blue),
81
+ // error: (token1: red),
82
+ // )
83
+ // )
84
+ /// @param {Map} $slots A map of token slots, with null value indicating the token is not supported.
85
+ /// @param {String|null} $variant The name of the variant the token values are for.
86
+ /// @return {Map} A map of fully qualified token names to values, for only the supported tokens.
87
+ @function namespace-tokens($prefix, $values, $slots, $variant: null) {
88
+ $result: ();
89
+ @if $variant == null and meta.type-of($values) == 'list' and list.length($values == 2) {
90
+ $variants: list.nth($values, 2);
91
+ $values: list.nth($values, 1);
92
+ @each $variant, $overrides in $variants {
93
+ $result: map.merge($result, namespace-tokens($prefix, $overrides, $slots, $variant));
94
+ }
95
+ }
96
+ $used-token-names: map.keys(_filter-nulls(map.get($slots, $prefix)));
97
+ $used-m3-tokens: _pick(_filter-nulls($values), $used-token-names);
98
+ $prefix: if($variant == null, $prefix, list.append($prefix, $variant));
99
+ @return map.merge($result, ($prefix: $used-m3-tokens));
100
+ }
101
+
102
+ /// Hardcode the given value, or null if hardcoded values are excluded.
103
+ @function hardcode($value, $exclude-hardcoded) {
104
+ @return if($exclude-hardcoded, null, $value);
105
+ }
106
+
107
+ /// Sets all of the standard typography tokens for the given token base name to the given typography
108
+ /// level.
109
+ /// @param {Map} $systems The MDC system tokens
110
+ /// @param {String} $base-name The token base name to get the typography tokens for
111
+ /// @param {String} $typography-level The typography level to base the token values on
112
+ /// @return {Map} A map containing the typography tokens for the given base token name
113
+ @function generate-typography-tokens($systems, $base-name, $typography-level) {
114
+ $result: ();
115
+ @each $prop in (font, line-height, size, tracking, weight) {
116
+ $result: map.set($result, #{$base-name}-#{$prop},
117
+ map.get($systems, md-sys-typescale, #{$typography-level}-#{$prop}));
118
+ }
119
+ @return $result;
120
+ }
121
+
122
+ /// Maps the values in a map to new values using the given mapping function
123
+ /// @param {Map} $map The maps whose values will be mapped to new values.
124
+ /// @param {Function} $fn The value mapping function.
125
+ /// @param {Map} A new map with its values updated using the mapping function.
126
+ /* stylelint-disable-next-line scss/no-global-function-names */
127
+ @function map-values($map, $fn) {
128
+ $result: ();
129
+ @each $key, $value in $map {
130
+ $result: map.set($result, $key, meta.call($fn, $value));
131
+ }
132
+ @return $result;
133
+ }
134
+
135
+ /// Renames the keys in a map
136
+ /// @param {Map} $map The map whose keys should be renamed
137
+ /// @param {Map} $rename-keys A map of original key to renamed key to apply to $map
138
+ /// @return {Map} The result of applying the given key renames to the given map.
139
+ @function rename-map-keys($map, $rename-keys) {
140
+ $result: $map;
141
+ @each $old-key-name, $new-key-name in $rename-keys {
142
+ @if map.has-key($map, $old-key-name) {
143
+ $result: map.set($result, $new-key-name, map.get($map, $old-key-name));
144
+ }
145
+ }
146
+ @return $result;
147
+ }
148
+
149
+ /// At the time of writing, some color tokens (e.g. disabled state) are defined as a solid color
150
+ /// token and a separate opacity token. This function applies the opacity to the color and drops the
151
+ /// opacity key from the map. Can be removed once b/213331407 is resolved.
152
+ /// @param {Map} $tokens The map of tokens currently being generated
153
+ /// @param {Map} $all-tokens A map of all tokens, including hardcoded values
154
+ /// @param {List} $pairs Pairs of color token names and their opacities. Should be in the shape of
155
+ /// `((color: 'color-key', opacity: 'opacity-key'))`.
156
+ /// @return {Map} The initial tokens with the combined color values.
157
+ @function combine-color-tokens($tokens, $opacity-lookup, $pairs) {
158
+ $result: $tokens;
159
+
160
+ @each $pair in $pairs {
161
+ $color-key: map.get($pair, color);
162
+ $opacity-key: map.get($pair, opacity);
163
+ $color: map.get($tokens, $color-key);
164
+
165
+ @if (mat.private-is-css-var-name($color)) {
166
+ $color: var(#{$color});
167
+ }
168
+
169
+ $opacity: map.get($opacity-lookup, $opacity-key);
170
+
171
+ @if(meta.type-of($color) == 'color') {
172
+ $result: map.remove($result, $opacity-key);
173
+ $result: map.set($result, $color-key, rgba($color, $opacity));
174
+ }
175
+ @else if($color != null) {
176
+ $result: map.remove($result, $opacity-key);
177
+ $combined-color: #{color-mix(in srgb, #{$color} #{($opacity * 100) + '%'}, transparent)};
178
+ $result: map.set($result, $color-key, $combined-color);
179
+ }
180
+ }
181
+
182
+ @return $result;
183
+ }
184
+
185
+ /// Inherited function from MDC that computes which contrast tone to use on top of a color.
186
+ /// This is used only in a narrow set of use cases when generating M2 button tokens to maintain
187
+ /// backwards compatibility.
188
+ /// @param {Color} $value Color for which we're calculating the contrast tone.
189
+ /// @param {Boolean} $is-dark Whether the current theme is dark.
190
+ /// @return {Map} Either `dark` or `light`.
191
+ @function contrast-tone($value, $is-dark) {
192
+ @if ($value == 'dark') {
193
+ @return 'light';
194
+ }
195
+
196
+ @if ($value == 'light') {
197
+ @return 'dark';
198
+ }
199
+
200
+ // Fallback if the app is using a non-color palette (e.g. CSS variable based).
201
+ @if (meta.type-of($value) != 'color') {
202
+ @return if($is-dark, 'light', 'dark');
203
+ }
204
+
205
+ $minimum-contrast: 3.1;
206
+ $light-contrast: _contrast($value, #fff);
207
+ $dark-contrast: _contrast($value, rgba(0, 0, 0, 0.87));
208
+
209
+ @if ($light-contrast < $minimum-contrast) and ($dark-contrast > $light-contrast) {
210
+ @return 'dark';
211
+ }
212
+
213
+ @return 'light';
214
+ }
215
+
216
+ @function _linear-channel-value($channel-value) {
217
+ $normalized-channel-value: math.div($channel-value, 255);
218
+
219
+ @if ($normalized-channel-value < 0.03928) {
220
+ @return math.div($normalized-channel-value, 12.92);
221
+ }
222
+
223
+ @return math.pow(math.div($normalized-channel-value + 0.055, 1.055), 2.4);
224
+ }
225
+
226
+ // Calculate the luminance for a color.
227
+ // See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
228
+ @function _luminance($color) {
229
+ $red: _linear-channel-value(color.red($color));
230
+ $green: _linear-channel-value(color.green($color));
231
+ $blue: _linear-channel-value(color.blue($color));
232
+
233
+ @return 0.2126 * $red + 0.7152 * $green + 0.0722 * $blue;
234
+ }
235
+
236
+ // Calculate the contrast ratio between two colors.
237
+ // See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
238
+ @function _contrast($back, $front) {
239
+ $back-lum: _luminance($back) + 0.05;
240
+ $fore-lum: _luminance($front) + 0.05;
241
+
242
+ @return math.div(math.max($back-lum, $fore-lum), math.min($back-lum, $fore-lum));
243
+ }
244
+
245
+ /// Picks a submap containing only the given keys out the given map.
246
+ /// @param {Map} $map The map to pick from.
247
+ /// @param {List} $keys The map keys to pick.
248
+ /// @return {Map} A submap containing only the given keys.
249
+ @function _pick($map, $keys) {
250
+ $result: ();
251
+ @each $key in $keys {
252
+ @if map.has-key($map, $key) {
253
+ $result: map.set($result, $key, map.get($map, $key));
254
+ }
255
+ }
256
+ @return $result;
257
+ }
258
+
259
+
260
+ /// Filters keys with a null value out of the map.
261
+ /// @param {Map} $map The map to filter.
262
+ /// @return {Map} The given map with all of the null keys filtered out.
263
+ @function _filter-nulls($map) {
264
+ $result: ();
265
+ @each $key, $val in $map {
266
+ @if $val != null {
267
+ $result: map.set($result, $key, $val);
268
+ }
269
+ }
270
+ @return $result;
271
+ }