@angular/material 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.
- package/_index.scss +67 -60
- package/autocomplete/_autocomplete-theme.scss +7 -0
- package/autocomplete/index.d.ts +4 -12
- package/badge/_badge-theme.scss +9 -0
- package/bottom-sheet/_bottom-sheet-theme.scss +7 -0
- package/button/_button-theme.scss +25 -0
- package/button/_fab-theme.scss +13 -0
- package/button/_icon-button-theme.scss +8 -0
- package/button-toggle/_button-toggle-theme.scss +12 -0
- package/card/_card-theme.scss +9 -0
- package/checkbox/_checkbox-theme.scss +2 -4
- package/chips/_chips-theme.scss +10 -0
- package/core/_core-theme.scss +17 -0
- package/core/m2/_index.scss +52 -0
- package/core/m2/_theming.scss +295 -0
- package/core/{typography/_property-getters.scss → m2/_typography-utils.scss} +14 -0
- package/core/{typography/_definition.scss → m2/_typography.scss} +1 -1
- package/core/option/_optgroup-theme.scss +7 -0
- package/core/option/_option-theme.scss +9 -0
- package/core/ripple/_ripple-theme.scss +7 -0
- package/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss +13 -0
- package/core/style/_sass-utils.scss +14 -1
- package/core/theming/_color-api-backwards-compatibility.scss +128 -0
- package/core/theming/_config-validation.scss +173 -0
- package/core/theming/_definition.scss +113 -0
- package/core/theming/_m2-inspection.scss +23 -22
- package/core/theming/_palettes.scss +947 -0
- package/core/theming/_theming-deprecated.scss +9 -9
- package/core/theming/_theming.scss +73 -339
- package/core/tokens/_custom-tokens.scss +1918 -0
- package/core/tokens/_density.scss +191 -0
- package/core/tokens/_format-tokens.scss +5 -0
- package/core/tokens/_m3-tokens.scss +1252 -0
- package/core/tokens/_token-utils.scss +39 -49
- package/core/tokens/m2/mat/_chip.scss +3 -3
- package/core/tokens/m2/mat/_form-field.scss +3 -3
- package/core/tokens/m2/mdc/_checkbox.scss +3 -2
- package/core/tokens/m2/mdc/_chip.scss +3 -3
- package/core/tokens/m2/mdc/_radio.scss +3 -2
- package/core/typography/_all-typography.scss +3 -2
- package/core/typography/_typography-utils.scss +0 -26
- package/core/typography/_typography.scss +0 -2
- package/core/typography/_versioning.scss +3 -3
- package/datepicker/_datepicker-theme.scss +9 -0
- package/datepicker/index.d.ts +6 -4
- package/dialog/_dialog-theme.scss +8 -0
- package/divider/_divider-theme.scss +7 -0
- package/esm2022/autocomplete/autocomplete-origin.mjs +3 -3
- package/esm2022/autocomplete/autocomplete-trigger.mjs +13 -7
- package/esm2022/autocomplete/autocomplete.mjs +7 -36
- package/esm2022/autocomplete/module.mjs +4 -4
- package/esm2022/badge/badge-module.mjs +4 -4
- package/esm2022/badge/badge.mjs +6 -6
- package/esm2022/bottom-sheet/bottom-sheet-container.mjs +3 -3
- package/esm2022/bottom-sheet/bottom-sheet-module.mjs +4 -4
- package/esm2022/bottom-sheet/bottom-sheet.mjs +3 -3
- package/esm2022/button/button-base.mjs +6 -6
- package/esm2022/button/button.mjs +6 -6
- package/esm2022/button/fab.mjs +12 -12
- package/esm2022/button/icon-button.mjs +6 -6
- package/esm2022/button/module.mjs +4 -4
- package/esm2022/button-toggle/button-toggle-module.mjs +4 -4
- package/esm2022/button-toggle/button-toggle.mjs +6 -6
- package/esm2022/card/card.mjs +42 -42
- package/esm2022/card/module.mjs +4 -4
- package/esm2022/checkbox/checkbox-required-validator.mjs +3 -3
- package/esm2022/checkbox/checkbox.mjs +3 -3
- package/esm2022/checkbox/module.mjs +8 -8
- package/esm2022/chips/chip-action.mjs +3 -3
- package/esm2022/chips/chip-edit-input.mjs +3 -3
- package/esm2022/chips/chip-grid.mjs +3 -3
- package/esm2022/chips/chip-icons.mjs +9 -9
- package/esm2022/chips/chip-input.mjs +3 -3
- package/esm2022/chips/chip-listbox.mjs +3 -3
- package/esm2022/chips/chip-option.mjs +3 -3
- package/esm2022/chips/chip-row.mjs +3 -3
- package/esm2022/chips/chip-set.mjs +3 -3
- package/esm2022/chips/chip.mjs +3 -3
- package/esm2022/chips/module.mjs +4 -4
- package/esm2022/core/common-behaviors/common-module.mjs +4 -4
- package/esm2022/core/datetime/index.mjs +8 -8
- package/esm2022/core/datetime/native-date-adapter.mjs +3 -3
- package/esm2022/core/error/error-options.mjs +6 -6
- package/esm2022/core/internal-form-field/internal-form-field.mjs +3 -3
- package/esm2022/core/line/line.mjs +7 -7
- package/esm2022/core/option/index.mjs +4 -4
- package/esm2022/core/option/optgroup.mjs +3 -3
- package/esm2022/core/option/option.mjs +3 -3
- package/esm2022/core/private/ripple-loader.mjs +3 -3
- package/esm2022/core/ripple/index.mjs +4 -4
- package/esm2022/core/ripple/ripple.mjs +3 -3
- package/esm2022/core/selection/pseudo-checkbox/pseudo-checkbox-module.mjs +4 -4
- package/esm2022/core/selection/pseudo-checkbox/pseudo-checkbox.mjs +3 -3
- package/esm2022/core/version.mjs +1 -1
- package/esm2022/datepicker/calendar-body.mjs +3 -3
- package/esm2022/datepicker/calendar.mjs +6 -6
- package/esm2022/datepicker/date-range-input-parts.mjs +9 -9
- package/esm2022/datepicker/date-range-input.mjs +9 -4
- package/esm2022/datepicker/date-range-picker.mjs +3 -3
- package/esm2022/datepicker/date-range-selection-strategy.mjs +3 -3
- package/esm2022/datepicker/date-selection-model.mjs +9 -9
- package/esm2022/datepicker/datepicker-actions.mjs +9 -9
- package/esm2022/datepicker/datepicker-base.mjs +10 -13
- package/esm2022/datepicker/datepicker-input-base.mjs +3 -3
- package/esm2022/datepicker/datepicker-input.mjs +3 -3
- package/esm2022/datepicker/datepicker-intl.mjs +3 -3
- package/esm2022/datepicker/datepicker-module.mjs +4 -4
- package/esm2022/datepicker/datepicker-toggle.mjs +6 -6
- package/esm2022/datepicker/datepicker.mjs +3 -3
- package/esm2022/datepicker/month-view.mjs +3 -3
- package/esm2022/datepicker/multi-year-view.mjs +3 -3
- package/esm2022/datepicker/year-view.mjs +3 -3
- package/esm2022/dialog/dialog-container.mjs +3 -3
- package/esm2022/dialog/dialog-content-directives.mjs +15 -15
- package/esm2022/dialog/dialog.mjs +3 -3
- package/esm2022/dialog/module.mjs +4 -4
- package/esm2022/divider/divider-module.mjs +4 -4
- package/esm2022/divider/divider.mjs +3 -3
- package/esm2022/expansion/accordion.mjs +3 -3
- package/esm2022/expansion/expansion-module.mjs +4 -4
- package/esm2022/expansion/expansion-panel-content.mjs +3 -3
- package/esm2022/expansion/expansion-panel-header.mjs +9 -9
- package/esm2022/expansion/expansion-panel.mjs +6 -6
- package/esm2022/form-field/directives/error.mjs +3 -3
- package/esm2022/form-field/directives/floating-label.mjs +3 -3
- package/esm2022/form-field/directives/hint.mjs +3 -3
- package/esm2022/form-field/directives/label.mjs +3 -3
- package/esm2022/form-field/directives/line-ripple.mjs +3 -3
- package/esm2022/form-field/directives/notched-outline.mjs +3 -3
- package/esm2022/form-field/directives/prefix.mjs +3 -3
- package/esm2022/form-field/directives/suffix.mjs +3 -3
- package/esm2022/form-field/form-field-control.mjs +4 -4
- package/esm2022/form-field/form-field.mjs +6 -6
- package/esm2022/form-field/module.mjs +4 -4
- package/esm2022/grid-list/grid-list-module.mjs +4 -4
- package/esm2022/grid-list/grid-list.mjs +3 -3
- package/esm2022/grid-list/grid-tile.mjs +15 -15
- package/esm2022/icon/icon-module.mjs +4 -4
- package/esm2022/icon/icon-registry.mjs +3 -3
- package/esm2022/icon/icon.mjs +3 -3
- package/esm2022/icon/testing/fake-icon-registry.mjs +7 -7
- package/esm2022/input/input.mjs +3 -3
- package/esm2022/input/module.mjs +4 -4
- package/esm2022/list/action-list.mjs +3 -3
- package/esm2022/list/list-base.mjs +6 -6
- package/esm2022/list/list-item-sections.mjs +18 -18
- package/esm2022/list/list-module.mjs +4 -4
- package/esm2022/list/list-option.mjs +3 -3
- package/esm2022/list/list.mjs +6 -6
- package/esm2022/list/nav-list.mjs +3 -3
- package/esm2022/list/selection-list.mjs +3 -3
- package/esm2022/list/subheader.mjs +3 -3
- package/esm2022/menu/menu-content.mjs +3 -3
- package/esm2022/menu/menu-item.mjs +3 -3
- package/esm2022/menu/menu-trigger.mjs +3 -3
- package/esm2022/menu/menu.mjs +21 -16
- package/esm2022/menu/module.mjs +4 -4
- package/esm2022/paginator/module.mjs +4 -4
- package/esm2022/paginator/paginator-intl.mjs +3 -3
- package/esm2022/paginator/paginator.mjs +3 -3
- package/esm2022/progress-bar/module.mjs +4 -4
- package/esm2022/progress-bar/progress-bar.mjs +5 -5
- package/esm2022/progress-spinner/module.mjs +4 -4
- package/esm2022/progress-spinner/progress-spinner.mjs +3 -3
- package/esm2022/radio/module.mjs +4 -4
- package/esm2022/radio/radio.mjs +6 -6
- package/esm2022/select/module.mjs +4 -4
- package/esm2022/select/select.mjs +12 -7
- package/esm2022/sidenav/drawer.mjs +9 -9
- package/esm2022/sidenav/sidenav-module.mjs +4 -4
- package/esm2022/sidenav/sidenav.mjs +9 -9
- package/esm2022/slide-toggle/module.mjs +8 -8
- package/esm2022/slide-toggle/slide-toggle-required-validator.mjs +3 -3
- package/esm2022/slide-toggle/slide-toggle.mjs +3 -3
- package/esm2022/slider/module.mjs +4 -4
- package/esm2022/slider/slider-input.mjs +6 -6
- package/esm2022/slider/slider-thumb.mjs +3 -3
- package/esm2022/slider/slider.mjs +3 -3
- package/esm2022/snack-bar/module.mjs +4 -4
- package/esm2022/snack-bar/simple-snack-bar.mjs +3 -3
- package/esm2022/snack-bar/snack-bar-container.mjs +3 -3
- package/esm2022/snack-bar/snack-bar-content.mjs +9 -9
- package/esm2022/snack-bar/snack-bar.mjs +3 -3
- package/esm2022/sort/sort-header-intl.mjs +3 -3
- package/esm2022/sort/sort-header.mjs +3 -3
- package/esm2022/sort/sort-module.mjs +4 -4
- package/esm2022/sort/sort.mjs +3 -3
- package/esm2022/stepper/step-content.mjs +3 -3
- package/esm2022/stepper/step-header.mjs +3 -3
- package/esm2022/stepper/step-label.mjs +3 -3
- package/esm2022/stepper/stepper-button.mjs +6 -6
- package/esm2022/stepper/stepper-icon.mjs +3 -3
- package/esm2022/stepper/stepper-intl.mjs +3 -3
- package/esm2022/stepper/stepper-module.mjs +4 -4
- package/esm2022/stepper/stepper.mjs +6 -6
- package/esm2022/table/cell.mjs +21 -21
- package/esm2022/table/module.mjs +4 -4
- package/esm2022/table/row.mjs +21 -21
- package/esm2022/table/table.mjs +6 -6
- package/esm2022/table/text-column.mjs +3 -3
- package/esm2022/tabs/ink-bar.mjs +3 -3
- package/esm2022/tabs/module.mjs +4 -4
- package/esm2022/tabs/paginated-tab-header.mjs +3 -3
- package/esm2022/tabs/tab-body.mjs +6 -6
- package/esm2022/tabs/tab-content.mjs +3 -3
- package/esm2022/tabs/tab-group.mjs +6 -8
- package/esm2022/tabs/tab-header.mjs +3 -3
- package/esm2022/tabs/tab-label-wrapper.mjs +3 -3
- package/esm2022/tabs/tab-label.mjs +3 -3
- package/esm2022/tabs/tab-nav-bar/tab-nav-bar.mjs +9 -9
- package/esm2022/tabs/tab.mjs +4 -4
- package/esm2022/toolbar/toolbar-module.mjs +4 -4
- package/esm2022/toolbar/toolbar.mjs +6 -6
- package/esm2022/tooltip/module.mjs +4 -4
- package/esm2022/tooltip/tooltip.mjs +6 -6
- package/esm2022/tree/node.mjs +9 -9
- package/esm2022/tree/outlet.mjs +3 -3
- package/esm2022/tree/padding.mjs +3 -3
- package/esm2022/tree/toggle.mjs +3 -3
- package/esm2022/tree/tree-module.mjs +4 -4
- package/esm2022/tree/tree.mjs +3 -3
- package/expansion/_expansion-theme.scss +7 -0
- package/fesm2022/autocomplete.mjs +26 -48
- package/fesm2022/autocomplete.mjs.map +1 -1
- package/fesm2022/badge.mjs +10 -10
- package/fesm2022/bottom-sheet.mjs +10 -10
- package/fesm2022/button-toggle.mjs +10 -10
- package/fesm2022/button.mjs +34 -34
- package/fesm2022/card.mjs +46 -46
- package/fesm2022/checkbox.mjs +14 -14
- package/fesm2022/chips.mjs +40 -40
- package/fesm2022/core.mjs +59 -59
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/datepicker.mjs +89 -87
- package/fesm2022/datepicker.mjs.map +1 -1
- package/fesm2022/dialog.mjs +25 -25
- package/fesm2022/divider.mjs +7 -7
- package/fesm2022/expansion.mjs +25 -25
- package/fesm2022/form-field.mjs +36 -36
- package/fesm2022/form-field.mjs.map +1 -1
- package/fesm2022/grid-list.mjs +22 -22
- package/fesm2022/icon/testing.mjs +7 -7
- package/fesm2022/icon.mjs +10 -10
- package/fesm2022/input.mjs +7 -7
- package/fesm2022/list.mjs +49 -49
- package/fesm2022/menu.mjs +34 -28
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/paginator.mjs +10 -10
- package/fesm2022/progress-bar.mjs +8 -8
- package/fesm2022/progress-bar.mjs.map +1 -1
- package/fesm2022/progress-spinner.mjs +7 -7
- package/fesm2022/radio.mjs +10 -10
- package/fesm2022/select.mjs +15 -10
- package/fesm2022/select.mjs.map +1 -1
- package/fesm2022/sidenav.mjs +22 -22
- package/fesm2022/slide-toggle.mjs +14 -14
- package/fesm2022/slider.mjs +16 -16
- package/fesm2022/snack-bar.mjs +22 -22
- package/fesm2022/sort.mjs +13 -13
- package/fesm2022/stepper.mjs +31 -31
- package/fesm2022/table.mjs +55 -55
- package/fesm2022/tabs.mjs +46 -47
- package/fesm2022/tabs.mjs.map +1 -1
- package/fesm2022/toolbar.mjs +10 -10
- package/fesm2022/tooltip.mjs +10 -10
- package/fesm2022/tree.mjs +25 -25
- package/form-field/_form-field-theme.scss +15 -0
- package/form-field/index.d.ts +6 -0
- package/grid-list/_grid-list-theme.scss +7 -0
- package/icon/_icon-theme.scss +9 -0
- package/input/_input-theme.scss +8 -0
- package/list/_list-theme.scss +8 -0
- package/menu/_menu-theme.scss +7 -0
- package/menu/index.d.ts +1 -1
- package/package.json +3 -2
- package/paginator/_paginator-theme.scss +7 -0
- package/progress-bar/_progress-bar-theme.scss +11 -0
- package/progress-spinner/_progress-spinner-theme.scss +11 -0
- package/radio/_radio-theme.scss +10 -0
- package/schematics/collection.json +6 -0
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
- package/schematics/ng-add/theming/create-custom-theme.js +5 -6
- package/schematics/ng-add/theming/create-custom-theme.mjs +5 -6
- package/schematics/ng-generate/m3-theme/index_bundled.js +2682 -0
- package/schematics/ng-generate/m3-theme/index_bundled.js.map +7 -0
- package/schematics/ng-generate/m3-theme/schema.json +56 -0
- package/schematics/ng-update/index_bundled.js +215 -1
- package/schematics/ng-update/index_bundled.js.map +4 -4
- package/select/_select-theme.scss +9 -0
- package/select/index.d.ts +5 -0
- package/sidenav/_sidenav-theme.scss +7 -0
- package/slide-toggle/_slide-toggle-theme.scss +11 -0
- package/slider/_slider-theme.scss +10 -0
- package/snack-bar/_snack-bar-theme.scss +10 -0
- package/sort/_sort-theme.scss +7 -0
- package/stepper/_stepper-theme.scss +9 -0
- package/table/_table-theme.scss +7 -0
- package/tabs/_tabs-theme.scss +20 -0
- package/tabs/index.d.ts +2 -8
- package/toolbar/_toolbar-theme.scss +9 -0
- package/tooltip/_tooltip-theme.scss +8 -0
- package/tree/_tree-theme.scss +7 -0
- /package/core/{theming → m2}/_palette.scss +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
@use 'sass:list';
|
|
2
|
+
@use 'sass:map';
|
|
3
|
+
@use 'sass:meta';
|
|
4
|
+
@use 'sass:string';
|
|
5
|
+
@use '../style/validation';
|
|
6
|
+
@use './palettes';
|
|
7
|
+
|
|
8
|
+
/// Creates an error message by finding `$config` in the existing message and appending a suffix to
|
|
9
|
+
/// it.
|
|
10
|
+
/// @param {List|String} $err The error message.
|
|
11
|
+
/// @param {String} $suffix The suffix to add.
|
|
12
|
+
/// @return {List|String} The updated error message.
|
|
13
|
+
@function _create-dollar-config-error-message($err, $suffix) {
|
|
14
|
+
@if meta.type-of($err) == 'list' {
|
|
15
|
+
@for $i from 1 through list.length($err) {
|
|
16
|
+
$err: list.set-nth($err, $i,
|
|
17
|
+
_create-dollar-config-error-message(list.nth($err, $i), $suffix));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
@else if meta.type-of($err) == 'string' {
|
|
21
|
+
$start: string.index($err, '$config');
|
|
22
|
+
@if $start {
|
|
23
|
+
$err: string.insert($err, $suffix, $start + 7);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
@return $err;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// Validates that the given object is an M3 palette.
|
|
30
|
+
/// @param {*} $palette The object to test
|
|
31
|
+
/// @return {Boolean|null} null if it is a valid M3 palette, else true.
|
|
32
|
+
@function _validate-palette($palette) {
|
|
33
|
+
@if not meta.type-of($palette) == 'map' {
|
|
34
|
+
@return true;
|
|
35
|
+
}
|
|
36
|
+
$keys: map.keys($palette);
|
|
37
|
+
$expected-keys: map.keys(palettes.$red-palette);
|
|
38
|
+
@if validation.validate-allowed-values($keys, $expected-keys...) or
|
|
39
|
+
validation.validate-required-values($keys, $expected-keys...) {
|
|
40
|
+
@return true;
|
|
41
|
+
}
|
|
42
|
+
$nv-keys: map.keys(map.get($palette, neutral-variant));
|
|
43
|
+
$expected-nv-keys: map.keys(map.get(palettes.$red-palette, neutral-variant));
|
|
44
|
+
@if validation.validate-allowed-values($nv-keys, $expected-nv-keys...) or
|
|
45
|
+
validation.validate-required-values($nv-keys, $expected-nv-keys...) {
|
|
46
|
+
@return true;
|
|
47
|
+
}
|
|
48
|
+
@return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// Validates a theme config.
|
|
52
|
+
/// @param {Map} $config The config to test.
|
|
53
|
+
/// @return {List} null if no error, else the error message
|
|
54
|
+
@function validate-theme-config($config) {
|
|
55
|
+
$err: validation.validate-type($config, 'map', 'null');
|
|
56
|
+
@if $err {
|
|
57
|
+
@return (#{'$config should be a configuration object. Got:'} $config);
|
|
58
|
+
}
|
|
59
|
+
$allowed: (color, typography, density);
|
|
60
|
+
$err: validation.validate-allowed-values(map.keys($config or ()), $allowed...);
|
|
61
|
+
@if $err {
|
|
62
|
+
@return (
|
|
63
|
+
#{'$config has unexpected properties. Valid properties are'}
|
|
64
|
+
#{'#{$allowed}.'}
|
|
65
|
+
#{'Found:'}
|
|
66
|
+
$err
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
$err: validate-color-config(map.get($config, color));
|
|
70
|
+
@if $err {
|
|
71
|
+
@return _create-dollar-config-error-message($err, '.color');
|
|
72
|
+
}
|
|
73
|
+
$err: validate-typography-config(map.get($config, typography));
|
|
74
|
+
@if $err {
|
|
75
|
+
@return _create-dollar-config-error-message($err, '.typography');
|
|
76
|
+
}
|
|
77
|
+
$err: validate-density-config(map.get($config, density));
|
|
78
|
+
@if $err {
|
|
79
|
+
@return _create-dollar-config-error-message($err, '.density');
|
|
80
|
+
}
|
|
81
|
+
@return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// Validates a theme color config.
|
|
85
|
+
/// @param {Map} $config The config to test.
|
|
86
|
+
/// @return {List} null if no error, else the error message
|
|
87
|
+
@function validate-color-config($config) {
|
|
88
|
+
$err: validation.validate-type($config, 'map', 'null');
|
|
89
|
+
@if $err {
|
|
90
|
+
@return (#{'$config should be a color configuration object. Got:'} $config);
|
|
91
|
+
}
|
|
92
|
+
$allowed: (theme-type, primary, tertiary, use-system-variables);
|
|
93
|
+
$err: validation.validate-allowed-values(map.keys($config or ()), $allowed...);
|
|
94
|
+
@if $err {
|
|
95
|
+
@return (
|
|
96
|
+
#{'$config has unexpected properties. Valid properties are'}
|
|
97
|
+
#{'#{$allowed}.'}
|
|
98
|
+
#{'Found:'}
|
|
99
|
+
$err
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
@if $config and map.has-key($config, theme-type) and
|
|
103
|
+
not list.index((light, dark), map.get($config, theme-type)) {
|
|
104
|
+
@return (
|
|
105
|
+
#{'Expected $config.theme-type to be one of: light, dark. Got:'}
|
|
106
|
+
map.get($config, theme-type)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
@each $palette in (primary, secondary, tertiary) {
|
|
110
|
+
@if $config and map.has-key($config, $palette) {
|
|
111
|
+
$err: _validate-palette(map.get($config, $palette));
|
|
112
|
+
@if $err {
|
|
113
|
+
@return (
|
|
114
|
+
#{'Expected $config.#{$palette} to be a valid M3 palette. Got:'}
|
|
115
|
+
map.get($config, $palette)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
@return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/// Validates a theme typography config.
|
|
124
|
+
/// @param {Map} $config The config to test.
|
|
125
|
+
/// @return {List} null if no error, else the error message
|
|
126
|
+
@function validate-typography-config($config) {
|
|
127
|
+
$err: validation.validate-type($config, 'map', 'null');
|
|
128
|
+
@if $err {
|
|
129
|
+
@return (#{'$config should be a typography configuration object. Got:'} $config);
|
|
130
|
+
}
|
|
131
|
+
$allowed: (
|
|
132
|
+
brand-family,
|
|
133
|
+
plain-family,
|
|
134
|
+
bold-weight,
|
|
135
|
+
medium-weight,
|
|
136
|
+
regular-weight,
|
|
137
|
+
use-system-variables
|
|
138
|
+
);
|
|
139
|
+
$err: validation.validate-allowed-values(map.keys($config or ()), $allowed...);
|
|
140
|
+
@if $err {
|
|
141
|
+
@return (
|
|
142
|
+
#{'$config has unexpected properties. Valid properties are'}
|
|
143
|
+
#{'#{$allowed}.'}
|
|
144
|
+
#{'Found:'}
|
|
145
|
+
$err
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
@return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/// Validates a theme density config.
|
|
152
|
+
/// @param {Map} $config The config to test.
|
|
153
|
+
/// @return {List} null if no error, else the error message
|
|
154
|
+
@function validate-density-config($config) {
|
|
155
|
+
$err: validation.validate-type($config, 'map', 'null');
|
|
156
|
+
@if $err {
|
|
157
|
+
@return (#{'$config should be a density configuration object. Got:'} $config);
|
|
158
|
+
}
|
|
159
|
+
$err: validation.validate-allowed-values(map.keys($config or ()), scale);
|
|
160
|
+
@if $err {
|
|
161
|
+
@return (#{'$config has unexpected properties. Valid properties are: scale. Found:'} $err);
|
|
162
|
+
}
|
|
163
|
+
@if $config and map.has-key($config, scale) {
|
|
164
|
+
$allowed-scales: (0, -1, -2, -3, -4, -5, minimum, maximum);
|
|
165
|
+
@if validation.validate-allowed-values(map.get($config, scale), $allowed-scales...) {
|
|
166
|
+
@return (
|
|
167
|
+
#{'Expected $config.scale to be one of: #{$allowed-scales}. Got:'}
|
|
168
|
+
map.get($config, scale)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
@return null;
|
|
173
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// This file contains functions used to define Angular Material theme objects.
|
|
2
|
+
|
|
3
|
+
@use 'sass:map';
|
|
4
|
+
@use '../style/sass-utils';
|
|
5
|
+
@use './palettes';
|
|
6
|
+
@use '../tokens/m3-tokens';
|
|
7
|
+
@use './config-validation';
|
|
8
|
+
|
|
9
|
+
/// Map key used to store internals of theme config.
|
|
10
|
+
$internals: _mat-theming-internals-do-not-access;
|
|
11
|
+
/// The theme version of generated themes.
|
|
12
|
+
$theme-version: 1;
|
|
13
|
+
|
|
14
|
+
/// Defines an Angular Material theme object with color, typography, and density settings.
|
|
15
|
+
/// @param {Map} $config The theme configuration
|
|
16
|
+
/// @return {Map} A theme object
|
|
17
|
+
@function define-theme($config: ()) {
|
|
18
|
+
$err: config-validation.validate-theme-config($config);
|
|
19
|
+
@if $err {
|
|
20
|
+
@error $err;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@return sass-utils.deep-merge-all(
|
|
24
|
+
define-colors(map.get($config, color) or ()),
|
|
25
|
+
define-typography(map.get($config, typography) or ()),
|
|
26
|
+
define-density(map.get($config, density) or ()),
|
|
27
|
+
($internals: (base-tokens: m3-tokens.generate-base-tokens())),
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Defines an Angular Material theme object with color settings.
|
|
32
|
+
/// @param {Map} $config The color configuration
|
|
33
|
+
/// @return {Map} A theme object
|
|
34
|
+
@function define-colors($config: ()) {
|
|
35
|
+
$err: config-validation.validate-color-config($config);
|
|
36
|
+
@if $err {
|
|
37
|
+
@error $err;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
$type: map.get($config, theme-type) or light;
|
|
41
|
+
$primary: map.get($config, primary) or palettes.$violet-palette;
|
|
42
|
+
$tertiary: map.get($config, tertiary) or $primary;
|
|
43
|
+
sass-utils.$use-system-color-variables: map.get($config, use-system-variables) or false;
|
|
44
|
+
|
|
45
|
+
@return (
|
|
46
|
+
$internals: (
|
|
47
|
+
theme-version: $theme-version,
|
|
48
|
+
theme-type: $type,
|
|
49
|
+
palettes: (
|
|
50
|
+
primary: map.remove($primary, neutral, neutral-variant, secondary),
|
|
51
|
+
secondary: map.get($primary, secondary),
|
|
52
|
+
tertiary: map.remove($tertiary, neutral, neutral-variant, secondary),
|
|
53
|
+
neutral: map.get($primary, neutral),
|
|
54
|
+
neutral-variant: map.get($primary, neutral-variant),
|
|
55
|
+
error: map.get($primary, error),
|
|
56
|
+
),
|
|
57
|
+
color-tokens: m3-tokens.generate-color-tokens(
|
|
58
|
+
$type, $primary, $tertiary, map.get($primary, error))
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// Defines an Angular Material theme object with typography settings.
|
|
64
|
+
/// @param {Map} $config The typography configuration
|
|
65
|
+
/// @return {Map} A theme object
|
|
66
|
+
@function define-typography($config: ()) {
|
|
67
|
+
$err: config-validation.validate-typography-config($config);
|
|
68
|
+
@if $err {
|
|
69
|
+
@error $err;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
$plain: map.get($config, plain-family) or (Roboto, sans-serif);
|
|
73
|
+
$brand: map.get($config, brand-family) or $plain;
|
|
74
|
+
$bold: map.get($config, bold-weight) or 700;
|
|
75
|
+
$medium: map.get($config, medium-weight) or 500;
|
|
76
|
+
$regular: map.get($config, regular-weight) or 400;
|
|
77
|
+
sass-utils.$use-system-typography-variables: map.get($config, use-system-variables) or false;
|
|
78
|
+
|
|
79
|
+
@return (
|
|
80
|
+
$internals: (
|
|
81
|
+
theme-version: $theme-version,
|
|
82
|
+
font-definition: (
|
|
83
|
+
plain: $plain,
|
|
84
|
+
brand: $brand,
|
|
85
|
+
bold: $bold,
|
|
86
|
+
medium: $medium,
|
|
87
|
+
regular: $regular,
|
|
88
|
+
),
|
|
89
|
+
typography-tokens: m3-tokens.generate-typography-tokens(
|
|
90
|
+
$brand, $plain, $bold, $medium, $regular)
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/// Defines an Angular Material theme object with density settings.
|
|
96
|
+
/// @param {Map} $config The density configuration
|
|
97
|
+
/// @return {Map} A theme object
|
|
98
|
+
@function define-density($config: ()) {
|
|
99
|
+
$err: config-validation.validate-density-config($config);
|
|
100
|
+
@if $err {
|
|
101
|
+
@error $err;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
$density-scale: map.get($config, scale) or 0;
|
|
105
|
+
|
|
106
|
+
@return (
|
|
107
|
+
$internals: (
|
|
108
|
+
theme-version: $theme-version,
|
|
109
|
+
density-scale: $density-scale,
|
|
110
|
+
density-tokens: m3-tokens.generate-density-tokens($density-scale)
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
@use 'sass:map';
|
|
3
3
|
@use 'sass:meta';
|
|
4
4
|
@use './theming';
|
|
5
|
-
@use '../
|
|
5
|
+
@use '../m2/theming' as m2-theming;
|
|
6
|
+
@use '../m2/typography-utils' as m2-typography-utils;
|
|
6
7
|
@use '../typography/versioning' as typography-versioning;
|
|
7
8
|
|
|
8
9
|
/// Key used to access the Angular Material theme internals.
|
|
@@ -92,11 +93,11 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
|
|
|
92
93
|
@if not theme-has($theme, color) {
|
|
93
94
|
@error 'Color information is not available on this theme.';
|
|
94
95
|
}
|
|
95
|
-
$colors: theming.get-color-config($theme);
|
|
96
|
+
$colors: m2-theming.get-color-config($theme);
|
|
96
97
|
// Some apps seem to have mistakenly created nested color themes that somehow work with our old
|
|
97
98
|
// theme normalization logic. This check allows those apps to keep working.
|
|
98
99
|
@if theme-has($colors, color) {
|
|
99
|
-
$colors: theming.get-color-config($colors);
|
|
100
|
+
$colors: m2-theming.get-color-config($colors);
|
|
100
101
|
}
|
|
101
102
|
@return if(map.get($colors, is-dark), dark, light);
|
|
102
103
|
}
|
|
@@ -115,18 +116,18 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
|
|
|
115
116
|
@if not theme-has($theme, color) {
|
|
116
117
|
@error 'Color information is not available on this theme.';
|
|
117
118
|
}
|
|
118
|
-
$colors: theming.get-color-config($theme);
|
|
119
|
+
$colors: m2-theming.get-color-config($theme);
|
|
119
120
|
// Some apps seem to have mistakenly created nested color themes that somehow work with our old
|
|
120
121
|
// theme normalization logic. This check allows those apps to keep working.
|
|
121
122
|
@if theme-has($colors, color) {
|
|
122
|
-
$colors: theming.get-color-config($colors);
|
|
123
|
+
$colors: m2-theming.get-color-config($colors);
|
|
123
124
|
}
|
|
124
125
|
$palette: map.get($colors, $palette-name);
|
|
125
126
|
@if not $palette {
|
|
126
127
|
@error $palette-name $args $theme;
|
|
127
128
|
@error #{'Unrecognized palette name:'} $palette-name;
|
|
128
129
|
}
|
|
129
|
-
@return theming.get-color-from-palette($palette, $args...);
|
|
130
|
+
@return m2-theming.get-color-from-palette($palette, $args...);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
/// Gets a typography value from a theme object.
|
|
@@ -141,29 +142,29 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
|
|
|
141
142
|
@error 'Typography information is not available on this theme.';
|
|
142
143
|
}
|
|
143
144
|
$typography: typography-versioning.private-typography-to-2018-config(
|
|
144
|
-
theming.get-typography-config($theme));
|
|
145
|
+
m2-theming.get-typography-config($theme));
|
|
145
146
|
@if $property == font {
|
|
146
|
-
$font-weight: typography-
|
|
147
|
-
$font-size: typography-
|
|
148
|
-
$line-height: typography-
|
|
149
|
-
$font-family: typography-
|
|
147
|
+
$font-weight: m2-typography-utils.font-weight($typography, $typescale);
|
|
148
|
+
$font-size: m2-typography-utils.font-size($typography, $typescale);
|
|
149
|
+
$line-height: m2-typography-utils.line-height($typography, $typescale);
|
|
150
|
+
$font-family: m2-typography-utils.font-family($typography, $typescale);
|
|
150
151
|
@return ($font-weight list.slash($font-size, $line-height) $font-family);
|
|
151
152
|
}
|
|
152
153
|
@else if $property == font-family {
|
|
153
|
-
$result: typography-
|
|
154
|
-
@return $result or typography-
|
|
154
|
+
$result: m2-typography-utils.font-family($typography, $typescale);
|
|
155
|
+
@return $result or m2-typography-utils.font-family($typography);
|
|
155
156
|
}
|
|
156
157
|
@else if $property == font-size {
|
|
157
|
-
@return typography-
|
|
158
|
+
@return m2-typography-utils.font-size($typography, $typescale);
|
|
158
159
|
}
|
|
159
160
|
@else if $property == font-weight {
|
|
160
|
-
@return typography-
|
|
161
|
+
@return m2-typography-utils.font-weight($typography, $typescale);
|
|
161
162
|
}
|
|
162
163
|
@else if $property == line-height {
|
|
163
|
-
@return typography-
|
|
164
|
+
@return m2-typography-utils.line-height($typography, $typescale);
|
|
164
165
|
}
|
|
165
166
|
@else if $property == letter-spacing {
|
|
166
|
-
@return typography-
|
|
167
|
+
@return m2-typography-utils.letter-spacing($typography, $typescale);
|
|
167
168
|
}
|
|
168
169
|
@else {
|
|
169
170
|
@error #{'Valid typography properties are: #{$_typography-properties}. Got:'} $property;
|
|
@@ -178,7 +179,7 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
|
|
|
178
179
|
@if not theme-has($theme, density) {
|
|
179
180
|
@error 'Density information is not available on this theme.';
|
|
180
181
|
}
|
|
181
|
-
$scale: theming.get-density-config($theme);
|
|
182
|
+
$scale: m2-theming.get-density-config($theme);
|
|
182
183
|
@return theming.clamp-density($scale, -5);
|
|
183
184
|
}
|
|
184
185
|
|
|
@@ -192,11 +193,11 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
|
|
|
192
193
|
@return true;
|
|
193
194
|
}
|
|
194
195
|
@if $system == color {
|
|
195
|
-
$color: theming.get-color-config($theme);
|
|
196
|
+
$color: m2-theming.get-color-config($theme);
|
|
196
197
|
@return $color != null and _has-any-key($color, $_color-keys);
|
|
197
198
|
}
|
|
198
199
|
@if $system == typography {
|
|
199
|
-
$typography: theming.get-typography-config($theme);
|
|
200
|
+
$typography: m2-theming.get-typography-config($theme);
|
|
200
201
|
@return $typography != null and _has-any-key($typography, $_typography-keys);
|
|
201
202
|
}
|
|
202
203
|
@if $system == density {
|
|
@@ -205,7 +206,7 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
|
|
|
205
206
|
@if meta.type-of($theme) == 'map' and map.get($theme, density) {
|
|
206
207
|
@return true;
|
|
207
208
|
}
|
|
208
|
-
$density: theming.get-density-config($theme);
|
|
209
|
+
$density: m2-theming.get-density-config($theme);
|
|
209
210
|
@return $density != null and _is-density-value($density);
|
|
210
211
|
}
|
|
211
212
|
@error 'Valid systems are: base, color, typography, density. Got:' $system;
|
|
@@ -247,7 +248,7 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
|
|
|
247
248
|
$internal: map.get($theme, $_internals, m2-config);
|
|
248
249
|
$theme: map.remove($theme, $_internals);
|
|
249
250
|
@if theme-has($theme, typography) {
|
|
250
|
-
$typography-config: theming.get-typography-config($theme);
|
|
251
|
+
$typography-config: m2-theming.get-typography-config($theme);
|
|
251
252
|
// gmat configs have both 2018 and 2014 keys.
|
|
252
253
|
@if (not typography-versioning.private-typography-is-2014-config($typography-config)) or
|
|
253
254
|
(not typography-versioning.private-typography-is-2018-config($typography-config)) {
|