diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e7e22853525..c64263073aaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,35 @@ + +# 18.1.0-next.2 "ivory-infinity" (2024-06-12) +### cdk +| Commit | Type | Description | +| -- | -- | -- | +| [0bc6583892](https://github.com/angular/components/commit/0bc65838926e88723bfc677fc3e4de81826cfe5b) | feat | **drag-drop:** add mixed orientation support | +### material +| Commit | Type | Description | +| -- | -- | -- | +| [6f698fa4e2](https://github.com/angular/components/commit/6f698fa4e24ef4637b2c83f43cb608df967a78b5) | feat | **core:** add option to configure prefix of system variables ([#29139](https://github.com/angular/components/pull/29139)) | +| [e7312037f7](https://github.com/angular/components/commit/e7312037f75dad5482b06868542ec2a715c116fc) | fix | **dialog:** Make autofocus work with animations disabled ([#29195](https://github.com/angular/components/pull/29195)) | +| [3b32d0e7c9](https://github.com/angular/components/commit/3b32d0e7c95b358d30f8b7e6b0570ab8ba815a06) | fix | **dialog:** Make focus behavior consistent across zoneful/zoneless apps ([#29192](https://github.com/angular/components/pull/29192)) | +| [566057b8f5](https://github.com/angular/components/commit/566057b8f58fab1b5328cbd4336b7b19ea412fd3) | fix | **divider:** non-text color contrast issues ([#28995](https://github.com/angular/components/pull/28995)) | +| [e3abc65d7d](https://github.com/angular/components/commit/e3abc65d7d191f2adf1c294bdb84f532d4eac05c) | fix | **radio:** mark radio-group for check on touch ([#29203](https://github.com/angular/components/pull/29203)) | +| [3da43230e6](https://github.com/angular/components/commit/3da43230e62c8983af5c21c4c1fc66ea2e5e7d52) | fix | **schematics:** estimate missing hues in M3 schematic ([#29231](https://github.com/angular/components/pull/29231)) | +| [d717de5150](https://github.com/angular/components/commit/d717de51501e04a0410217c07fc31929ff2e983a) | fix | **snack-bar:** fix overrides mixin name typo ([#29180](https://github.com/angular/components/pull/29180)) | + + + + +# 18.0.3 "gossamer-glacier" (2024-06-12) +### material +| Commit | Type | Description | +| -- | -- | -- | +| [f6b993fdb7](https://github.com/angular/components/commit/f6b993fdb7fbdcfbe0297d320a5961097002308d) | fix | **dialog:** Make autofocus work with animations disabled ([#29195](https://github.com/angular/components/pull/29195)) | +| [6dd1689b51](https://github.com/angular/components/commit/6dd1689b519abf287098d30f7698fc37197e3db0) | fix | **dialog:** Make focus behavior consistent across zoneful/zoneless apps ([#29192](https://github.com/angular/components/pull/29192)) | +| [81d4527f91](https://github.com/angular/components/commit/81d4527f9130605f69dea31a092a60261bde25db) | fix | **radio:** mark radio-group for check on touch ([#29203](https://github.com/angular/components/pull/29203)) | +| [0f4d1862d3](https://github.com/angular/components/commit/0f4d1862d30366978176a4a87b7799915d3caedd) | fix | **schematics:** estimate missing hues in M3 schematic ([#29231](https://github.com/angular/components/pull/29231)) | +| [faf348438d](https://github.com/angular/components/commit/faf348438d57db80e8ac5187ffe3900fe398fe77) | fix | **snack-bar:** fix overrides mixin name typo ([#29180](https://github.com/angular/components/pull/29180)) | + + + # 18.1.0-next.1 "velvet-violoncello" (2024-06-05) ### cdk diff --git a/guides/getting-started.md b/guides/getting-started.md index e22bd13a45c4..642cb730f1bb 100644 --- a/guides/getting-started.md +++ b/guides/getting-started.md @@ -28,7 +28,7 @@ determine which features to include: 1. Choose a prebuilt theme name, or "custom" for a custom theme: - You can choose from [prebuilt material design themes](https://material.angular.io/guide/theming#using-a-pre-built-theme) or set up an extensible [custom theme](https://material.angular.io/guide/theming#defining-a-theme). + You can choose from [prebuilt material design themes](https://material.angular.io/guide/theming#pre-built-themes) or set up an extensible [custom theme](https://material.angular.io/guide/theming#defining-a-theme). 2. Set up global Angular Material typography styles: diff --git a/guides/schematics.md b/guides/schematics.md index ab1b2cd44715..b12ddbd60a84 100644 --- a/guides/schematics.md +++ b/guides/schematics.md @@ -26,7 +26,7 @@ The Angular Material `ng add` schematic helps you set up an Angular CLI project - Ensure [project dependencies](./getting-started#step-1-install-angular-material-angular-cdk-and-angular-animations) are placed in `package.json` - Enable the [BrowserAnimationsModule](./getting-started#step-2-configure-animations) in your app module -- Add either a [prebuilt theme](./theming#using-a-pre-built-theme) or a [custom theme](./theming#defining-a-custom-theme) +- Add either a [prebuilt theme](./theming#pre-built-themes) or a [custom theme](./theming#defining-a-custom-theme) - Add Roboto fonts to your `index.html` - Add the [Material Icon font](./getting-started#step-6-optional-add-material-icons) to your `index.html` - Add global styles to diff --git a/guides/theming.md b/guides/theming.md index bd204dfb19f6..633edf3d268f 100644 --- a/guides/theming.md +++ b/guides/theming.md @@ -91,8 +91,28 @@ more about these terms): ##### Pre-built themes -There are a number of color palettes available in `@angular/material` that can be -used with the `primary` and `tertiary` options: +Angular Material includes several pre-built theme CSS files, each with different palettes selected. +You can use one of these pre-built themes if you don't want to define a custom theme with Sass. + +| Theme | Light or dark? | Specification | +|------------------------|----------------|----------------------------------| +| `azure-blue.css` | Light | Material Design 3 | +| `rose-red.css` | Light | Material Design 3 | +| `cyan-orange.css` | Dark | Material Design 3 | +| `magenta-violet.css` | Dark | Material Design 3 | +| `deeppurple-amber.css` | Light | Material Design 2 | +| `indigo-pink.css` | Light | Material Design 2 | +| `pink-bluegrey.css` | Dark | Material Design 2 | +| `purple-green.css` | Dark | Material Design 2 | + +These files include the CSS for every component in the library. To include only the CSS for a subset +of components, you must use the Sass API detailed in [Defining a theme](#defining-a-theme) above. +You can [reference the source code for these pre-built themes](https://github.com/angular/components/blob/main/src/material/core/theming/prebuilt) to see examples of complete theme definitions. + +##### Pre-defined palettes + +The pre-built themes are based on a set of pre-defined palettes that can be used with the `primary` +and `tertiary` options: - `$red-palette` - `$green-palette` diff --git a/guides/v15-mdc-migration.md b/guides/v15-mdc-migration.md deleted file mode 100644 index 5f4663b1f151..000000000000 --- a/guides/v15-mdc-migration.md +++ /dev/null @@ -1,683 +0,0 @@ -# Migrating to MDC-based Angular Material Components - -In Angular Material v15 and later, many of the components have been refactored to be based on the official -[Material Design Components for Web (MDC)](https://github.com/material-components/material-components-web). -The components from the following imports have been refactored: - -| Import path | Summary of changes | -|------------------------------------|------------------------------------------------------| -| @angular/material/autocomplete | Style changes only | -| @angular/material/button | Style changes, API changes | -| @angular/material/card | Style changes only | -| @angular/material/checkbox | Style changes, changes to event behavior | -| @angular/material/chips | Complete rewrite | -| @angular/material/core | Style changes only | -| @angular/material/dialog | Style changes, changes to change detection behavior | -| @angular/material/form-field | Style changes, some appearances removed, API changes | -| @angular/material/input | Style changes only | -| @angular/material/list | Style changes, API changes | -| @angular/material/menu | Style changes, API changes | -| @angular/material/paginator | Style changes only | -| @angular/material/progress-bar | Style changes only | -| @angular/material/progress-spinner | Style changes only | -| @angular/material/radio | Style changes only | -| @angular/material/select | Style changes only | -| @angular/material/slide-toggle | Style changes only | -| @angular/material/slider | Complete rewrite | -| @angular/material/snack-bar | Style changes, API changes | -| @angular/material/table | Style changes only | -| @angular/material/tabs | Style changes, API changes | -| @angular/material/tooltip | Style changes only | - -The refactored components offer several benefits over the old implementations, including: -* Improved accessibility -* Better adherence to the Material Design spec -* Faster adoption of future versions of the Material Design spec, due to being based on common - infrastructure - -## What has changed? - -The new components have different internal DOM and CSS styles. However, most of the TypeScript APIs -and component/directive selectors for the new components have been kept as close as possible to the -old implementation. This makes it straightforward to migrate your application and get it running -with the new components. - -Due to the new DOM and CSS, you will likely find that some styles in your application need to be -adjusted, particularly if your CSS is overriding styles on internal elements on any of the migrated -components. - -There are a few components with larger changes to their APIs that were necessary in order to -integrate with MDC. These components include: -* form-field -* chips -* slider -* list - -See below for a [comprehensive list of changes](#comprehensive-list-of-changes) for all components. - -The old implementation of each new component is now deprecated, but still available from a "legacy" -import. For example, you can import the old `mat-button` implementation can be used by importing the -legacy button module. - -```ts -import {MatLegacyButtonModule} from '@angular/material/legacy-button'; -``` - -## How to Migrate - -You can start your migration by running Angular Material's automated refactoring tool. This tool, -implemented as an [Angular Schematic](https://angular.io/guide/schematics), updates the majority -your code to the new component versions. While some follow-up is necessary, you can reduce the -manual effort by following these best practices: - -You can reduce the amount of manual effort needed by ensuring that your application follows good -practices before migrating. -* Avoid overriding styles on internal Angular Material elements in your CSS as much as possible. If - you find yourself frequently overriding styles on internal elements, consider using a component - that is designed for more style customization, such as the ones available in the - [Angular CDK](/cdk). -* Use [component harnesses](/guide/using-component-harnesses) to interact with Angular Material - components in tests rather than inspecting internal elements, properties, or methods of the - component. Using component harnesses makes your tests easier to understand and more robust to - changes in Angular Material - -### 1. Update to Angular Material v16 - -Angular Material includes a schematic to help migrate applications to use the new MDC-based -components. To get started, upgrade your application to Angular Material 16. - -```shell -ng update @angular/material@16 -``` - -As part of this update, a schematic will run to automatically move your application to use the -"legacy" imports containing the old component implementations. This provides a quick path to getting -your application running on v16 with minimal manual changes. - -### 2. Run the migration tool - -After upgrading to v16, you can run the migration tool to switch from the legacy component -implementations to the new MDC-based ones. - -```shell -ng generate @angular/material:mdc-migration -``` - -This command updates your TypeScript, styles, and templates to the new implementations, updating as -much as it can automatically. - -#### Running a Partial Migration - -Depending on the size and complexity of your application, you may want to migrate a single component -or small group of components at a time, rather than all components at once. - -You may also want to migrate your app one module at a time instead of all together. You can use both -the old implementation and new implementation in the same application, as long as they aren't used -in the same `NgModule`. - -The script will prompt you for the directory and components you want to migrate. - -### 3. Check for TODOs left by the migration tool. - -In situations where the migration tool is not able to automatically update your code, it will -attempt to add comments for a human to follow up. These TODO comments follow a common format, so -they can be easily identified. - -```ts -// TODO(mdc-migration): ... -``` - -To search for all comments left by the migration tool, search for `TODO(mdc-migration):` in your -IDE. - -### 4. Verify Your Application - -After running the migration and addressing the TODOs, manually verify that everything is working -correctly. - -Run your tests and confirm that they pass. It's possible that your tests depended on internal DOM or -async timing details of the old component implementations and may need to be updated. If you find -you need to update some tests, consider using [component harnesses](./using-component-harnesses) to -make the tests more robust. - -Run your application and verify that the new components look right. Due to the changes in internal -DOM and CSS of the components, you may need to tweak some of your application's styles. - -## Comprehensive List of Changes - -### Library-wide Changes - -* Component size, color, spacing, shadows, and animations all change slightly across the board. - These changes generally improve spec-compliance and accessibility. - -* The DOM structure for all components has changed to improve accessibility and better follow the - Material Design spec. - -* CSS classes applied to components use the `mat-mdc-` prefix, whereas before it was simply a `mat-` - prefix. Elements that roughly correspond to element in the old implementation have been given the - same class name (aside from the prefix). For example, the button’s host class is `mat-mdc-button` - instead of `mat-button`. However, not all elements in the previous implementation have an - equivalent element in the new implementation. - -* The styles associated with the `mat-typography` class are no longer generated automatically. You - have to include them using the `mat.typography-hierarchy` mixin. - -### Theming - -* Default typography levels defined by `mat.define-typography-config` have been updated to reflect - changes to the Material Design spec. - -* All components now have themeable density. Styles for the default density level (0) will be - included by default when you include a theme mixin. - - ```scss - @use '@angular/material' as mat; - - $theme: mat.define-light-theme(( - color: ... - )); - - // Adds density level 0 styles - @include mat.all-component-themes($theme); - ``` - - If you prefer a different default density level, you can set it in your theme config: - - - ```scss - $theme: mat.define-light-theme(( - color: ..., - density: -1 - )); - ``` - -### Autocomplete - -* Long options now wrap instead of truncating. - -* Option heights are no longer capped at `48px`. - -* Option list now has an `8px` top and bottom padding. - -* Options list now has an animation when opening and closing. - -### Button - -* Icon button height and width are `48px` instead of `40px`. - -* State colors (hover, focus, active) are slightly different to improve text contrast ratios. - -* Letter-spacing is `1.25px` instead of `normal`. - -* FAB supports text with the `extended` input attribute. - -* Theming mixins are split into three separate mixins: - - Normal button (default, raised, stroked, flat): `mat.mdc-button-theme` - - Icon button: `mat.mdc-icon-button-theme` - - FAB: `mat.mdc-fab-theme` - -* Icons in the button content are placed before the button text. Add the `iconPositionEnd` attribute to place them after the button text. - -* Icons in the button content inherit the text `font-size`. Buttons with only icons and no text do - not align properly (this does not apply to the icon-button). - -### Card - -* By default, mat-card does not apply any internal padding. Instead, this padding is defined on the - card content areas: ``, ``, and ``. - -* `` no longer sets any typography styles, users are free to add whatever - typography styles make sense for their application, either to `` itself or any - child elements as appropriate. For example: - - ```scss - @use '@angular/material' as mat; - @include mat.typography-hierarchy(); - ``` - - ```html - - ... - - ``` - -### Checkbox - -* Clicks on the checkbox now trigger directly on the native checkbox element rather than a shim div. - Native checkboxes have bizarre behavior when calling `preventDefault` on their `click` event, so - users should not call `preventDefault` on `click`. - -* Checkbox touch targets are larger, now 40px instead of 16px, which is more accessible. Be sure to - allow enough space in your layout so that the touch target does not overlap other components. If - you are not concerned with accessibility you can match the previous size by using density -1 for - the checkbox. - - ```scss - @use '@angular/material' as mat; - @include mat.checkbox-density(-1); - ``` - -* Checkbox color may be changed to white or black due to a change in heuristics based on the - application’s theme. Previously, the check’s color would be set to the theme’s background color. - With MDC, it is determined by whether white or black has the most contrast against the primary - color. - -* Focus state is slightly darker, improving contrast ratio. - -* Text styles are not inherited; you will need to specifically target the checkbox’s `label` to - override typography properties. - -* After toggling a checkbox with the mouse, the ripple will remain visible instead of animating out. - -### Chips - -* Chips used to be directives, but they're now components. This means that they can't be applied to - other components anymore. -* The chips component has been split into multiple variants corresponding with more appropriate - interaction patterns for accessibility. The original `mat-chip-list` used `role="listbox"`, but - this interaction pattern is not suited for all use-cases. The new chips have: - - * `` with `` - this is the closest to the previous interaction - pattern. This is the only variant that supports selection state for chips. This pattern aligns - with the filter chips pattern specified in the Material Design spec. This pattern should be used - when you want the user to select one or more values from a list of options. - - * `` with `` - this pattern should be used for any text input + chips - interaction. - - * `` with `` - this variant has no accessibility pattern and assumes one - will be applied at the application level. This allows the application to implement a custom - accessibility pattern with the chips visuals. - -* The migration tool always changes the legacy `` to `` to minimize - differences before and after. You should separately consider changing to `` or - `` on a case-by-case basis. See [Chips Interaction Patterns]( - /components/chips/overview#interaction-patterns) for more guidence on - choosing the appropriate component for your use case. - -### Dialog - -* The `.mat-dialog-container` does not contain a 24px padding anymore. Instead, the inner dialog - directives are responsible for adding the right padding. This will be apparent if your dialog does - not use any of the directives like ``. - -* `mat-dialog-content` uses the font-settings specified by the Material Design spec, which includes - a rather roomy line-height. If you have an information-dense dialog that doesn't look good with - these settings, you can avoid using `` and just use a div with custom padding, - or use custom typography settings that can be applied with the `mat.mdc-dialog-typography` mixin. - -* The old dialog triggered an extra change detection, which may have masked change detection issues - in your application that need to be fixed when migrating. - -### Form Field - -* The "legacy" and "standard" form-field appearance settings no longer exist, as these have been - dropped from the Material Design spec. - -* The removed "legacy" appearance promoted input placeholders to the floating label if the label was - not specified. All newer appearance settings require explicitly specifying a `` if one - was not provided before. This change addresses an accessibility best practice of not using labels - and placeholders interchangeably. - -* By default, MatFormField still reserves exactly one line of space below the field for hint or - error text. However, there is a new option `@Input() subscriptSizing: 'fixed'|'dynamic'`. When - this setting is set to `fixed` (default), the form-field reserves enough space in the layout to - show one line of hint or error text. When set to `dynamic`, the form-field expands and contracts - the amount of space it takes in the layout to fit the error / hint that is currently shown. - -* The text inside `` is larger and darker in order to meet W3C text guidelines. - -* While the previous form-field had a single directive for prefixes (`matPrefix`) and a single - directive for suffixes (`matSuffix`), the MDC-based form-field distinguishes between text - prefix/suffixes which are baseline aligned with the input text, and icon prefix/suffixes which are - center aligned in the form-field. Use `matTextPrefix` or `matTextSuffix` to indicate a text - prefix/suffix, and `matIconPrefix` or `matIconSuffix` to indicate an icon prefix/suffix. The old - `matSuffix` and `matPrefix` APIs will behave like icons, though they are now deprecated. - -* The `floatLabel` input no longer accepts `'never'`. `floatLabel="never"` was only supported by the - legacy form-field appearance which has been dropped. It was used to achieve a floating label that - behaved like a placeholder. If you need this behavior, use the `placeholder` property on `` - instead. - -* Custom form field controls may need their styles adjusted to account for the fact that the - surrounding form field DOM and styles have changed. - -### Input - -* MatInput must be inside ``. Previously it was (unintentionally) possible to use an - `` without the form field if the page loaded form field styles elsewhere. - -* The MDC-based MatInput hides the native calendar picker indicator associated with - ``, if you want this indicator to appear for your inputs, use the - following styles: - - ```scss - input.mat-mdc-input-element::-webkit-calendar-picker-indicator { - display: block; - } - ``` - -### List - -* The API has been reworked to support text wrapping and better integration with the Material Design - specification. - -* Previously, list items were commonly created using multiple `span` elements with the `matLine` - directive applied. Each `span` resulting in a line, and the first one becoming the primary line. - With the new API, the `matLine` directive has been split into two more granular and meaningful - directives: - * `matListItemTitle` - * `matListItemLine` - -* Text outside of a `matListItemLine` (so-called "unscoped content") will result in an additional - line being acquired (as if the content was put into a line). - - ```html - - Title - Second line - - ``` - -* The list automatically infers the number of lines of text content. For example, in the snippet - above, the list item renders space for two lines. With the new API, you can set an explicit number - of lines on the `` to manually control wrapping. - - ```html - - Title - This text will wrap into the third line. Space for three lines is acquired by the - list item. - - ``` - - Note that text inside a `matListItemTitle` or `matListItemLine` will never wrap. Only unscoped - content will wrap/take up the remaining space based on explicit number of lines provided. - -* Aside from the differences in how lines are composed, some other directives have been renamed to - use more explicit naming: - * `matListIcon` is now `matListItemIcon` - * `matListAvatar` is now `matListItemAvatar` - -* Lastly, also a new directive (`matListItemMeta`) is available to put content into the meta section - of a list item (usually the end of the list item). Previously unscoped content in a list item was - put into the meta section. - -* Recommended migration steps for common use of a list item: - 1. Change the first `matLine` to `matListItemTitle` - 2. Change all other `matLine`'s to `matListItemLine` - 3. Change all `matListIcon` to `matListItemIcon` - 4. Change all `matListAvatar` to `matListItemAvatar` - 5. Wrap all unscoped content (content outside a `matLine`) in a `matListItemMeta` container. - -### Menu - -* The icon for a menu item appears before the text, regardless of the order in the DOM. - - * If you have a piece of content such as an `` that you want to use in place of a - `` use `ngProjectAs="mat-icon"` to project it into the icon slot. - - * If you need your icon to appear at the end of the item (not officially supported by the spec) - you can wrap both the text and your icon in a span, for example: - - ```html - - Text - end_icon - - ``` - -* The text in menu items wraps instead of being hidden with an ellipses. - -* Menu item heights are no longer capped at `48px`. - -* Menu elevation starts from level 8, instead of level 4. - -### Option / Optgroup - -* Long options now wrap instead of truncating with an ellipsis. - -* Option heights are no longer capped at `48px`. - -### Paginator - -* The form-field inside of `mat-paginator` only supports the `appearance` options offered by the new - form-field (`fill` and `outline`). - -### Progress Bar - -* Visibility on internal elements is now set to `visible`. Setting `visibility: hidden` will no - longer hide all internal elements. Instead, style it with `opacity: 0`, `display: none`, or - remove it completely with `ngIf`. - -* Height is always set to 4px and does not get shorter or taller using `height` styles. - -### Progress Spinner - -* Host element is no longer `display: block` which may affect layout. To fix layout issues add - `display: block` back to the element. - -### Radio - -* Radio button labels are no longer `width: 100%`. This helps prevent users from accidentally - selecting a radio when clicking on whitespace that appears inert on the page. - -* Labels are smaller and further away from the radio button to align with the Material Design spec. - -* The touch target is now much larger and more accessible. Be sure to allow enough space in your - layout so that the touch target does not overlap other components. If you are not concerned with - accessibility you can match the previous size by using density -1 for the radio. - - ```scss - @use '@angular/material' as mat; - @include mat.radio-density(-1); - ``` - -### Select - -* `MatSelect` no longer aligns the selected option in the dropdown menu with the trigger text. - -* Long options now wrap instead of truncating. - -* Option heights are no longer capped at `48px`. - -* Option list now has an `8px` top and bottom padding. - -* Option list animation has changed. - -* Previously the dropdown menu width could be wider than the parent form-field, but now the dropdown - is the same width as the form-field - -### Slide Toggle - -* To improve accessibility, the MDC-based version uses ` @@ -28,7 +28,7 @@
Icon with a badge - home + home diff --git a/src/components-examples/material/button-toggle/BUILD.bazel b/src/components-examples/material/button-toggle/BUILD.bazel index 801193d03f94..f90609b1be27 100644 --- a/src/components-examples/material/button-toggle/BUILD.bazel +++ b/src/components-examples/material/button-toggle/BUILD.bazel @@ -17,6 +17,7 @@ ng_module( "//src/cdk/testing/testbed", "//src/material/button-toggle", "//src/material/button-toggle/testing", + "//src/material/checkbox", "//src/material/icon", "@npm//@angular/platform-browser", "@npm//@types/jasmine", diff --git a/src/components-examples/material/button-toggle/button-toggle-appearance/button-toggle-appearance-example.ts b/src/components-examples/material/button-toggle/button-toggle-appearance/button-toggle-appearance-example.ts index 02eee9db2ac6..ea695d7d122a 100644 --- a/src/components-examples/material/button-toggle/button-toggle-appearance/button-toggle-appearance-example.ts +++ b/src/components-examples/material/button-toggle/button-toggle-appearance/button-toggle-appearance-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatButtonToggleModule} from '@angular/material/button-toggle'; /** @@ -10,5 +10,6 @@ import {MatButtonToggleModule} from '@angular/material/button-toggle'; styleUrl: 'button-toggle-appearance-example.css', standalone: true, imports: [MatButtonToggleModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ButtonToggleAppearanceExample {} diff --git a/src/components-examples/material/button-toggle/button-toggle-exclusive/button-toggle-exclusive-example.css b/src/components-examples/material/button-toggle/button-toggle-exclusive/button-toggle-exclusive-example.css deleted file mode 100644 index d21ca3ce57fb..000000000000 --- a/src/components-examples/material/button-toggle/button-toggle-exclusive/button-toggle-exclusive-example.css +++ /dev/null @@ -1,3 +0,0 @@ -.example-selected-value { - margin: 15px 0; -} diff --git a/src/components-examples/material/button-toggle/button-toggle-exclusive/button-toggle-exclusive-example.html b/src/components-examples/material/button-toggle/button-toggle-exclusive/button-toggle-exclusive-example.html deleted file mode 100644 index 26ca16ada374..000000000000 --- a/src/components-examples/material/button-toggle/button-toggle-exclusive/button-toggle-exclusive-example.html +++ /dev/null @@ -1,15 +0,0 @@ - - - format_align_left - - - format_align_center - - - format_align_right - - - format_align_justify - - -
Selected value: {{group.value}}
diff --git a/src/components-examples/material/button-toggle/button-toggle-exclusive/button-toggle-exclusive-example.ts b/src/components-examples/material/button-toggle/button-toggle-exclusive/button-toggle-exclusive-example.ts deleted file mode 100644 index 5333087fb58e..000000000000 --- a/src/components-examples/material/button-toggle/button-toggle-exclusive/button-toggle-exclusive-example.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {Component} from '@angular/core'; -import {MatIconModule} from '@angular/material/icon'; -import {MatButtonToggleModule} from '@angular/material/button-toggle'; - -/** - * @title Exclusive selection - */ -@Component({ - selector: 'button-toggle-exclusive-example', - templateUrl: 'button-toggle-exclusive-example.html', - styleUrl: 'button-toggle-exclusive-example.css', - standalone: true, - imports: [MatButtonToggleModule, MatIconModule], -}) -export class ButtonToggleExclusiveExample {} diff --git a/src/components-examples/material/button-toggle/button-toggle-forms/button-toggle-forms-example.ts b/src/components-examples/material/button-toggle/button-toggle-forms/button-toggle-forms-example.ts index 5b327e5451b2..2ea7301793ba 100644 --- a/src/components-examples/material/button-toggle/button-toggle-forms/button-toggle-forms-example.ts +++ b/src/components-examples/material/button-toggle/button-toggle-forms/button-toggle-forms-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {MatButtonToggleModule} from '@angular/material/button-toggle'; @@ -10,6 +10,7 @@ import {MatButtonToggleModule} from '@angular/material/button-toggle'; templateUrl: 'button-toggle-forms-example.html', standalone: true, imports: [MatButtonToggleModule, FormsModule, ReactiveFormsModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ButtonToggleFormsExample { fontStyleControl = new FormControl(''); diff --git a/src/components-examples/material/button-toggle/button-toggle-harness/button-toggle-harness-example.ts b/src/components-examples/material/button-toggle/button-toggle-harness/button-toggle-harness-example.ts index 485561846535..d0def6535c17 100644 --- a/src/components-examples/material/button-toggle/button-toggle-harness/button-toggle-harness-example.ts +++ b/src/components-examples/material/button-toggle/button-toggle-harness/button-toggle-harness-example.ts @@ -1,4 +1,4 @@ -import {Component, signal} from '@angular/core'; +import {ChangeDetectionStrategy, Component, signal} from '@angular/core'; import {MatButtonToggleAppearance, MatButtonToggleModule} from '@angular/material/button-toggle'; /** @@ -9,6 +9,7 @@ import {MatButtonToggleAppearance, MatButtonToggleModule} from '@angular/materia templateUrl: 'button-toggle-harness-example.html', standalone: true, imports: [MatButtonToggleModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ButtonToggleHarnessExample { disabled = signal(false); diff --git a/src/components-examples/material/button-toggle/button-toggle-mode/button-toggle-mode-example.html b/src/components-examples/material/button-toggle/button-toggle-mode/button-toggle-mode-example.html index aade97177e89..1835522735b6 100644 --- a/src/components-examples/material/button-toggle/button-toggle-mode/button-toggle-mode-example.html +++ b/src/components-examples/material/button-toggle/button-toggle-mode/button-toggle-mode-example.html @@ -1,13 +1,39 @@ -

Single selection

- - Red - Green - Blue - - -

Multiple selection

- - Flour - Eggs - Sugar - +
+ + Hide Single Selection Indicator + + + Hide Multiple Selection Indicator + +
+
+

Single selection

+ + Red + Green + Blue + +
+
+

Multiple selection

+ + Flour + Eggs + Sugar + +
diff --git a/src/components-examples/material/button-toggle/button-toggle-mode/button-toggle-mode-example.ts b/src/components-examples/material/button-toggle/button-toggle-mode/button-toggle-mode-example.ts index 6abdcd3a90ed..c6543e025326 100644 --- a/src/components-examples/material/button-toggle/button-toggle-mode/button-toggle-mode-example.ts +++ b/src/components-examples/material/button-toggle/button-toggle-mode/button-toggle-mode-example.ts @@ -1,5 +1,6 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component, signal} from '@angular/core'; import {MatButtonToggleModule} from '@angular/material/button-toggle'; +import {MatCheckboxModule} from '@angular/material/checkbox'; /** * @title Button toggle selection mode @@ -8,6 +9,18 @@ import {MatButtonToggleModule} from '@angular/material/button-toggle'; selector: 'button-toggle-mode-example', templateUrl: 'button-toggle-mode-example.html', standalone: true, - imports: [MatButtonToggleModule], + imports: [MatButtonToggleModule, MatCheckboxModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) -export class ButtonToggleModeExample {} +export class ButtonToggleModeExample { + hideSingleSelectionIndicator = signal(false); + hideMultipleSelectionIndicator = signal(false); + + toggleSingleSelectionIndicator() { + this.hideSingleSelectionIndicator.update(value => !value); + } + + toggleMultipleSelectionIndicator() { + this.hideMultipleSelectionIndicator.update(value => !value); + } +} diff --git a/src/components-examples/material/button-toggle/index.ts b/src/components-examples/material/button-toggle/index.ts index 269cb42bb5de..32998f7ef1fc 100644 --- a/src/components-examples/material/button-toggle/index.ts +++ b/src/components-examples/material/button-toggle/index.ts @@ -1,5 +1,4 @@ export {ButtonToggleAppearanceExample} from './button-toggle-appearance/button-toggle-appearance-example'; -export {ButtonToggleExclusiveExample} from './button-toggle-exclusive/button-toggle-exclusive-example'; export {ButtonToggleOverviewExample} from './button-toggle-overview/button-toggle-overview-example'; export {ButtonToggleHarnessExample} from './button-toggle-harness/button-toggle-harness-example'; export {ButtonToggleFormsExample} from './button-toggle-forms/button-toggle-forms-example'; diff --git a/src/components-examples/material/button/button-overview/button-overview-example.html b/src/components-examples/material/button/button-overview/button-overview-example.html index 67720f49024b..feb62a8caf2e 100644 --- a/src/components-examples/material/button/button-overview/button-overview-example.html +++ b/src/components-examples/material/button/button-overview/button-overview-example.html @@ -2,9 +2,6 @@
Basic
- - - Link
@@ -14,9 +11,6 @@
Raised
- - - Link
@@ -26,9 +20,6 @@
Stroked
- - - Link
@@ -38,9 +29,6 @@
Flat
- - - Link
@@ -53,15 +41,6 @@ - - - @@ -74,20 +53,10 @@
-
-
- -
-
- -
-
+
+
+ +
+
Extended Fab
+
+
-
-
+
diff --git a/src/components-examples/material/button/button-types/button-types-example.css b/src/components-examples/material/button/button-types/button-types-example.css deleted file mode 100644 index 74bc6ae390ab..000000000000 --- a/src/components-examples/material/button/button-types/button-types-example.css +++ /dev/null @@ -1,8 +0,0 @@ -.example-button-row button, -.example-button-row a { - margin-right: 8px; -} - -.example-disabled { - display: inline-block; -} diff --git a/src/components-examples/material/button/button-types/button-types-example.html b/src/components-examples/material/button/button-types/button-types-example.html deleted file mode 100644 index b04112865955..000000000000 --- a/src/components-examples/material/button/button-types/button-types-example.html +++ /dev/null @@ -1,129 +0,0 @@ -

Basic Buttons

-
- - - - - - Link -
- -

Raised Buttons

-
- - - - - - Link -
- -

Stroked Buttons

-
- - - - - - Link -
- -

Flat Buttons

-
- - - - - - Link -
- -

Icon Buttons

-
- - - - -
- -
- - favorite - -
- -

Fab Buttons

-
- - - -
- -
- - favorite - -
- -

Mini Fab Buttons

-
- - - -
- -
- - favorite - -
- -

Extended Fab

-
- - - - - - favorite - Link - -
diff --git a/src/components-examples/material/button/button-types/button-types-example.ts b/src/components-examples/material/button/button-types/button-types-example.ts deleted file mode 100644 index 3066cc45fa1e..000000000000 --- a/src/components-examples/material/button/button-types/button-types-example.ts +++ /dev/null @@ -1,16 +0,0 @@ -import {Component} from '@angular/core'; -import {MatIconModule} from '@angular/material/icon'; -import {MatTooltipModule} from '@angular/material/tooltip'; -import {MatButtonModule} from '@angular/material/button'; - -/** - * @title Button varieties - */ -@Component({ - selector: 'button-types-example', - templateUrl: 'button-types-example.html', - styleUrl: 'button-types-example.css', - standalone: true, - imports: [MatButtonModule, MatTooltipModule, MatIconModule], -}) -export class ButtonTypesExample {} diff --git a/src/components-examples/material/button/index.ts b/src/components-examples/material/button/index.ts index 73a5072bd973..4557e8edb62e 100644 --- a/src/components-examples/material/button/index.ts +++ b/src/components-examples/material/button/index.ts @@ -1,4 +1,3 @@ export {ButtonOverviewExample} from './button-overview/button-overview-example'; -export {ButtonTypesExample} from './button-types/button-types-example'; export {ButtonDisabledInteractiveExample} from './button-disabled-interactive/button-disabled-interactive-example'; export {ButtonHarnessExample} from './button-harness/button-harness-example'; diff --git a/src/components-examples/material/card/BUILD.bazel b/src/components-examples/material/card/BUILD.bazel index 26e607bbe5a6..a946d615e6aa 100644 --- a/src/components-examples/material/card/BUILD.bazel +++ b/src/components-examples/material/card/BUILD.bazel @@ -19,6 +19,7 @@ ng_module( "//src/material/button/testing", "//src/material/card", "//src/material/card/testing", + "//src/material/chips", "//src/material/divider", "//src/material/progress-bar", "@npm//@angular/platform-browser", diff --git a/src/components-examples/material/card/card-actions/card-actions-example.html b/src/components-examples/material/card/card-actions/card-actions-example.html index e731bd9c17e9..10db36f2ce0d 100644 --- a/src/components-examples/material/card/card-actions/card-actions-example.html +++ b/src/components-examples/material/card/card-actions/card-actions-example.html @@ -1,21 +1,19 @@ - + - Actions Buttons - Start + Australian Shepherd + Herding group - - +
- + - Actions Buttons - End + Poodle + Non-sporting group - - + diff --git a/src/components-examples/material/card/card-actions/card-actions-example.ts b/src/components-examples/material/card/card-actions/card-actions-example.ts index abd274159130..567cf44fe0bb 100644 --- a/src/components-examples/material/card/card-actions/card-actions-example.ts +++ b/src/components-examples/material/card/card-actions/card-actions-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; import {MatCardModule} from '@angular/material/card'; @@ -10,5 +10,6 @@ import {MatCardModule} from '@angular/material/card'; templateUrl: 'card-actions-example.html', standalone: true, imports: [MatCardModule, MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CardActionsExample {} diff --git a/src/components-examples/material/card/card-fancy/card-fancy-example.html b/src/components-examples/material/card/card-fancy/card-fancy-example.html index e7fdeb8efe16..f4f90b2553df 100644 --- a/src/components-examples/material/card/card-fancy/card-fancy-example.html +++ b/src/components-examples/material/card/card-fancy/card-fancy-example.html @@ -1,4 +1,4 @@ - +
Shiba Inu diff --git a/src/components-examples/material/card/card-fancy/card-fancy-example.ts b/src/components-examples/material/card/card-fancy/card-fancy-example.ts index 31ae97926e41..b6543dd6c427 100644 --- a/src/components-examples/material/card/card-fancy/card-fancy-example.ts +++ b/src/components-examples/material/card/card-fancy/card-fancy-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; import {MatCardModule} from '@angular/material/card'; @@ -11,5 +11,6 @@ import {MatCardModule} from '@angular/material/card'; styleUrl: 'card-fancy-example.css', standalone: true, imports: [MatCardModule, MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CardFancyExample {} diff --git a/src/components-examples/material/card/card-footer/card-footer-example.css b/src/components-examples/material/card/card-footer/card-footer-example.css index 81749a89098e..744d54a6a412 100644 --- a/src/components-examples/material/card/card-footer/card-footer-example.css +++ b/src/components-examples/material/card/card-footer/card-footer-example.css @@ -2,3 +2,6 @@ max-width: 400px; } +.example-card-footer { + padding: 16px; +} diff --git a/src/components-examples/material/card/card-footer/card-footer-example.html b/src/components-examples/material/card/card-footer/card-footer-example.html index 62a8818233dd..022068f9d778 100644 --- a/src/components-examples/material/card/card-footer/card-footer-example.html +++ b/src/components-examples/material/card/card-footer/card-footer-example.html @@ -1,18 +1,15 @@ - + - Dog Breed - Shiba Inu + Chihuahua -

This card has divider and indeterminate progress as footer

-

{{ longText }}

- +

{{longText}}

- - - - - - + + + charming + graceful + sassy +
diff --git a/src/components-examples/material/card/card-footer/card-footer-example.ts b/src/components-examples/material/card/card-footer/card-footer-example.ts index 5fbca7b37165..425a6b93feca 100644 --- a/src/components-examples/material/card/card-footer/card-footer-example.ts +++ b/src/components-examples/material/card/card-footer/card-footer-example.ts @@ -1,8 +1,7 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatProgressBarModule} from '@angular/material/progress-bar'; -import {MatButtonModule} from '@angular/material/button'; -import {MatDividerModule} from '@angular/material/divider'; import {MatCardModule} from '@angular/material/card'; +import {MatChipsModule} from '@angular/material/chips'; /** * @title Card with footer @@ -12,10 +11,11 @@ import {MatCardModule} from '@angular/material/card'; templateUrl: 'card-footer-example.html', styleUrl: 'card-footer-example.css', standalone: true, - imports: [MatCardModule, MatDividerModule, MatButtonModule, MatProgressBarModule], + imports: [MatCardModule, MatChipsModule, MatProgressBarModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CardFooterExample { - longText = `The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog - from Japan. A small, agile dog that copes very well with mountainous terrain, the Shiba Inu was - originally bred for hunting.`; + longText = `The Chihuahua is a Mexican breed of toy dog. It is named for the + Mexican state of Chihuahua and is among the smallest of all dog breeds. It is + usually kept as a companion animal or for showing.`; } diff --git a/src/components-examples/material/card/card-harness/card-harness-example.spec.ts b/src/components-examples/material/card/card-harness/card-harness-example.spec.ts index 52dedc84ea6b..a10d32c1b1e9 100644 --- a/src/components-examples/material/card/card-harness/card-harness-example.spec.ts +++ b/src/components-examples/material/card/card-harness/card-harness-example.spec.ts @@ -31,7 +31,7 @@ describe('CardHarnessExample', () => { it('should act as a harness loader for user content', async () => { const card = await loader.getHarness(MatCardHarness.with({title: 'Shiba Inu'})); - const footerSubcomponents = (await card.getAllHarnesses(MatButtonHarness)) ?? []; + const footerSubcomponents = await card.getAllHarnesses(MatButtonHarness); expect(footerSubcomponents.length).toBe(2); }); }); diff --git a/src/components-examples/material/card/card-harness/card-harness-example.ts b/src/components-examples/material/card/card-harness/card-harness-example.ts index b68e1ba071b6..6ef2013c7ddb 100644 --- a/src/components-examples/material/card/card-harness/card-harness-example.ts +++ b/src/components-examples/material/card/card-harness/card-harness-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; import {MatCardModule} from '@angular/material/card'; @@ -10,5 +10,6 @@ import {MatCardModule} from '@angular/material/card'; templateUrl: 'card-harness-example.html', standalone: true, imports: [MatCardModule, MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CardHarnessExample {} diff --git a/src/components-examples/material/card/card-media-size/card-media-size-example.html b/src/components-examples/material/card/card-media-size/card-media-size-example.html index 8b04a3ed3405..891f4fde82c5 100644 --- a/src/components-examples/material/card/card-media-size/card-media-size-example.html +++ b/src/components-examples/material/card/card-media-size/card-media-size-example.html @@ -1,5 +1,5 @@ - + Shiba Inu @@ -12,7 +12,7 @@ - + Shiba Inu @@ -25,7 +25,7 @@ - + Shiba Inu @@ -38,7 +38,7 @@ - + Shiba Inu diff --git a/src/components-examples/material/card/card-media-size/card-media-size-example.ts b/src/components-examples/material/card/card-media-size/card-media-size-example.ts index aa1e909a1a28..f82f2398e10f 100644 --- a/src/components-examples/material/card/card-media-size/card-media-size-example.ts +++ b/src/components-examples/material/card/card-media-size/card-media-size-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatCardModule} from '@angular/material/card'; /** @@ -10,6 +10,7 @@ import {MatCardModule} from '@angular/material/card'; styleUrl: 'card-media-size-example.css', standalone: true, imports: [MatCardModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CardMediaSizeExample { longText = `The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog diff --git a/src/components-examples/material/card/card-overview/card-overview-example.html b/src/components-examples/material/card/card-overview/card-overview-example.html index 5c8fe56a1124..6805d4fb8214 100644 --- a/src/components-examples/material/card/card-overview/card-overview-example.html +++ b/src/components-examples/material/card/card-overview/card-overview-example.html @@ -1,3 +1,3 @@ - + Simple card diff --git a/src/components-examples/material/card/card-overview/card-overview-example.ts b/src/components-examples/material/card/card-overview/card-overview-example.ts index 652b71d8c92f..770ab06d3841 100644 --- a/src/components-examples/material/card/card-overview/card-overview-example.ts +++ b/src/components-examples/material/card/card-overview/card-overview-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatCardModule} from '@angular/material/card'; /** @@ -9,5 +9,6 @@ import {MatCardModule} from '@angular/material/card'; templateUrl: 'card-overview-example.html', standalone: true, imports: [MatCardModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CardOverviewExample {} diff --git a/src/components-examples/material/card/card-subtitle/card-subtitle-example.css b/src/components-examples/material/card/card-subtitle/card-subtitle-example.css deleted file mode 100644 index 82c7afd666f7..000000000000 --- a/src/components-examples/material/card/card-subtitle/card-subtitle-example.css +++ /dev/null @@ -1,3 +0,0 @@ -.example-card { - max-width: 400px; -} diff --git a/src/components-examples/material/card/card-subtitle/card-subtitle-example.html b/src/components-examples/material/card/card-subtitle/card-subtitle-example.html deleted file mode 100644 index ca7b70720ad5..000000000000 --- a/src/components-examples/material/card/card-subtitle/card-subtitle-example.html +++ /dev/null @@ -1,14 +0,0 @@ - - - Shiba Inu - Dog Breed - - -

This card indeterminates progress bar.

-

{{longText}}

-
- - - - -
diff --git a/src/components-examples/material/card/card-subtitle/card-subtitle-example.ts b/src/components-examples/material/card/card-subtitle/card-subtitle-example.ts deleted file mode 100644 index 0458f769281f..000000000000 --- a/src/components-examples/material/card/card-subtitle/card-subtitle-example.ts +++ /dev/null @@ -1,19 +0,0 @@ -import {Component} from '@angular/core'; -import {MatButtonModule} from '@angular/material/button'; -import {MatCardModule} from '@angular/material/card'; - -/** - * @title Card with sub-title - */ -@Component({ - selector: 'card-subtitle-example', - templateUrl: 'card-subtitle-example.html', - styleUrl: 'card-subtitle-example.css', - standalone: true, - imports: [MatCardModule, MatButtonModule], -}) -export class CardSubtitleExample { - longText = `The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog - from Japan. A small, agile dog that copes very well with mountainous terrain, the Shiba Inu was - originally bred for hunting.`; -} diff --git a/src/components-examples/material/card/index.ts b/src/components-examples/material/card/index.ts index dea80c297097..2c526e731aec 100644 --- a/src/components-examples/material/card/index.ts +++ b/src/components-examples/material/card/index.ts @@ -3,5 +3,4 @@ export {CardOverviewExample} from './card-overview/card-overview-example'; export {CardHarnessExample} from './card-harness/card-harness-example'; export {CardActionsExample} from './card-actions/card-actions-example'; export {CardMediaSizeExample} from './card-media-size/card-media-size-example'; -export {CardSubtitleExample} from './card-subtitle/card-subtitle-example'; export {CardFooterExample} from './card-footer/card-footer-example'; diff --git a/src/components-examples/material/checkbox/checkbox-configurable/checkbox-configurable-example.html b/src/components-examples/material/checkbox/checkbox-configurable/checkbox-configurable-example.html index 4591963c3e23..5e69d1164262 100644 --- a/src/components-examples/material/checkbox/checkbox-configurable/checkbox-configurable-example.html +++ b/src/components-examples/material/checkbox/checkbox-configurable/checkbox-configurable-example.html @@ -27,11 +27,12 @@

Result

+ class="example-margin" + [(ngModel)]="checked" + [(indeterminate)]="indeterminate" + [labelPosition]="labelPosition()" + [disabled]="disabled()" + > I'm a checkbox
diff --git a/src/components-examples/material/checkbox/checkbox-configurable/checkbox-configurable-example.ts b/src/components-examples/material/checkbox/checkbox-configurable/checkbox-configurable-example.ts index 59226280dbc7..988ca6c6ecaa 100644 --- a/src/components-examples/material/checkbox/checkbox-configurable/checkbox-configurable-example.ts +++ b/src/components-examples/material/checkbox/checkbox-configurable/checkbox-configurable-example.ts @@ -1,8 +1,8 @@ -import {Component} from '@angular/core'; -import {MatRadioModule} from '@angular/material/radio'; +import {ChangeDetectionStrategy, Component, model} from '@angular/core'; import {FormsModule} from '@angular/forms'; -import {MatCheckboxModule} from '@angular/material/checkbox'; import {MatCardModule} from '@angular/material/card'; +import {MatCheckboxModule} from '@angular/material/checkbox'; +import {MatRadioModule} from '@angular/material/radio'; /** * @title Configurable checkbox @@ -13,10 +13,11 @@ import {MatCardModule} from '@angular/material/card'; styleUrl: 'checkbox-configurable-example.css', standalone: true, imports: [MatCardModule, MatCheckboxModule, FormsModule, MatRadioModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CheckboxConfigurableExample { - checked = false; - indeterminate = false; - labelPosition: 'before' | 'after' = 'after'; - disabled = false; + readonly checked = model(false); + readonly indeterminate = model(false); + readonly labelPosition = model<'before' | 'after'>('after'); + readonly disabled = model(false); } diff --git a/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.html b/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.html index 016dd3b2fdcf..ec690de63f0f 100644 --- a/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.html +++ b/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.html @@ -1,11 +1,12 @@ + required + [checked]="true" + name="first-name" + value="first-value" + aria-label="First checkbox" +> First - + Second diff --git a/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.spec.ts b/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.spec.ts index fce1d8b50331..a1d933725071 100644 --- a/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.spec.ts +++ b/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.spec.ts @@ -38,7 +38,7 @@ describe('CheckboxHarnessExample', () => { }); it('should toggle checkbox', async () => { - fixture.componentInstance.disabled = false; + fixture.componentRef.setInput('disabled', false); fixture.changeDetectorRef.markForCheck(); const [checkedCheckbox, uncheckedCheckbox] = await loader.getAllHarnesses(MatCheckboxHarness); await checkedCheckbox.toggle(); diff --git a/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.ts b/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.ts index b705d6fb1042..15096bd64c23 100644 --- a/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.ts +++ b/src/components-examples/material/checkbox/checkbox-harness/checkbox-harness-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component, input} from '@angular/core'; import {MatCheckboxModule} from '@angular/material/checkbox'; /** @@ -9,7 +9,8 @@ import {MatCheckboxModule} from '@angular/material/checkbox'; templateUrl: 'checkbox-harness-example.html', standalone: true, imports: [MatCheckboxModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CheckboxHarnessExample { - disabled = true; + readonly disabled = input(true); } diff --git a/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.html b/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.html index ff06d1f31192..c0ef9c350835 100644 --- a/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.html +++ b/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.html @@ -5,21 +5,20 @@
- - {{task.name}} + + {{task().name}}
    - @for (subtask of task.subtasks; track subtask) { + @for (subtask of task().subtasks; track subtask; let i = $index) {
  • - + {{subtask.name}}
  • diff --git a/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.ts b/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.ts index afc6b11d655f..2ec2a90dd804 100644 --- a/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.ts +++ b/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.ts @@ -1,12 +1,10 @@ -import {Component} from '@angular/core'; -import {ThemePalette} from '@angular/material/core'; +import {ChangeDetectionStrategy, Component, computed, signal} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {MatCheckboxModule} from '@angular/material/checkbox'; export interface Task { name: string; completed: boolean; - color: ThemePalette; subtasks?: Task[]; } @@ -19,37 +17,37 @@ export interface Task { styleUrl: 'checkbox-overview-example.css', standalone: true, imports: [MatCheckboxModule, FormsModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CheckboxOverviewExample { - task: Task = { - name: 'Indeterminate', + readonly task = signal({ + name: 'Parent task', completed: false, - color: 'primary', subtasks: [ - {name: 'Primary', completed: false, color: 'primary'}, - {name: 'Accent', completed: false, color: 'accent'}, - {name: 'Warn', completed: false, color: 'warn'}, + {name: 'Child task 1', completed: false}, + {name: 'Child task 2', completed: false}, + {name: 'Child task 3', completed: false}, ], - }; + }); - allComplete: boolean = false; - - updateAllComplete() { - this.allComplete = this.task.subtasks != null && this.task.subtasks.every(t => t.completed); - } - - someComplete(): boolean { - if (this.task.subtasks == null) { + readonly partiallyComplete = computed(() => { + const task = this.task(); + if (!task.subtasks) { return false; } - return this.task.subtasks.filter(t => t.completed).length > 0 && !this.allComplete; - } + return task.subtasks.some(t => t.completed) && !task.subtasks.every(t => t.completed); + }); - setAll(completed: boolean) { - this.allComplete = completed; - if (this.task.subtasks == null) { - return; - } - this.task.subtasks.forEach(t => (t.completed = completed)); + update(completed: boolean, index?: number) { + this.task.update(task => { + if (index === undefined) { + task.completed = completed; + task.subtasks?.forEach(t => (t.completed = completed)); + } else { + task.subtasks![index].completed = completed; + task.completed = task.subtasks?.every(t => t.completed) ?? true; + } + return {...task}; + }); } } diff --git a/src/components-examples/material/checkbox/checkbox-reactive-forms/checkbox-reactive-forms-example.ts b/src/components-examples/material/checkbox/checkbox-reactive-forms/checkbox-reactive-forms-example.ts index 1ef154b96e93..da549269c1c2 100644 --- a/src/components-examples/material/checkbox/checkbox-reactive-forms/checkbox-reactive-forms-example.ts +++ b/src/components-examples/material/checkbox/checkbox-reactive-forms/checkbox-reactive-forms-example.ts @@ -1,6 +1,6 @@ -import {Component} from '@angular/core'; -import {FormBuilder, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {JsonPipe} from '@angular/common'; +import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; +import {FormBuilder, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {MatCheckboxModule} from '@angular/material/checkbox'; /** @title Checkboxes with reactive forms */ @@ -10,13 +10,14 @@ import {MatCheckboxModule} from '@angular/material/checkbox'; styleUrl: 'checkbox-reactive-forms-example.css', standalone: true, imports: [FormsModule, ReactiveFormsModule, MatCheckboxModule, JsonPipe], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CheckboxReactiveFormsExample { - toppings = this._formBuilder.group({ + private readonly _formBuilder = inject(FormBuilder); + + readonly toppings = this._formBuilder.group({ pepperoni: false, extracheese: false, mushroom: false, }); - - constructor(private _formBuilder: FormBuilder) {} } diff --git a/src/components-examples/material/chips/chips-autocomplete/chips-autocomplete-example.html b/src/components-examples/material/chips/chips-autocomplete/chips-autocomplete-example.html index 0e9f4a806f2b..b9d6271c95cd 100644 --- a/src/components-examples/material/chips/chips-autocomplete/chips-autocomplete-example.html +++ b/src/components-examples/material/chips/chips-autocomplete/chips-autocomplete-example.html @@ -2,7 +2,7 @@ Favorite Fruits - @for (fruit of fruits; track fruit) { + @for (fruit of fruits(); track $index) { {{fruit}} } - + diff --git a/src/components-examples/material/chips/chips-input/chips-input-example.ts b/src/components-examples/material/chips/chips-input/chips-input-example.ts index 73bea6995ced..29be44d93f16 100644 --- a/src/components-examples/material/chips/chips-input/chips-input-example.ts +++ b/src/components-examples/material/chips/chips-input/chips-input-example.ts @@ -1,9 +1,9 @@ +import {LiveAnnouncer} from '@angular/cdk/a11y'; import {COMMA, ENTER} from '@angular/cdk/keycodes'; -import {Component, inject} from '@angular/core'; +import {ChangeDetectionStrategy, Component, inject, signal} from '@angular/core'; import {MatChipEditedEvent, MatChipInputEvent, MatChipsModule} from '@angular/material/chips'; -import {MatIconModule} from '@angular/material/icon'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {LiveAnnouncer} from '@angular/cdk/a11y'; +import {MatIconModule} from '@angular/material/icon'; export interface Fruit { name: string; @@ -18,20 +18,20 @@ export interface Fruit { styleUrl: 'chips-input-example.css', standalone: true, imports: [MatFormFieldModule, MatChipsModule, MatIconModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ChipsInputExample { - addOnBlur = true; + readonly addOnBlur = true; readonly separatorKeysCodes = [ENTER, COMMA] as const; - fruits: Fruit[] = [{name: 'Lemon'}, {name: 'Lime'}, {name: 'Apple'}]; - - announcer = inject(LiveAnnouncer); + readonly fruits = signal([{name: 'Lemon'}, {name: 'Lime'}, {name: 'Apple'}]); + readonly announcer = inject(LiveAnnouncer); add(event: MatChipInputEvent): void { const value = (event.value || '').trim(); // Add our fruit if (value) { - this.fruits.push({name: value}); + this.fruits.update(fruits => [...fruits, {name: value}]); } // Clear the input value @@ -39,13 +39,16 @@ export class ChipsInputExample { } remove(fruit: Fruit): void { - const index = this.fruits.indexOf(fruit); - - if (index >= 0) { - this.fruits.splice(index, 1); + this.fruits.update(fruits => { + const index = fruits.indexOf(fruit); + if (index < 0) { + return fruits; + } - this.announcer.announce(`Removed ${fruit}`); - } + fruits.splice(index, 1); + this.announcer.announce(`Removed ${fruit.name}`); + return [...fruits]; + }); } edit(fruit: Fruit, event: MatChipEditedEvent) { @@ -58,9 +61,13 @@ export class ChipsInputExample { } // Edit existing fruit - const index = this.fruits.indexOf(fruit); - if (index >= 0) { - this.fruits[index].name = value; - } + this.fruits.update(fruits => { + const index = fruits.indexOf(fruit); + if (index >= 0) { + fruits[index].name = value; + return [...fruits]; + } + return fruits; + }); } } diff --git a/src/components-examples/material/chips/chips-overview/chips-overview-example.ts b/src/components-examples/material/chips/chips-overview/chips-overview-example.ts index 431aebb8cf93..e541dba4b95f 100644 --- a/src/components-examples/material/chips/chips-overview/chips-overview-example.ts +++ b/src/components-examples/material/chips/chips-overview/chips-overview-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatChipsModule} from '@angular/material/chips'; /** @@ -9,5 +9,6 @@ import {MatChipsModule} from '@angular/material/chips'; templateUrl: 'chips-overview-example.html', standalone: true, imports: [MatChipsModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ChipsOverviewExample {} diff --git a/src/components-examples/material/chips/chips-stacked/chips-stacked-example.html b/src/components-examples/material/chips/chips-stacked/chips-stacked-example.html index 22b676f0ee49..d3273425942b 100644 --- a/src/components-examples/material/chips/chips-stacked/chips-stacked-example.html +++ b/src/components-examples/material/chips/chips-stacked/chips-stacked-example.html @@ -1,5 +1,5 @@ - - @for (chip of availableColors; track chip) { - {{chip.name}} + + @for (dog of bestBoys; track dog) { + {{dog}} } diff --git a/src/components-examples/material/chips/chips-stacked/chips-stacked-example.ts b/src/components-examples/material/chips/chips-stacked/chips-stacked-example.ts index ecc56988b2fc..e95df3c4731f 100644 --- a/src/components-examples/material/chips/chips-stacked/chips-stacked-example.ts +++ b/src/components-examples/material/chips/chips-stacked/chips-stacked-example.ts @@ -1,12 +1,6 @@ import {Component} from '@angular/core'; -import {ThemePalette} from '@angular/material/core'; import {MatChipsModule} from '@angular/material/chips'; -export interface ChipColor { - name: string; - color: ThemePalette; -} - /** * @title Stacked chips */ @@ -18,10 +12,5 @@ export interface ChipColor { imports: [MatChipsModule], }) export class ChipsStackedExample { - availableColors: ChipColor[] = [ - {name: 'none', color: undefined}, - {name: 'Primary', color: 'primary'}, - {name: 'Accent', color: 'accent'}, - {name: 'Warn', color: 'warn'}, - ]; + readonly bestBoys: string[] = ['Samoyed', 'Akita Inu', 'Alaskan Malamute', 'Siberian Husky']; } diff --git a/src/components-examples/material/datepicker/date-range-picker-comparison/date-range-picker-comparison-example.ts b/src/components-examples/material/datepicker/date-range-picker-comparison/date-range-picker-comparison-example.ts index b11f3ef380e0..07ce8e6a5ac0 100644 --- a/src/components-examples/material/datepicker/date-range-picker-comparison/date-range-picker-comparison-example.ts +++ b/src/components-examples/material/datepicker/date-range-picker-comparison/date-range-picker-comparison-example.ts @@ -1,5 +1,5 @@ -import {Component} from '@angular/core'; -import {FormGroup, FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; import {MatFormFieldModule} from '@angular/material/form-field'; @@ -16,13 +16,14 @@ const year = today.getFullYear(); standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatDatepickerModule, FormsModule, ReactiveFormsModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DateRangePickerComparisonExample { - campaignOne = new FormGroup({ + readonly campaignOne = new FormGroup({ start: new FormControl(new Date(year, month, 13)), end: new FormControl(new Date(year, month, 16)), }); - campaignTwo = new FormGroup({ + readonly campaignTwo = new FormGroup({ start: new FormControl(new Date(year, month, 15)), end: new FormControl(new Date(year, month, 19)), }); diff --git a/src/components-examples/material/datepicker/date-range-picker-forms/date-range-picker-forms-example.ts b/src/components-examples/material/datepicker/date-range-picker-forms/date-range-picker-forms-example.ts index 93f7559f0757..907abf773ad0 100644 --- a/src/components-examples/material/datepicker/date-range-picker-forms/date-range-picker-forms-example.ts +++ b/src/components-examples/material/datepicker/date-range-picker-forms/date-range-picker-forms-example.ts @@ -1,9 +1,9 @@ -import {Component} from '@angular/core'; -import {FormGroup, FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {JsonPipe} from '@angular/common'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; /** @title Date range picker forms integration */ @Component({ @@ -12,9 +12,10 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatDatepickerModule, FormsModule, ReactiveFormsModule, JsonPipe], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DateRangePickerFormsExample { - range = new FormGroup({ + readonly range = new FormGroup({ start: new FormControl(null), end: new FormControl(null), }); diff --git a/src/components-examples/material/datepicker/date-range-picker-overview/date-range-picker-overview-example.ts b/src/components-examples/material/datepicker/date-range-picker-overview/date-range-picker-overview-example.ts index 2b59e0a15da3..32e17bdc1cdb 100644 --- a/src/components-examples/material/datepicker/date-range-picker-overview/date-range-picker-overview-example.ts +++ b/src/components-examples/material/datepicker/date-range-picker-overview/date-range-picker-overview-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; import {MatFormFieldModule} from '@angular/material/form-field'; @@ -10,5 +10,6 @@ import {MatFormFieldModule} from '@angular/material/form-field'; standalone: true, imports: [MatFormFieldModule, MatDatepickerModule], providers: [provideNativeDateAdapter()], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DateRangePickerOverviewExample {} diff --git a/src/components-examples/material/datepicker/date-range-picker-selection-strategy/date-range-picker-selection-strategy-example.ts b/src/components-examples/material/datepicker/date-range-picker-selection-strategy/date-range-picker-selection-strategy-example.ts index 075be05b1183..7f18ade38e3f 100644 --- a/src/components-examples/material/datepicker/date-range-picker-selection-strategy/date-range-picker-selection-strategy-example.ts +++ b/src/components-examples/material/datepicker/date-range-picker-selection-strategy/date-range-picker-selection-strategy-example.ts @@ -1,9 +1,9 @@ -import {Component, Injectable} from '@angular/core'; +import {ChangeDetectionStrategy, Component, Injectable} from '@angular/core'; import {DateAdapter, provideNativeDateAdapter} from '@angular/material/core'; import { - MatDateRangeSelectionStrategy, DateRange, MAT_DATE_RANGE_SELECTION_STRATEGY, + MatDateRangeSelectionStrategy, MatDatepickerModule, } from '@angular/material/datepicker'; import {MatFormFieldModule} from '@angular/material/form-field'; @@ -44,5 +44,6 @@ export class FiveDayRangeSelectionStrategy implements MatDateRangeSelectionSt ], standalone: true, imports: [MatFormFieldModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DateRangePickerSelectionStrategyExample {} diff --git a/src/components-examples/material/datepicker/datepicker-actions/datepicker-actions-example.html b/src/components-examples/material/datepicker/datepicker-actions/datepicker-actions-example.html index 460a271dd2d5..29ae1ae580f0 100644 --- a/src/components-examples/material/datepicker/datepicker-actions/datepicker-actions-example.html +++ b/src/components-examples/material/datepicker/datepicker-actions/datepicker-actions-example.html @@ -1,32 +1,32 @@ Choose a date - + MM/DD/YYYY - + - + - + Enter a date range - - + + MM/DD/YYYY – MM/DD/YYYY - + - + - + diff --git a/src/components-examples/material/datepicker/datepicker-actions/datepicker-actions-example.ts b/src/components-examples/material/datepicker/datepicker-actions/datepicker-actions-example.ts index aa9db2362cd4..6cd6ee931bd2 100644 --- a/src/components-examples/material/datepicker/datepicker-actions/datepicker-actions-example.ts +++ b/src/components-examples/material/datepicker/datepicker-actions/datepicker-actions-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; import {MatDatepickerModule} from '@angular/material/datepicker'; import {MatInputModule} from '@angular/material/input'; @@ -13,5 +13,6 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule, MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerActionsExample {} diff --git a/src/components-examples/material/datepicker/datepicker-api/datepicker-api-example.ts b/src/components-examples/material/datepicker/datepicker-api/datepicker-api-example.ts index 0560293266ff..5368a236f301 100644 --- a/src/components-examples/material/datepicker/datepicker-api/datepicker-api-example.ts +++ b/src/components-examples/material/datepicker/datepicker-api/datepicker-api-example.ts @@ -1,9 +1,9 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** @title Datepicker open method */ @Component({ @@ -13,5 +13,6 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule, MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerApiExample {} diff --git a/src/components-examples/material/datepicker/datepicker-color/datepicker-color-example.css b/src/components-examples/material/datepicker/datepicker-color/datepicker-color-example.css deleted file mode 100644 index ece1d0db513c..000000000000 --- a/src/components-examples/material/datepicker/datepicker-color/datepicker-color-example.css +++ /dev/null @@ -1,3 +0,0 @@ -mat-form-field { - margin-right: 12px; -} diff --git a/src/components-examples/material/datepicker/datepicker-color/datepicker-color-example.html b/src/components-examples/material/datepicker/datepicker-color/datepicker-color-example.html deleted file mode 100644 index 9e69871270ce..000000000000 --- a/src/components-examples/material/datepicker/datepicker-color/datepicker-color-example.html +++ /dev/null @@ -1,15 +0,0 @@ - - Inherited calendar color - - MM/DD/YYYY - - - - - - Custom calendar color - - MM/DD/YYYY - - - diff --git a/src/components-examples/material/datepicker/datepicker-color/datepicker-color-example.ts b/src/components-examples/material/datepicker/datepicker-color/datepicker-color-example.ts deleted file mode 100644 index 1c7ce411d875..000000000000 --- a/src/components-examples/material/datepicker/datepicker-color/datepicker-color-example.ts +++ /dev/null @@ -1,16 +0,0 @@ -import {Component} from '@angular/core'; -import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; -import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; - -/** @title Datepicker palette colors */ -@Component({ - selector: 'datepicker-color-example', - templateUrl: 'datepicker-color-example.html', - styleUrl: 'datepicker-color-example.css', - standalone: true, - providers: [provideNativeDateAdapter()], - imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule], -}) -export class DatepickerColorExample {} diff --git a/src/components-examples/material/datepicker/datepicker-custom-header/datepicker-custom-header-example.ts b/src/components-examples/material/datepicker/datepicker-custom-header/datepicker-custom-header-example.ts index d2b2c019b4ef..b3dc89f5d8a2 100644 --- a/src/components-examples/material/datepicker/datepicker-custom-header/datepicker-custom-header-example.ts +++ b/src/components-examples/material/datepicker/datepicker-custom-header/datepicker-custom-header-example.ts @@ -1,35 +1,29 @@ -import { - ChangeDetectionStrategy, - ChangeDetectorRef, - Component, - Inject, - OnDestroy, -} from '@angular/core'; -import {MatCalendar, MatDatepickerModule} from '@angular/material/datepicker'; +import {ChangeDetectionStrategy, Component, Inject, OnDestroy, signal} from '@angular/core'; +import {MatButtonModule} from '@angular/material/button'; import { DateAdapter, MAT_DATE_FORMATS, MatDateFormats, provideNativeDateAdapter, } from '@angular/material/core'; -import {Subject} from 'rxjs'; -import {takeUntil} from 'rxjs/operators'; +import {MatCalendar, MatDatepickerModule} from '@angular/material/datepicker'; +import {MatFormFieldModule} from '@angular/material/form-field'; import {MatIconModule} from '@angular/material/icon'; -import {MatButtonModule} from '@angular/material/button'; import {MatInputModule} from '@angular/material/input'; -import {MatFormFieldModule} from '@angular/material/form-field'; +import {Subject} from 'rxjs'; +import {startWith, takeUntil} from 'rxjs/operators'; /** @title Datepicker with custom calendar header */ @Component({ selector: 'datepicker-custom-header-example', templateUrl: 'datepicker-custom-header-example.html', - changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerCustomHeaderExample { - exampleHeader = ExampleHeader; + readonly exampleHeader = ExampleHeader; } /** Custom header component for datepicker. */ @@ -57,7 +51,7 @@ export class DatepickerCustomHeaderExample { - {{periodLabel}} + {{periodLabel()}} @@ -66,20 +60,27 @@ export class DatepickerCustomHeaderExample {
`, - changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [MatButtonModule, MatIconModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExampleHeader implements OnDestroy { private _destroyed = new Subject(); + readonly periodLabel = signal(''); + constructor( private _calendar: MatCalendar, private _dateAdapter: DateAdapter, @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats, - cdr: ChangeDetectorRef, ) { - _calendar.stateChanges.pipe(takeUntil(this._destroyed)).subscribe(() => cdr.markForCheck()); + _calendar.stateChanges.pipe(startWith(null), takeUntil(this._destroyed)).subscribe(() => { + this.periodLabel.set( + this._dateAdapter + .format(this._calendar.activeDate, this._dateFormats.display.monthYearLabel) + .toLocaleUpperCase(), + ); + }); } ngOnDestroy() { @@ -87,12 +88,6 @@ export class ExampleHeader implements OnDestroy { this._destroyed.complete(); } - get periodLabel() { - return this._dateAdapter - .format(this._calendar.activeDate, this._dateFormats.display.monthYearLabel) - .toLocaleUpperCase(); - } - previousClicked(mode: 'month' | 'year') { this._calendar.activeDate = mode === 'month' diff --git a/src/components-examples/material/datepicker/datepicker-custom-icon/datepicker-custom-icon-example.ts b/src/components-examples/material/datepicker/datepicker-custom-icon/datepicker-custom-icon-example.ts index 752846e38c56..9e6489d466d3 100644 --- a/src/components-examples/material/datepicker/datepicker-custom-icon/datepicker-custom-icon-example.ts +++ b/src/components-examples/material/datepicker/datepicker-custom-icon/datepicker-custom-icon-example.ts @@ -1,9 +1,9 @@ -import {Component} from '@angular/core'; -import {MatIconModule} from '@angular/material/icon'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatIconModule} from '@angular/material/icon'; +import {MatInputModule} from '@angular/material/input'; /** @title Datepicker with custom icon */ @Component({ @@ -12,5 +12,6 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule, MatIconModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerCustomIconExample {} diff --git a/src/components-examples/material/datepicker/datepicker-date-class/datepicker-date-class-example.ts b/src/components-examples/material/datepicker/datepicker-date-class/datepicker-date-class-example.ts index 769bf00b02a8..fb831f7e145b 100644 --- a/src/components-examples/material/datepicker/datepicker-date-class/datepicker-date-class-example.ts +++ b/src/components-examples/material/datepicker/datepicker-date-class/datepicker-date-class-example.ts @@ -1,8 +1,8 @@ -import {Component, ViewEncapsulation} from '@angular/core'; +import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatCalendarCellClassFunction, MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** @title Datepicker with custom date classes */ @Component({ @@ -13,6 +13,7 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerDateClassExample { dateClass: MatCalendarCellClassFunction = (cellDate, view) => { diff --git a/src/components-examples/material/datepicker/datepicker-disabled/datepicker-disabled-example.ts b/src/components-examples/material/datepicker/datepicker-disabled/datepicker-disabled-example.ts index bc49b2d75cff..2948d4cadebe 100644 --- a/src/components-examples/material/datepicker/datepicker-disabled/datepicker-disabled-example.ts +++ b/src/components-examples/material/datepicker/datepicker-disabled/datepicker-disabled-example.ts @@ -1,8 +1,8 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** @title Disabled datepicker */ @Component({ @@ -11,5 +11,6 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerDisabledExample {} diff --git a/src/components-examples/material/datepicker/datepicker-events/datepicker-events-example.html b/src/components-examples/material/datepicker/datepicker-events/datepicker-events-example.html index 1dc59fb2450d..6973491dec91 100644 --- a/src/components-examples/material/datepicker/datepicker-events/datepicker-events-example.html +++ b/src/components-examples/material/datepicker/datepicker-events/datepicker-events-example.html @@ -1,14 +1,18 @@ Input & change events - + MM/DD/YYYY
- @for (e of events; track e) { + @for (e of events(); track e) {
{{e}}
}
diff --git a/src/components-examples/material/datepicker/datepicker-events/datepicker-events-example.ts b/src/components-examples/material/datepicker/datepicker-events/datepicker-events-example.ts index e8d0d1776e15..354fabe38a80 100644 --- a/src/components-examples/material/datepicker/datepicker-events/datepicker-events-example.ts +++ b/src/components-examples/material/datepicker/datepicker-events/datepicker-events-example.ts @@ -1,8 +1,8 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component, signal} from '@angular/core'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerInputEvent, MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** @title Datepicker input and change events */ @Component({ @@ -12,11 +12,12 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerEventsExample { - events: string[] = []; + events = signal([]); addEvent(type: string, event: MatDatepickerInputEvent) { - this.events.push(`${type}: ${event.value}`); + this.events.update(events => [...events, `${type}: ${event.value}`]); } } diff --git a/src/components-examples/material/datepicker/datepicker-filter/datepicker-filter-example.ts b/src/components-examples/material/datepicker/datepicker-filter/datepicker-filter-example.ts index 48deeac155d2..18051587c147 100644 --- a/src/components-examples/material/datepicker/datepicker-filter/datepicker-filter-example.ts +++ b/src/components-examples/material/datepicker/datepicker-filter/datepicker-filter-example.ts @@ -1,8 +1,8 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** @title Datepicker with filter validation */ @Component({ @@ -11,6 +11,7 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerFilterExample { myFilter = (d: Date | null): boolean => { diff --git a/src/components-examples/material/datepicker/datepicker-formats/datepicker-formats-example.ts b/src/components-examples/material/datepicker/datepicker-formats/datepicker-formats-example.ts index b2291812c3a0..ade7995ea8ee 100644 --- a/src/components-examples/material/datepicker/datepicker-formats/datepicker-formats-example.ts +++ b/src/components-examples/material/datepicker/datepicker-formats/datepicker-formats-example.ts @@ -1,7 +1,9 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {provideMomentDateAdapter} from '@angular/material-moment-adapter'; - +import {MatDatepickerModule} from '@angular/material/datepicker'; +import {MatFormFieldModule} from '@angular/material/form-field'; +import {MatInputModule} from '@angular/material/input'; // Depending on whether rollup is used, moment needs to be imported differently. // Since Moment.js doesn't have a default export, we normally need to import using the `* as` // syntax. However, rollup creates a synthetic default module and we thus need to import it using @@ -9,9 +11,6 @@ import {provideMomentDateAdapter} from '@angular/material-moment-adapter'; import * as _moment from 'moment'; // tslint:disable-next-line:no-duplicate-imports import {default as _rollupMoment} from 'moment'; -import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; -import {MatFormFieldModule} from '@angular/material/form-field'; const moment = _rollupMoment || _moment; @@ -47,7 +46,8 @@ export const MY_FORMATS = { FormsModule, ReactiveFormsModule, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerFormatsExample { - date = new FormControl(moment()); + readonly date = new FormControl(moment()); } diff --git a/src/components-examples/material/datepicker/datepicker-harness/datepicker-harness-example.html b/src/components-examples/material/datepicker/datepicker-harness/datepicker-harness-example.html index daef3ea96968..58228373eceb 100644 --- a/src/components-examples/material/datepicker/datepicker-harness/datepicker-harness-example.html +++ b/src/components-examples/material/datepicker/datepicker-harness/datepicker-harness-example.html @@ -1,6 +1,2 @@ - + diff --git a/src/components-examples/material/datepicker/datepicker-harness/datepicker-harness-example.ts b/src/components-examples/material/datepicker/datepicker-harness/datepicker-harness-example.ts index 500d0d5b8612..7ddb30fc4e22 100644 --- a/src/components-examples/material/datepicker/datepicker-harness/datepicker-harness-example.ts +++ b/src/components-examples/material/datepicker/datepicker-harness/datepicker-harness-example.ts @@ -1,4 +1,4 @@ -import {Component, signal} from '@angular/core'; +import {ChangeDetectionStrategy, Component, model, signal} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; @@ -13,8 +13,9 @@ import {MatInputModule} from '@angular/material/input'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatInputModule, MatDatepickerModule, FormsModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerHarnessExample { - date: Date | null = null; + date = model(null); minDate = signal(null); } diff --git a/src/components-examples/material/datepicker/datepicker-inline-calendar/datepicker-inline-calendar-example.html b/src/components-examples/material/datepicker/datepicker-inline-calendar/datepicker-inline-calendar-example.html index 8ffcf05863ac..3fb2d5348f78 100644 --- a/src/components-examples/material/datepicker/datepicker-inline-calendar/datepicker-inline-calendar-example.html +++ b/src/components-examples/material/datepicker/datepicker-inline-calendar/datepicker-inline-calendar-example.html @@ -1,4 +1,4 @@ -

Selected date: {{selected}}

+

Selected date: {{selected()}}

diff --git a/src/components-examples/material/datepicker/datepicker-inline-calendar/datepicker-inline-calendar-example.ts b/src/components-examples/material/datepicker/datepicker-inline-calendar/datepicker-inline-calendar-example.ts index f7acfa610c81..b31d24d1c544 100644 --- a/src/components-examples/material/datepicker/datepicker-inline-calendar/datepicker-inline-calendar-example.ts +++ b/src/components-examples/material/datepicker/datepicker-inline-calendar/datepicker-inline-calendar-example.ts @@ -1,7 +1,7 @@ -import {Component} from '@angular/core'; -import {MatDatepickerModule} from '@angular/material/datepicker'; +import {ChangeDetectionStrategy, Component, model} from '@angular/core'; import {MatCardModule} from '@angular/material/card'; import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatDatepickerModule} from '@angular/material/datepicker'; /** @title Datepicker inline calendar example */ @Component({ @@ -11,7 +11,8 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatCardModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerInlineCalendarExample { - selected: Date | null; + selected = model(null); } diff --git a/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.html b/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.html index a0d2983857f2..aa9889acc61b 100644 --- a/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.html +++ b/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.html @@ -1,7 +1,7 @@ Different locale - - {{getDateFormatString()}} + + {{dateFormatString()}} diff --git a/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts b/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts index 17f4e061c545..383712032b7a 100644 --- a/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts +++ b/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts @@ -1,12 +1,12 @@ -import {Component, Inject, OnInit} from '@angular/core'; +import {ChangeDetectionStrategy, Component, OnInit, computed, inject, signal} from '@angular/core'; import {provideMomentDateAdapter} from '@angular/material-moment-adapter'; -import {DateAdapter, MAT_DATE_LOCALE} from '@angular/material/core'; import {MatButtonModule} from '@angular/material/button'; -import {MatDatepickerModule, MatDatepickerIntl} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; +import {DateAdapter, MAT_DATE_LOCALE} from '@angular/material/core'; +import {MatDatepickerIntl, MatDatepickerModule} from '@angular/material/datepicker'; import {MatFormFieldModule} from '@angular/material/form-field'; -import 'moment/locale/ja'; +import {MatInputModule} from '@angular/material/input'; import 'moment/locale/fr'; +import 'moment/locale/ja'; /** @title Datepicker with different locale */ @Component({ @@ -25,21 +25,28 @@ import 'moment/locale/fr'; ], standalone: true, imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule, MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerLocaleExample implements OnInit { - constructor( - private _adapter: DateAdapter, - private _intl: MatDatepickerIntl, - @Inject(MAT_DATE_LOCALE) private _locale: string, - ) {} + private readonly _adapter = inject>(DateAdapter); + private readonly _intl = inject(MatDatepickerIntl); + private readonly _locale = signal(inject(MAT_DATE_LOCALE)); + readonly dateFormatString = computed(() => { + if (this._locale() === 'ja-JP') { + return 'YYYY/MM/DD'; + } else if (this._locale() === 'fr') { + return 'DD/MM/YYYY'; + } + return ''; + }); ngOnInit() { this.updateCloseButtonLabel('カレンダーを閉じる'); } french() { - this._locale = 'fr'; - this._adapter.setLocale(this._locale); + this._locale.set('fr'); + this._adapter.setLocale(this._locale()); this.updateCloseButtonLabel('Fermer le calendrier'); } @@ -47,13 +54,4 @@ export class DatepickerLocaleExample implements OnInit { this._intl.closeCalendarLabel = label; this._intl.changes.next(); } - - getDateFormatString(): string { - if (this._locale === 'ja-JP') { - return 'YYYY/MM/DD'; - } else if (this._locale === 'fr') { - return 'DD/MM/YYYY'; - } - return ''; - } } diff --git a/src/components-examples/material/datepicker/datepicker-min-max/datepicker-min-max-example.html b/src/components-examples/material/datepicker/datepicker-min-max/datepicker-min-max-example.html index a33e3f8338ce..0c0ba98aefcf 100644 --- a/src/components-examples/material/datepicker/datepicker-min-max/datepicker-min-max-example.html +++ b/src/components-examples/material/datepicker/datepicker-min-max/datepicker-min-max-example.html @@ -1,6 +1,6 @@ Choose a date - + MM/DD/YYYY diff --git a/src/components-examples/material/datepicker/datepicker-min-max/datepicker-min-max-example.ts b/src/components-examples/material/datepicker/datepicker-min-max/datepicker-min-max-example.ts index 0d71676c0ca9..d10a9302be26 100644 --- a/src/components-examples/material/datepicker/datepicker-min-max/datepicker-min-max-example.ts +++ b/src/components-examples/material/datepicker/datepicker-min-max/datepicker-min-max-example.ts @@ -1,8 +1,8 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** @title Datepicker with min & max validation */ @Component({ @@ -11,15 +11,11 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerMinMaxExample { - minDate: Date; - maxDate: Date; - - constructor() { - // Set the minimum to January 1st 20 years in the past and December 31st a year in the future. - const currentYear = new Date().getFullYear(); - this.minDate = new Date(currentYear - 20, 0, 1); - this.maxDate = new Date(currentYear + 1, 11, 31); - } + // Set the minimum to January 1st 20 years in the past and December 31st a year in the future. + private readonly _currentYear = new Date().getFullYear(); + readonly minDate = new Date(this._currentYear - 20, 0, 1); + readonly maxDate = new Date(this._currentYear + 1, 11, 31); } diff --git a/src/components-examples/material/datepicker/datepicker-moment/datepicker-moment-example.ts b/src/components-examples/material/datepicker/datepicker-moment/datepicker-moment-example.ts index 003ded4a8a28..c8d95833d83a 100644 --- a/src/components-examples/material/datepicker/datepicker-moment/datepicker-moment-example.ts +++ b/src/components-examples/material/datepicker/datepicker-moment/datepicker-moment-example.ts @@ -1,7 +1,9 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {provideMomentDateAdapter} from '@angular/material-moment-adapter'; - +import {MatDatepickerModule} from '@angular/material/datepicker'; +import {MatFormFieldModule} from '@angular/material/form-field'; +import {MatInputModule} from '@angular/material/input'; // Depending on whether rollup is used, moment needs to be imported differently. // Since Moment.js doesn't have a default export, we normally need to import using the `* as` // syntax. However, rollup creates a synthetic default module and we thus need to import it using @@ -9,9 +11,6 @@ import {provideMomentDateAdapter} from '@angular/material-moment-adapter'; import * as _moment from 'moment'; // tslint:disable-next-line:no-duplicate-imports import {default as _rollupMoment} from 'moment'; -import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; -import {MatFormFieldModule} from '@angular/material/form-field'; const moment = _rollupMoment || _moment; @@ -33,8 +32,9 @@ const moment = _rollupMoment || _moment; FormsModule, ReactiveFormsModule, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerMomentExample { // Datepicker takes `Moment` objects instead of `Date` objects. - date = new FormControl(moment([2017, 0, 1])); + readonly date = new FormControl(moment([2017, 0, 1])); } diff --git a/src/components-examples/material/datepicker/datepicker-overview/datepicker-overview-example.ts b/src/components-examples/material/datepicker/datepicker-overview/datepicker-overview-example.ts index 635278caf7fd..3e821deee9fb 100644 --- a/src/components-examples/material/datepicker/datepicker-overview/datepicker-overview-example.ts +++ b/src/components-examples/material/datepicker/datepicker-overview/datepicker-overview-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; @@ -11,5 +11,6 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerOverviewExample {} diff --git a/src/components-examples/material/datepicker/datepicker-start-view/datepicker-start-view-example.ts b/src/components-examples/material/datepicker/datepicker-start-view/datepicker-start-view-example.ts index 9ac8dc7bde55..8f7366ca95f5 100644 --- a/src/components-examples/material/datepicker/datepicker-start-view/datepicker-start-view-example.ts +++ b/src/components-examples/material/datepicker/datepicker-start-view/datepicker-start-view-example.ts @@ -1,8 +1,8 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** @title Datepicker start date */ @Component({ @@ -11,7 +11,8 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerStartViewExample { - startDate = new Date(1990, 0, 1); + readonly startDate = new Date(1990, 0, 1); } diff --git a/src/components-examples/material/datepicker/datepicker-touch/datepicker-touch-example.ts b/src/components-examples/material/datepicker/datepicker-touch/datepicker-touch-example.ts index b4346df5c648..24d5ed9d1a2a 100644 --- a/src/components-examples/material/datepicker/datepicker-touch/datepicker-touch-example.ts +++ b/src/components-examples/material/datepicker/datepicker-touch/datepicker-touch-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; @@ -11,5 +11,6 @@ import {provideNativeDateAdapter} from '@angular/material/core'; standalone: true, providers: [provideNativeDateAdapter()], imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerTouchExample {} diff --git a/src/components-examples/material/datepicker/datepicker-value/datepicker-value-example.ts b/src/components-examples/material/datepicker/datepicker-value/datepicker-value-example.ts index 34dfd467ff7d..6713992c691f 100644 --- a/src/components-examples/material/datepicker/datepicker-value/datepicker-value-example.ts +++ b/src/components-examples/material/datepicker/datepicker-value/datepicker-value-example.ts @@ -1,9 +1,9 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** @title Datepicker selected value */ @Component({ @@ -19,8 +19,9 @@ import {provideNativeDateAdapter} from '@angular/material/core'; FormsModule, ReactiveFormsModule, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerValueExample { - date = new FormControl(new Date()); - serializedDate = new FormControl(new Date().toISOString()); + readonly date = new FormControl(new Date()); + readonly serializedDate = new FormControl(new Date().toISOString()); } diff --git a/src/components-examples/material/datepicker/datepicker-views-selection/datepicker-views-selection-example.ts b/src/components-examples/material/datepicker/datepicker-views-selection/datepicker-views-selection-example.ts index 75424004adf0..0524a68c2681 100644 --- a/src/components-examples/material/datepicker/datepicker-views-selection/datepicker-views-selection-example.ts +++ b/src/components-examples/material/datepicker/datepicker-views-selection/datepicker-views-selection-example.ts @@ -1,4 +1,4 @@ -import {Component, ViewEncapsulation} from '@angular/core'; +import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {provideMomentDateAdapter} from '@angular/material-moment-adapter'; import {MatDatepicker, MatDatepickerModule} from '@angular/material/datepicker'; @@ -49,9 +49,10 @@ export const MY_FORMATS = { FormsModule, ReactiveFormsModule, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DatepickerViewsSelectionExample { - date = new FormControl(moment()); + readonly date = new FormControl(moment()); setMonthAndYear(normalizedMonthAndYear: Moment, datepicker: MatDatepicker) { const ctrlValue = this.date.value ?? moment(); diff --git a/src/components-examples/material/datepicker/index.ts b/src/components-examples/material/datepicker/index.ts index 88b3c566aef1..d62989a242fd 100644 --- a/src/components-examples/material/datepicker/index.ts +++ b/src/components-examples/material/datepicker/index.ts @@ -5,7 +5,6 @@ export {DateRangePickerSelectionStrategyExample} from './date-range-picker-selec export {DatepickerActionsExample} from './datepicker-actions/datepicker-actions-example'; export {DatepickerApiExample} from './datepicker-api/datepicker-api-example'; -export {DatepickerColorExample} from './datepicker-color/datepicker-color-example'; export { DatepickerCustomHeaderExample, ExampleHeader, diff --git a/src/components-examples/material/dialog/dialog-animations/dialog-animations-example.ts b/src/components-examples/material/dialog/dialog-animations/dialog-animations-example.ts index 3e98572dc312..eff78b4dd888 100644 --- a/src/components-examples/material/dialog/dialog-animations/dialog-animations-example.ts +++ b/src/components-examples/material/dialog/dialog-animations/dialog-animations-example.ts @@ -1,13 +1,13 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; +import {MatButtonModule} from '@angular/material/button'; import { MatDialog, - MatDialogRef, MatDialogActions, MatDialogClose, - MatDialogTitle, MatDialogContent, + MatDialogRef, + MatDialogTitle, } from '@angular/material/dialog'; -import {MatButtonModule} from '@angular/material/button'; /** * @title Dialog Animations @@ -18,9 +18,10 @@ import {MatButtonModule} from '@angular/material/button'; templateUrl: 'dialog-animations-example.html', standalone: true, imports: [MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogAnimationsExample { - constructor(public dialog: MatDialog) {} + readonly dialog = inject(MatDialog); openDialog(enterAnimationDuration: string, exitAnimationDuration: string): void { this.dialog.open(DialogAnimationsExampleDialog, { @@ -36,7 +37,8 @@ export class DialogAnimationsExample { templateUrl: 'dialog-animations-example-dialog.html', standalone: true, imports: [MatButtonModule, MatDialogActions, MatDialogClose, MatDialogTitle, MatDialogContent], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogAnimationsExampleDialog { - constructor(public dialogRef: MatDialogRef) {} + readonly dialogRef = inject(MatDialogRef); } diff --git a/src/components-examples/material/dialog/dialog-content/dialog-content-example.ts b/src/components-examples/material/dialog/dialog-content/dialog-content-example.ts index 953ecddeefb2..fc01911151f2 100644 --- a/src/components-examples/material/dialog/dialog-content/dialog-content-example.ts +++ b/src/components-examples/material/dialog/dialog-content/dialog-content-example.ts @@ -1,6 +1,6 @@ -import {Component} from '@angular/core'; -import {MatDialog, MatDialogModule} from '@angular/material/dialog'; +import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; +import {MatDialog, MatDialogModule} from '@angular/material/dialog'; /** * @title Dialog with header, scrollable content and actions @@ -10,9 +10,10 @@ import {MatButtonModule} from '@angular/material/button'; templateUrl: 'dialog-content-example.html', standalone: true, imports: [MatButtonModule, MatDialogModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogContentExample { - constructor(public dialog: MatDialog) {} + readonly dialog = inject(MatDialog); openDialog() { const dialogRef = this.dialog.open(DialogContentExampleDialog); @@ -28,5 +29,6 @@ export class DialogContentExample { templateUrl: 'dialog-content-example-dialog.html', standalone: true, imports: [MatDialogModule, MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogContentExampleDialog {} diff --git a/src/components-examples/material/dialog/dialog-elements/dialog-elements-example.ts b/src/components-examples/material/dialog/dialog-elements/dialog-elements-example.ts index 9bffc07754f0..db028d4ece0b 100644 --- a/src/components-examples/material/dialog/dialog-elements/dialog-elements-example.ts +++ b/src/components-examples/material/dialog/dialog-elements/dialog-elements-example.ts @@ -1,4 +1,5 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; +import {MatButtonModule} from '@angular/material/button'; import { MatDialog, MatDialogActions, @@ -6,7 +7,6 @@ import { MatDialogContent, MatDialogTitle, } from '@angular/material/dialog'; -import {MatButtonModule} from '@angular/material/button'; /** * @title Dialog elements @@ -16,9 +16,10 @@ import {MatButtonModule} from '@angular/material/button'; templateUrl: 'dialog-elements-example.html', standalone: true, imports: [MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogElementsExample { - constructor(public dialog: MatDialog) {} + readonly dialog = inject(MatDialog); openDialog() { this.dialog.open(DialogElementsExampleDialog); @@ -30,5 +31,6 @@ export class DialogElementsExample { templateUrl: 'dialog-elements-example-dialog.html', standalone: true, imports: [MatDialogTitle, MatDialogContent, MatDialogActions, MatDialogClose, MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogElementsExampleDialog {} diff --git a/src/components-examples/material/dialog/dialog-from-menu/dialog-from-menu-example.ts b/src/components-examples/material/dialog/dialog-from-menu/dialog-from-menu-example.ts index ec26842ee4b4..451c42e663b2 100644 --- a/src/components-examples/material/dialog/dialog-from-menu/dialog-from-menu-example.ts +++ b/src/components-examples/material/dialog/dialog-from-menu/dialog-from-menu-example.ts @@ -1,12 +1,12 @@ -import {Component, ViewChild} from '@angular/core'; +import {ChangeDetectionStrategy, Component, inject, viewChild} from '@angular/core'; +import {MatButtonModule} from '@angular/material/button'; import { MatDialog, MatDialogActions, MatDialogClose, MatDialogContent, } from '@angular/material/dialog'; -import {MatMenuTrigger, MatMenuModule} from '@angular/material/menu'; -import {MatButtonModule} from '@angular/material/button'; +import {MatMenuModule, MatMenuTrigger} from '@angular/material/menu'; /** * @title Dialog launched from a menu */ @@ -15,11 +15,12 @@ import {MatButtonModule} from '@angular/material/button'; templateUrl: 'dialog-from-menu-example.html', standalone: true, imports: [MatButtonModule, MatMenuModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogFromMenuExample { - @ViewChild('menuTrigger') menuTrigger: MatMenuTrigger; + readonly menuTrigger = viewChild.required(MatMenuTrigger); - constructor(public dialog: MatDialog) {} + readonly dialog = inject(MatDialog); openDialog() { // #docregion focus-restoration @@ -27,7 +28,7 @@ export class DialogFromMenuExample { // Manually restore focus to the menu trigger since the element that // opens the dialog won't be in the DOM any more when the dialog closes. - dialogRef.afterClosed().subscribe(() => this.menuTrigger.focus()); + dialogRef.afterClosed().subscribe(() => this.menuTrigger().focus()); // #enddocregion focus-restoration } } @@ -37,5 +38,6 @@ export class DialogFromMenuExample { templateUrl: 'dialog-from-menu-example-dialog.html', standalone: true, imports: [MatDialogContent, MatDialogActions, MatDialogClose, MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogFromMenuExampleDialog {} diff --git a/src/components-examples/material/dialog/dialog-harness/dialog-harness-example.ts b/src/components-examples/material/dialog/dialog-harness/dialog-harness-example.ts index 59b73d324af9..ea186b8c1c15 100644 --- a/src/components-examples/material/dialog/dialog-harness/dialog-harness-example.ts +++ b/src/components-examples/material/dialog/dialog-harness/dialog-harness-example.ts @@ -1,4 +1,4 @@ -import {Component, TemplateRef, ViewChild} from '@angular/core'; +import {ChangeDetectionStrategy, Component, TemplateRef, inject, viewChild} from '@angular/core'; import {MatDialog, MatDialogConfig} from '@angular/material/dialog'; /** @@ -8,13 +8,14 @@ import {MatDialog, MatDialogConfig} from '@angular/material/dialog'; selector: 'dialog-harness-example', templateUrl: 'dialog-harness-example.html', standalone: true, + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogHarnessExample { - @ViewChild(TemplateRef) dialogTemplate: TemplateRef; + readonly dialogTemplate = viewChild.required(TemplateRef); - constructor(readonly dialog: MatDialog) {} + readonly dialog = inject(MatDialog); open(config?: MatDialogConfig) { - return this.dialog.open(this.dialogTemplate, config); + return this.dialog.open(this.dialogTemplate(), config); } } diff --git a/src/components-examples/material/dialog/dialog-overview/dialog-overview-example-dialog.html b/src/components-examples/material/dialog/dialog-overview/dialog-overview-example-dialog.html index 212816310692..725de76c635e 100644 --- a/src/components-examples/material/dialog/dialog-overview/dialog-overview-example-dialog.html +++ b/src/components-examples/material/dialog/dialog-overview/dialog-overview-example-dialog.html @@ -3,10 +3,10 @@

Hi {{data.name}}

What's your favorite animal?

Favorite Animal - +
- + diff --git a/src/components-examples/material/dialog/dialog-overview/dialog-overview-example.html b/src/components-examples/material/dialog/dialog-overview/dialog-overview-example.html index c3f033499dad..210a36c9d466 100644 --- a/src/components-examples/material/dialog/dialog-overview/dialog-overview-example.html +++ b/src/components-examples/material/dialog/dialog-overview/dialog-overview-example.html @@ -2,13 +2,15 @@
  • What's your name? - +
  • - @if (animal) { -
  • You chose: {{animal}}
  • + @if (animal()) { +
  • + You chose: {{animal()}} +
  • } diff --git a/src/components-examples/material/dialog/dialog-overview/dialog-overview-example.ts b/src/components-examples/material/dialog/dialog-overview/dialog-overview-example.ts index 93812eb3f4eb..41449e632951 100644 --- a/src/components-examples/material/dialog/dialog-overview/dialog-overview-example.ts +++ b/src/components-examples/material/dialog/dialog-overview/dialog-overview-example.ts @@ -1,17 +1,17 @@ -import {Component, Inject} from '@angular/core'; +import {ChangeDetectionStrategy, Component, inject, model, signal} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {MatButtonModule} from '@angular/material/button'; import { - MatDialog, MAT_DIALOG_DATA, - MatDialogRef, - MatDialogTitle, - MatDialogContent, + MatDialog, MatDialogActions, MatDialogClose, + MatDialogContent, + MatDialogRef, + MatDialogTitle, } from '@angular/material/dialog'; -import {MatButtonModule} from '@angular/material/button'; -import {FormsModule} from '@angular/forms'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; +import {MatInputModule} from '@angular/material/input'; export interface DialogData { animal: string; @@ -26,21 +26,23 @@ export interface DialogData { templateUrl: 'dialog-overview-example.html', standalone: true, imports: [MatFormFieldModule, MatInputModule, FormsModule, MatButtonModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogOverviewExample { - animal: string; - name: string; - - constructor(public dialog: MatDialog) {} + readonly animal = signal(''); + readonly name = model(''); + readonly dialog = inject(MatDialog); openDialog(): void { const dialogRef = this.dialog.open(DialogOverviewExampleDialog, { - data: {name: this.name, animal: this.animal}, + data: {name: this.name(), animal: this.animal()}, }); dialogRef.afterClosed().subscribe(result => { console.log('The dialog was closed'); - this.animal = result; + if (result !== undefined) { + this.animal.set(result); + } }); } } @@ -61,10 +63,9 @@ export class DialogOverviewExample { ], }) export class DialogOverviewExampleDialog { - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: DialogData, - ) {} + readonly dialogRef = inject(MatDialogRef); + readonly data = inject(MAT_DIALOG_DATA); + readonly animal = model(this.data.animal); onNoClick(): void { this.dialogRef.close(); diff --git a/src/components-examples/material/divider/divider-harness/divider-harness-example.ts b/src/components-examples/material/divider/divider-harness/divider-harness-example.ts index 1540160a8a63..edb74ee7175a 100644 --- a/src/components-examples/material/divider/divider-harness/divider-harness-example.ts +++ b/src/components-examples/material/divider/divider-harness/divider-harness-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatDividerModule} from '@angular/material/divider'; /** @@ -9,5 +9,6 @@ import {MatDividerModule} from '@angular/material/divider'; templateUrl: 'divider-harness-example.html', standalone: true, imports: [MatDividerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DividerHarnessExample {} diff --git a/src/components-examples/material/divider/divider-overview/divider-overview-example.ts b/src/components-examples/material/divider/divider-overview/divider-overview-example.ts index 323e298d97e7..0192fdcd9d1c 100644 --- a/src/components-examples/material/divider/divider-overview/divider-overview-example.ts +++ b/src/components-examples/material/divider/divider-overview/divider-overview-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatDividerModule} from '@angular/material/divider'; import {MatListModule} from '@angular/material/list'; @@ -10,5 +10,6 @@ import {MatListModule} from '@angular/material/list'; templateUrl: 'divider-overview-example.html', standalone: true, imports: [MatListModule, MatDividerModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class DividerOverviewExample {} diff --git a/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.html b/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.html index 1b1f68e136d9..e0719977acca 100644 --- a/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.html +++ b/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.html @@ -1,15 +1,13 @@
    - - + +
    - + - - Personal data - + Personal data Type your name and age account_circle @@ -18,22 +16,19 @@ First name - + Age - + - - + - + - - Destination - + Destination Type the country name map @@ -42,15 +37,13 @@ Country - + - - Day of the trip - + Day of the trip Inform the date you wish to travel date_range @@ -59,7 +52,7 @@ Date - + diff --git a/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.ts b/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.ts index bfec84229ecc..c0d09f8e267e 100644 --- a/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.ts +++ b/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.ts @@ -1,11 +1,11 @@ -import {Component, ViewChild} from '@angular/core'; -import {MatAccordion, MatExpansionModule} from '@angular/material/expansion'; +import {ChangeDetectionStrategy, Component, viewChild} from '@angular/core'; +import {MatButtonModule} from '@angular/material/button'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; +import {MatAccordion, MatExpansionModule} from '@angular/material/expansion'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatIconModule} from '@angular/material/icon'; -import {MatButtonModule} from '@angular/material/button'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** * @title Accordion with expand/collapse all toggles @@ -24,7 +24,8 @@ import {provideNativeDateAdapter} from '@angular/material/core'; MatInputModule, MatDatepickerModule, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExpansionExpandCollapseAllExample { - @ViewChild(MatAccordion) accordion: MatAccordion; + accordion = viewChild.required(MatAccordion); } diff --git a/src/components-examples/material/expansion/expansion-harness/expansion-harness-example.ts b/src/components-examples/material/expansion/expansion-harness/expansion-harness-example.ts index 72b8f2f2890a..55c2bb6c6d51 100644 --- a/src/components-examples/material/expansion/expansion-harness/expansion-harness-example.ts +++ b/src/components-examples/material/expansion/expansion-harness/expansion-harness-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatExpansionModule} from '@angular/material/expansion'; /** @@ -9,5 +9,6 @@ import {MatExpansionModule} from '@angular/material/expansion'; templateUrl: 'expansion-harness-example.html', standalone: true, imports: [MatExpansionModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExpansionHarnessExample {} diff --git a/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.html b/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.html index 552cd3d161ca..63f9dff1eb82 100644 --- a/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.html +++ b/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.html @@ -1,27 +1,20 @@ - - + + - + - - This is the expansion title - - - This is a summary of the content - + This is the expansion title + This is a summary of the content

    This is the primary content of the panel.

    - - + + - - Self aware panel - + Self aware panel - Currently I am {{panelOpenState ? 'open' : 'closed'}} + Currently I am {{panelOpenState() ? 'open' : 'closed'}}

    I'm visible because I am open

    diff --git a/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.ts b/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.ts index c5acf05bc7be..6e733bc60d48 100644 --- a/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.ts +++ b/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component, signal} from '@angular/core'; import {MatExpansionModule} from '@angular/material/expansion'; /** @@ -9,7 +9,8 @@ import {MatExpansionModule} from '@angular/material/expansion'; templateUrl: 'expansion-overview-example.html', standalone: true, imports: [MatExpansionModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExpansionOverviewExample { - panelOpenState = false; + readonly panelOpenState = signal(false); } diff --git a/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.html b/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.html index c69815f92c8e..cbeed271fb98 100644 --- a/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.html +++ b/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.html @@ -1,9 +1,7 @@ - + - - Personal data - + Personal data Type your name and age account_circle @@ -12,25 +10,23 @@ First name - + Age - + - + - + - + - - Destination - + Destination Type the country name map @@ -39,7 +35,7 @@ Country - + @@ -48,11 +44,9 @@ - + - - Day of the trip - + Day of the trip Inform the date you wish to travel date_range @@ -61,7 +55,7 @@ Date - + @@ -70,5 +64,4 @@ - diff --git a/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.ts b/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.ts index 8ee83a29202c..d0fe339da89d 100644 --- a/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.ts +++ b/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.ts @@ -1,11 +1,11 @@ -import {Component} from '@angular/core'; -import {MatDatepickerModule} from '@angular/material/datepicker'; +import {ChangeDetectionStrategy, Component, signal} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; -import {MatInputModule} from '@angular/material/input'; +import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatDatepickerModule} from '@angular/material/datepicker'; +import {MatExpansionModule} from '@angular/material/expansion'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatIconModule} from '@angular/material/icon'; -import {MatExpansionModule} from '@angular/material/expansion'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** * @title Expansion panel as accordion @@ -24,19 +24,20 @@ import {provideNativeDateAdapter} from '@angular/material/core'; MatButtonModule, MatDatepickerModule, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExpansionStepsExample { - step = 0; + step = signal(0); setStep(index: number) { - this.step = index; + this.step.set(index); } nextStep() { - this.step++; + this.step.update(i => i + 1); } prevStep() { - this.step--; + this.step.update(i => i - 1); } } diff --git a/src/components-examples/material/form-field/form-field-appearance/form-field-appearance-example.ts b/src/components-examples/material/form-field/form-field-appearance/form-field-appearance-example.ts index 611acfb5f989..068fcdfc5c23 100644 --- a/src/components-examples/material/form-field/form-field-appearance/form-field-appearance-example.ts +++ b/src/components-examples/material/form-field/form-field-appearance/form-field-appearance-example.ts @@ -1,7 +1,7 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {MatFormFieldModule} from '@angular/material/form-field'; import {MatIconModule} from '@angular/material/icon'; import {MatInputModule} from '@angular/material/input'; -import {MatFormFieldModule} from '@angular/material/form-field'; /** @title Form field appearance variants */ @Component({ @@ -9,5 +9,6 @@ import {MatFormFieldModule} from '@angular/material/form-field'; templateUrl: 'form-field-appearance-example.html', standalone: true, imports: [MatFormFieldModule, MatInputModule, MatIconModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class FormFieldAppearanceExample {} diff --git a/src/components-examples/material/form-field/form-field-custom-control/example-tel-input-example.html b/src/components-examples/material/form-field/form-field-custom-control/example-tel-input-example.html index 0103309a96b7..79775ce567d5 100644 --- a/src/components-examples/material/form-field/form-field-custom-control/example-tel-input-example.html +++ b/src/components-examples/material/form-field/form-field-custom-control/example-tel-input-example.html @@ -1,30 +1,40 @@ -
    - +
    + - + - +
    diff --git a/src/components-examples/material/form-field/form-field-custom-control/form-field-custom-control-example.html b/src/components-examples/material/form-field/form-field-custom-control/form-field-custom-control-example.html index cd025c09ba69..450f8afae244 100644 --- a/src/components-examples/material/form-field/form-field-custom-control/form-field-custom-control-example.html +++ b/src/components-examples/material/form-field/form-field-custom-control/form-field-custom-control-example.html @@ -5,4 +5,5 @@ phone Include area code +

    Entered value: {{form.valueChanges | async | json}}

    diff --git a/src/components-examples/material/form-field/form-field-custom-control/form-field-custom-control-example.ts b/src/components-examples/material/form-field/form-field-custom-control/form-field-custom-control-example.ts index 60008128ff42..2c0f4bc39674 100644 --- a/src/components-examples/material/form-field/form-field-custom-control/form-field-custom-control-example.ts +++ b/src/components-examples/material/form-field/form-field-custom-control/form-field-custom-control-example.ts @@ -1,35 +1,39 @@ import {FocusMonitor} from '@angular/cdk/a11y'; -import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; +import {AsyncPipe, JsonPipe} from '@angular/common'; import { + ChangeDetectionStrategy, Component, ElementRef, - Inject, - Input, OnDestroy, - Optional, - Self, - ViewChild, + booleanAttribute, + computed, + effect, forwardRef, + inject, + input, + model, + signal, + viewChild, } from '@angular/core'; +import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import { AbstractControl, ControlValueAccessor, FormBuilder, FormControl, FormGroup, - NgControl, - Validators, FormsModule, + NgControl, ReactiveFormsModule, + Validators, } from '@angular/forms'; import { MAT_FORM_FIELD, - MatFormField, MatFormFieldControl, MatFormFieldModule, } from '@angular/material/form-field'; -import {Subject} from 'rxjs'; import {MatIconModule} from '@angular/material/icon'; +import {Subject} from 'rxjs'; /** @title Form field with custom telephone number input control. */ @Component({ @@ -42,10 +46,13 @@ import {MatIconModule} from '@angular/material/icon'; MatFormFieldModule, forwardRef(() => MyTelInput), MatIconModule, + AsyncPipe, + JsonPipe, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class FormFieldCustomControlExample { - form: FormGroup = new FormGroup({ + readonly form = new FormGroup({ tel: new FormControl(null), }); } @@ -71,26 +78,51 @@ export class MyTel { }, standalone: true, imports: [FormsModule, ReactiveFormsModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class MyTelInput implements ControlValueAccessor, MatFormFieldControl, OnDestroy { static nextId = 0; - @ViewChild('area') areaInput: HTMLInputElement; - @ViewChild('exchange') exchangeInput: HTMLInputElement; - @ViewChild('subscriber') subscriberInput: HTMLInputElement; - - parts: FormGroup<{ + readonly areaInput = viewChild.required('area'); + readonly exchangeInput = viewChild.required('exchange'); + readonly subscriberInput = viewChild.required('subscriber'); + ngControl = inject(NgControl, {optional: true, self: true}); + readonly parts: FormGroup<{ area: FormControl; exchange: FormControl; subscriber: FormControl; }>; - stateChanges = new Subject(); - focused = false; - touched = false; - controlType = 'example-tel-input'; - id = `example-tel-input-${MyTelInput.nextId++}`; + readonly stateChanges = new Subject(); + readonly touched = signal(false); + readonly controlType = 'example-tel-input'; + readonly id = `example-tel-input-${MyTelInput.nextId++}`; + readonly _userAriaDescribedBy = input('', {alias: 'aria-describedby'}); + readonly _placeholder = input('', {alias: 'placeholder'}); + readonly _required = input(false, { + alias: 'required', + transform: booleanAttribute, + }); + readonly _disabledByInput = input(false, { + alias: 'disabled', + transform: booleanAttribute, + }); + readonly _value = model(null, {alias: 'value'}); onChange = (_: any) => {}; onTouched = () => {}; + protected readonly _formField = inject(MAT_FORM_FIELD, { + optional: true, + }); + + private readonly _focused = signal(false); + private readonly _disabledByCva = signal(false); + private readonly _disabled = computed(() => this._disabledByInput() || this._disabledByCva()); + private readonly _focusMonitor = inject(FocusMonitor); + private readonly _elementRef = inject>(ElementRef); + + get focused(): boolean { + return this._focused(); + } + get empty() { const { value: {area, exchange, subscriber}, @@ -103,75 +135,75 @@ export class MyTelInput implements ControlValueAccessor, MatFormFieldControl, - @Optional() @Inject(MAT_FORM_FIELD) public _formField: MatFormField, - @Optional() @Self() public ngControl: NgControl, - ) { + constructor() { if (this.ngControl != null) { this.ngControl.valueAccessor = this; } - this.parts = formBuilder.group({ + this.parts = inject(FormBuilder).group({ area: ['', [Validators.required, Validators.minLength(3), Validators.maxLength(3)]], exchange: ['', [Validators.required, Validators.minLength(3), Validators.maxLength(3)]], subscriber: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(4)]], }); + + effect(() => { + // Read signals to trigger effect. + this._placeholder(); + this._required(); + this._disabled(); + // Propagate state changes. + this.stateChanges.next(); + }); + + effect(() => { + if (this._disabled()) { + this.parts.disable(); + } else { + this.parts.enable(); + } + }); + + effect(() => { + this.parts.setValue(this._value() || new MyTel('', '', '')); + }); + + this.parts.statusChanges.pipe(takeUntilDestroyed()).subscribe(() => { + this.stateChanges.next(); + }); + + this.parts.valueChanges.pipe(takeUntilDestroyed()).subscribe(value => { + const tel = this.parts.valid + ? new MyTel( + this.parts.value.area || '', + this.parts.value.exchange || '', + this.parts.value.subscriber || '', + ) + : null; + this._updateValue(tel); + }); } ngOnDestroy() { @@ -179,19 +211,17 @@ export class MyTelInput implements ControlValueAccessor, MatFormFieldControl Enter your email - + @if (email.invalid) { - {{errorMessage}} + {{errorMessage()}} } diff --git a/src/components-examples/material/form-field/form-field-error/form-field-error-example.ts b/src/components-examples/material/form-field/form-field-error/form-field-error-example.ts index 891a4432257e..0cb5a84be9b7 100644 --- a/src/components-examples/material/form-field/form-field-error/form-field-error-example.ts +++ b/src/components-examples/material/form-field/form-field-error/form-field-error-example.ts @@ -1,8 +1,8 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component, signal} from '@angular/core'; import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; -import {FormControl, Validators, FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {MatInputModule} from '@angular/material/input'; +import {FormControl, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms'; import {MatFormFieldModule} from '@angular/material/form-field'; +import {MatInputModule} from '@angular/material/input'; import {merge} from 'rxjs'; /** @title Form field with error messages */ @@ -12,11 +12,12 @@ import {merge} from 'rxjs'; styleUrl: 'form-field-error-example.css', standalone: true, imports: [MatFormFieldModule, MatInputModule, FormsModule, ReactiveFormsModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class FormFieldErrorExample { - email = new FormControl('', [Validators.required, Validators.email]); + readonly email = new FormControl('', [Validators.required, Validators.email]); - errorMessage = ''; + errorMessage = signal(''); constructor() { merge(this.email.statusChanges, this.email.valueChanges) @@ -26,11 +27,11 @@ export class FormFieldErrorExample { updateErrorMessage() { if (this.email.hasError('required')) { - this.errorMessage = 'You must enter a value'; + this.errorMessage.set('You must enter a value'); } else if (this.email.hasError('email')) { - this.errorMessage = 'Not a valid email'; + this.errorMessage.set('Not a valid email'); } else { - this.errorMessage = ''; + this.errorMessage.set(''); } } } diff --git a/src/components-examples/material/form-field/form-field-harness/form-field-harness-example.ts b/src/components-examples/material/form-field/form-field-harness/form-field-harness-example.ts index 19c1012604fe..a00eec80535c 100644 --- a/src/components-examples/material/form-field/form-field-harness/form-field-harness-example.ts +++ b/src/components-examples/material/form-field/form-field-harness/form-field-harness-example.ts @@ -1,7 +1,7 @@ -import {Component} from '@angular/core'; -import {FormControl, Validators, FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {MatInputModule} from '@angular/material/input'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {FormControl, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms'; import {MatFormFieldModule} from '@angular/material/form-field'; +import {MatInputModule} from '@angular/material/input'; /** * @title Testing with MatFormFieldHarness @@ -11,7 +11,8 @@ import {MatFormFieldModule} from '@angular/material/form-field'; templateUrl: 'form-field-harness-example.html', standalone: true, imports: [MatFormFieldModule, MatInputModule, FormsModule, ReactiveFormsModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class FormFieldHarnessExample { - requiredControl = new FormControl('Initial value', [Validators.required]); + readonly requiredControl = new FormControl('Initial value', [Validators.required]); } diff --git a/src/components-examples/material/form-field/form-field-hint/form-field-hint-example.html b/src/components-examples/material/form-field/form-field-hint/form-field-hint-example.html index 4c46c727f6c5..c08a2d4b11d3 100644 --- a/src/components-examples/material/form-field/form-field-hint/form-field-hint-example.html +++ b/src/components-examples/material/form-field/form-field-hint/form-field-hint-example.html @@ -1,8 +1,8 @@
    Enter some input - - {{input.value.length}}/10 + + {{value().length}}/10 diff --git a/src/components-examples/material/form-field/form-field-hint/form-field-hint-example.ts b/src/components-examples/material/form-field/form-field-hint/form-field-hint-example.ts index 5279fe2a0aef..5f7f5c45b031 100644 --- a/src/components-examples/material/form-field/form-field-hint/form-field-hint-example.ts +++ b/src/components-examples/material/form-field/form-field-hint/form-field-hint-example.ts @@ -1,7 +1,7 @@ -import {Component} from '@angular/core'; -import {MatSelectModule} from '@angular/material/select'; -import {MatInputModule} from '@angular/material/input'; +import {ChangeDetectionStrategy, Component, signal} from '@angular/core'; import {MatFormFieldModule} from '@angular/material/form-field'; +import {MatInputModule} from '@angular/material/input'; +import {MatSelectModule} from '@angular/material/select'; /** @title Form field with hints */ @Component({ @@ -10,5 +10,12 @@ import {MatFormFieldModule} from '@angular/material/form-field'; styleUrl: 'form-field-hint-example.css', standalone: true, imports: [MatFormFieldModule, MatInputModule, MatSelectModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) -export class FormFieldHintExample {} +export class FormFieldHintExample { + protected readonly value = signal(''); + + protected onInput(event: Event) { + this.value.set((event.target as HTMLInputElement).value); + } +} diff --git a/src/components-examples/material/form-field/form-field-label/form-field-label-example.html b/src/components-examples/material/form-field/form-field-label/form-field-label-example.html index 0556459e2afe..5caf21f0f5f7 100644 --- a/src/components-examples/material/form-field/form-field-label/form-field-label-example.html +++ b/src/components-examples/material/form-field/form-field-label/form-field-label-example.html @@ -10,20 +10,16 @@
    - - + + - + Both a label and a placeholder - + - + -- None -- Option diff --git a/src/components-examples/material/form-field/form-field-label/form-field-label-example.ts b/src/components-examples/material/form-field/form-field-label/form-field-label-example.ts index 7cdc7a52450b..a11f34d34301 100644 --- a/src/components-examples/material/form-field/form-field-label/form-field-label-example.ts +++ b/src/components-examples/material/form-field/form-field-label/form-field-label-example.ts @@ -1,11 +1,13 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; +import {toSignal} from '@angular/core/rxjs-interop'; import {FormBuilder, FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {MatCheckboxModule} from '@angular/material/checkbox'; import {FloatLabelType, MatFormFieldModule} from '@angular/material/form-field'; import {MatIconModule} from '@angular/material/icon'; -import {MatSelectModule} from '@angular/material/select'; import {MatInputModule} from '@angular/material/input'; import {MatRadioModule} from '@angular/material/radio'; -import {MatCheckboxModule} from '@angular/material/checkbox'; +import {MatSelectModule} from '@angular/material/select'; +import {map} from 'rxjs/operators'; /** @title Form field with label */ @Component({ @@ -23,18 +25,18 @@ import {MatCheckboxModule} from '@angular/material/checkbox'; MatSelectModule, MatIconModule, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class FormFieldLabelExample { - hideRequiredControl = new FormControl(false); - floatLabelControl = new FormControl('auto' as FloatLabelType); - options = this._formBuilder.group({ + readonly hideRequiredControl = new FormControl(false); + readonly floatLabelControl = new FormControl('auto' as FloatLabelType); + readonly options = inject(FormBuilder).group({ hideRequired: this.hideRequiredControl, floatLabel: this.floatLabelControl, }); - - constructor(private _formBuilder: FormBuilder) {} - - getFloatLabelValue(): FloatLabelType { - return this.floatLabelControl.value || 'auto'; - } + protected readonly hideRequired = toSignal(this.hideRequiredControl.valueChanges); + protected readonly floatLabel = toSignal( + this.floatLabelControl.valueChanges.pipe(map(v => v || 'auto')), + {initialValue: 'auto'}, + ); } diff --git a/src/components-examples/material/form-field/form-field-overview/form-field-overview-example.ts b/src/components-examples/material/form-field/form-field-overview/form-field-overview-example.ts index c5a820960ab9..c1d4ffe7a63a 100644 --- a/src/components-examples/material/form-field/form-field-overview/form-field-overview-example.ts +++ b/src/components-examples/material/form-field/form-field-overview/form-field-overview-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatSelectModule} from '@angular/material/select'; import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; @@ -10,5 +10,6 @@ import {MatFormFieldModule} from '@angular/material/form-field'; styleUrl: 'form-field-overview-example.css', standalone: true, imports: [MatFormFieldModule, MatInputModule, MatSelectModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class FormFieldOverviewExample {} diff --git a/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.html b/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.html index dd514eb6ba49..3bf388ecc9b2 100644 --- a/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.html +++ b/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.html @@ -1,15 +1,21 @@
    Enter your password - - Amount - + .00 diff --git a/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.ts b/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.ts index ca65f80ffd12..98f37a5ad0a9 100644 --- a/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.ts +++ b/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.ts @@ -1,8 +1,8 @@ -import {Component} from '@angular/core'; -import {MatIconModule} from '@angular/material/icon'; +import {ChangeDetectionStrategy, Component, signal} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; -import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; +import {MatIconModule} from '@angular/material/icon'; +import {MatInputModule} from '@angular/material/input'; /** @title Form field with prefix & suffix */ @Component({ @@ -11,11 +11,12 @@ import {MatFormFieldModule} from '@angular/material/form-field'; styleUrl: 'form-field-prefix-suffix-example.css', standalone: true, imports: [MatFormFieldModule, MatInputModule, MatButtonModule, MatIconModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class FormFieldPrefixSuffixExample { - hide = true; + hide = signal(true); clickEvent(event: MouseEvent) { - this.hide = !this.hide; + this.hide.set(!this.hide); event.stopPropagation(); } } diff --git a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.css b/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.css deleted file mode 100644 index d98172fcc0a3..000000000000 --- a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.css +++ /dev/null @@ -1,3 +0,0 @@ -.example-container mat-form-field + mat-form-field { - margin-left: 8px; -} diff --git a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.html b/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.html deleted file mode 100644 index 6b455564f846..000000000000 --- a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.html +++ /dev/null @@ -1,8 +0,0 @@ - - Color - - Primary - Accent - Warn - - diff --git a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.ts b/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.ts deleted file mode 100644 index 5f21cc74fef9..000000000000 --- a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.ts +++ /dev/null @@ -1,17 +0,0 @@ -import {Component} from '@angular/core'; -import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {ThemePalette} from '@angular/material/core'; -import {MatSelectModule} from '@angular/material/select'; -import {MatFormFieldModule} from '@angular/material/form-field'; - -/** @title Form field theming */ -@Component({ - selector: 'form-field-theming-example', - templateUrl: 'form-field-theming-example.html', - styleUrl: 'form-field-theming-example.css', - standalone: true, - imports: [MatFormFieldModule, MatSelectModule, FormsModule, ReactiveFormsModule], -}) -export class FormFieldThemingExample { - colorControl = new FormControl('primary' as ThemePalette); -} diff --git a/src/components-examples/material/form-field/index.ts b/src/components-examples/material/form-field/index.ts index 4e22bcbb0597..99b315986fb7 100644 --- a/src/components-examples/material/form-field/index.ts +++ b/src/components-examples/material/form-field/index.ts @@ -4,9 +4,8 @@ export { MyTelInput, } from './form-field-custom-control/form-field-custom-control-example'; export {FormFieldErrorExample} from './form-field-error/form-field-error-example'; +export {FormFieldHarnessExample} from './form-field-harness/form-field-harness-example'; export {FormFieldHintExample} from './form-field-hint/form-field-hint-example'; export {FormFieldLabelExample} from './form-field-label/form-field-label-example'; export {FormFieldOverviewExample} from './form-field-overview/form-field-overview-example'; export {FormFieldPrefixSuffixExample} from './form-field-prefix-suffix/form-field-prefix-suffix-example'; -export {FormFieldThemingExample} from './form-field-theming/form-field-theming-example'; -export {FormFieldHarnessExample} from './form-field-harness/form-field-harness-example'; diff --git a/src/components-examples/material/icon/icon-harness/icon-harness-example.ts b/src/components-examples/material/icon/icon-harness/icon-harness-example.ts index 10a8115b6976..896f99df309d 100644 --- a/src/components-examples/material/icon/icon-harness/icon-harness-example.ts +++ b/src/components-examples/material/icon/icon-harness/icon-harness-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatIconModule} from '@angular/material/icon'; /** @@ -9,5 +9,6 @@ import {MatIconModule} from '@angular/material/icon'; templateUrl: 'icon-harness-example.html', standalone: true, imports: [MatIconModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class IconHarnessExample {} diff --git a/src/components-examples/material/icon/icon-overview/icon-overview-example.ts b/src/components-examples/material/icon/icon-overview/icon-overview-example.ts index dd7b1c841e1d..e039b2508947 100644 --- a/src/components-examples/material/icon/icon-overview/icon-overview-example.ts +++ b/src/components-examples/material/icon/icon-overview/icon-overview-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatIconModule} from '@angular/material/icon'; /** @@ -9,5 +9,6 @@ import {MatIconModule} from '@angular/material/icon'; templateUrl: 'icon-overview-example.html', standalone: true, imports: [MatIconModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class IconOverviewExample {} diff --git a/src/components-examples/material/icon/icon-svg/icon-svg-example.ts b/src/components-examples/material/icon/icon-svg/icon-svg-example.ts index ed7e475a429c..e278cbc50b1c 100644 --- a/src/components-examples/material/icon/icon-svg/icon-svg-example.ts +++ b/src/components-examples/material/icon/icon-svg/icon-svg-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {DomSanitizer} from '@angular/platform-browser'; import {MatIconRegistry, MatIconModule} from '@angular/material/icon'; @@ -20,6 +20,7 @@ const THUMBUP_ICON = templateUrl: 'icon-svg-example.html', standalone: true, imports: [MatIconModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class IconSvgExample { constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) { diff --git a/src/dev-app/drag-drop/BUILD.bazel b/src/dev-app/drag-drop/BUILD.bazel index 416ba4b592d8..d41ec8215880 100644 --- a/src/dev-app/drag-drop/BUILD.bazel +++ b/src/dev-app/drag-drop/BUILD.bazel @@ -11,6 +11,7 @@ ng_module( ], deps = [ "//src/cdk/drag-drop", + "//src/material/checkbox", "//src/material/form-field", "//src/material/icon", "//src/material/input", diff --git a/src/dev-app/drag-drop/drag-drop-demo.html b/src/dev-app/drag-drop/drag-drop-demo.html index 5c011e0a1042..104101ae2496 100644 --- a/src/dev-app/drag-drop/drag-drop-demo.html +++ b/src/dev-app/drag-drop/drag-drop-demo.html @@ -68,6 +68,52 @@

    Preferred Ages

    +

    Mixed orientation

    + +

    + Wrap list +

    + +
    +
    +
    + @for (item of mixedTodo; track item) { +
    + {{item}} + +
    + } +
    +
    + +
    +
    + @for (item of mixedDone; track item) { +
    + {{item}} + +
    + } +
    +
    +
    +

    Free dragging

    +/// import { ChangeDetectionStrategy, diff --git a/src/google-maps/map-advanced-marker/map-advanced-marker.ts b/src/google-maps/map-advanced-marker/map-advanced-marker.ts index 185657d11083..aff4b6781c40 100644 --- a/src/google-maps/map-advanced-marker/map-advanced-marker.ts +++ b/src/google-maps/map-advanced-marker/map-advanced-marker.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Input, diff --git a/src/google-maps/map-anchor-point.ts b/src/google-maps/map-anchor-point.ts index 5c37a06e840b..76ed0a897a4e 100644 --- a/src/google-maps/map-anchor-point.ts +++ b/src/google-maps/map-anchor-point.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// export interface MapAnchorPoint { getAnchor(): google.maps.MVCObject | google.maps.marker.AdvancedMarkerElement; diff --git a/src/google-maps/map-base-layer.ts b/src/google-maps/map-base-layer.ts index 5448a9e5678b..0db4dfb40775 100644 --- a/src/google-maps/map-base-layer.ts +++ b/src/google-maps/map-base-layer.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import {Directive, NgZone, OnDestroy, OnInit} from '@angular/core'; diff --git a/src/google-maps/map-bicycling-layer/map-bicycling-layer.ts b/src/google-maps/map-bicycling-layer/map-bicycling-layer.ts index 0c97147478da..6817e3d26ef7 100644 --- a/src/google-maps/map-bicycling-layer/map-bicycling-layer.ts +++ b/src/google-maps/map-bicycling-layer/map-bicycling-layer.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import {Directive, EventEmitter, NgZone, OnDestroy, OnInit, Output, inject} from '@angular/core'; diff --git a/src/google-maps/map-circle/map-circle.ts b/src/google-maps/map-circle/map-circle.ts index b8c3a3b3a942..8ee8cfd72037 100644 --- a/src/google-maps/map-circle/map-circle.ts +++ b/src/google-maps/map-circle/map-circle.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Directive, diff --git a/src/google-maps/map-directions-renderer/map-directions-renderer.ts b/src/google-maps/map-directions-renderer/map-directions-renderer.ts index e6ee5868b985..6a3351c40697 100644 --- a/src/google-maps/map-directions-renderer/map-directions-renderer.ts +++ b/src/google-maps/map-directions-renderer/map-directions-renderer.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Directive, diff --git a/src/google-maps/map-directions-renderer/map-directions-service.ts b/src/google-maps/map-directions-renderer/map-directions-service.ts index a30e2a3a91e4..a63c64def5e8 100644 --- a/src/google-maps/map-directions-renderer/map-directions-service.ts +++ b/src/google-maps/map-directions-renderer/map-directions-service.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import {Injectable, NgZone} from '@angular/core'; import {Observable} from 'rxjs'; diff --git a/src/google-maps/map-geocoder/map-geocoder.ts b/src/google-maps/map-geocoder/map-geocoder.ts index 7bc138480644..978e711f3068 100644 --- a/src/google-maps/map-geocoder/map-geocoder.ts +++ b/src/google-maps/map-geocoder/map-geocoder.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import {Injectable, NgZone} from '@angular/core'; import {Observable} from 'rxjs'; diff --git a/src/google-maps/map-ground-overlay/map-ground-overlay.ts b/src/google-maps/map-ground-overlay/map-ground-overlay.ts index bb67c6bf8bb6..22952f01ece8 100644 --- a/src/google-maps/map-ground-overlay/map-ground-overlay.ts +++ b/src/google-maps/map-ground-overlay/map-ground-overlay.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Directive, diff --git a/src/google-maps/map-heatmap-layer/map-heatmap-layer.ts b/src/google-maps/map-heatmap-layer/map-heatmap-layer.ts index 62b159dbe0a8..d6d7288677ac 100644 --- a/src/google-maps/map-heatmap-layer/map-heatmap-layer.ts +++ b/src/google-maps/map-heatmap-layer/map-heatmap-layer.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Input, diff --git a/src/google-maps/map-info-window/map-info-window.ts b/src/google-maps/map-info-window/map-info-window.ts index 0d1f51878aa8..f0dac16bcfb2 100644 --- a/src/google-maps/map-info-window/map-info-window.ts +++ b/src/google-maps/map-info-window/map-info-window.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Directive, diff --git a/src/google-maps/map-kml-layer/map-kml-layer.ts b/src/google-maps/map-kml-layer/map-kml-layer.ts index d1930c848960..5dcd1a22391b 100644 --- a/src/google-maps/map-kml-layer/map-kml-layer.ts +++ b/src/google-maps/map-kml-layer/map-kml-layer.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Directive, diff --git a/src/google-maps/map-marker-clusterer/map-marker-clusterer.ts b/src/google-maps/map-marker-clusterer/map-marker-clusterer.ts index c9edcf57c9c4..d2d8a645652c 100644 --- a/src/google-maps/map-marker-clusterer/map-marker-clusterer.ts +++ b/src/google-maps/map-marker-clusterer/map-marker-clusterer.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { AfterContentInit, diff --git a/src/google-maps/map-marker-clusterer/marker-clusterer-types.ts b/src/google-maps/map-marker-clusterer/marker-clusterer-types.ts index 8c5f99d34c33..3612963cfab8 100644 --- a/src/google-maps/map-marker-clusterer/marker-clusterer-types.ts +++ b/src/google-maps/map-marker-clusterer/marker-clusterer-types.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -/// +/// /** * Class for clustering markers on a Google Map. diff --git a/src/google-maps/map-marker/map-marker.ts b/src/google-maps/map-marker/map-marker.ts index c3bb4d584a4a..520c1ff5d375 100644 --- a/src/google-maps/map-marker/map-marker.ts +++ b/src/google-maps/map-marker/map-marker.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Input, diff --git a/src/google-maps/map-polygon/map-polygon.ts b/src/google-maps/map-polygon/map-polygon.ts index 07fce1691b28..449193242a68 100644 --- a/src/google-maps/map-polygon/map-polygon.ts +++ b/src/google-maps/map-polygon/map-polygon.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Directive, diff --git a/src/google-maps/map-polyline/map-polyline.ts b/src/google-maps/map-polyline/map-polyline.ts index fa8d16149e9a..838aa31e4eaf 100644 --- a/src/google-maps/map-polyline/map-polyline.ts +++ b/src/google-maps/map-polyline/map-polyline.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Directive, diff --git a/src/google-maps/map-rectangle/map-rectangle.ts b/src/google-maps/map-rectangle/map-rectangle.ts index b789c7a94128..4b03d07cd7fe 100644 --- a/src/google-maps/map-rectangle/map-rectangle.ts +++ b/src/google-maps/map-rectangle/map-rectangle.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import { Directive, diff --git a/src/google-maps/map-traffic-layer/map-traffic-layer.ts b/src/google-maps/map-traffic-layer/map-traffic-layer.ts index 63060f31264c..2bebd34f8824 100644 --- a/src/google-maps/map-traffic-layer/map-traffic-layer.ts +++ b/src/google-maps/map-traffic-layer/map-traffic-layer.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import {Directive, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output} from '@angular/core'; import {BehaviorSubject, Observable, Subject} from 'rxjs'; diff --git a/src/google-maps/map-transit-layer/map-transit-layer.ts b/src/google-maps/map-transit-layer/map-transit-layer.ts index 9d49114d5b3b..5c897d6a0dee 100644 --- a/src/google-maps/map-transit-layer/map-transit-layer.ts +++ b/src/google-maps/map-transit-layer/map-transit-layer.ts @@ -7,7 +7,7 @@ */ // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// +/// import {Directive, EventEmitter, NgZone, OnDestroy, OnInit, Output, inject} from '@angular/core'; diff --git a/src/material-luxon-adapter/adapter/luxon-date-adapter.ts b/src/material-luxon-adapter/adapter/luxon-date-adapter.ts index ef518cd5a181..a4dc2e2a734a 100644 --- a/src/material-luxon-adapter/adapter/luxon-date-adapter.ts +++ b/src/material-luxon-adapter/adapter/luxon-date-adapter.ts @@ -135,7 +135,7 @@ export class LuxonDateAdapter extends DateAdapter { } getNumDaysInMonth(date: LuxonDateTime): number { - return date.daysInMonth; + return date.daysInMonth!; } clone(date: LuxonDateTime): LuxonDateTime { @@ -231,7 +231,7 @@ export class LuxonDateAdapter extends DateAdapter { } toIso8601(date: LuxonDateTime): string { - return date.toISO(); + return date.toISO()!; } /** diff --git a/src/material/autocomplete/autocomplete-trigger.ts b/src/material/autocomplete/autocomplete-trigger.ts index bbfb7756f71f..45211bb28e19 100644 --- a/src/material/autocomplete/autocomplete-trigger.ts +++ b/src/material/autocomplete/autocomplete-trigger.ts @@ -9,6 +9,7 @@ import {addAriaReferencedId, removeAriaReferencedId} from '@angular/cdk/a11y'; import {Directionality} from '@angular/cdk/bidi'; import {DOWN_ARROW, ENTER, ESCAPE, TAB, UP_ARROW, hasModifierKey} from '@angular/cdk/keycodes'; +import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout'; import { ConnectedPosition, FlexibleConnectedPositionStrategy, @@ -161,6 +162,10 @@ export class MatAutocompleteTrigger /** Subscription to viewport size changes. */ private _viewportSubscription = Subscription.EMPTY; + /** Implements BreakpointObserver to be used to detect handset landscape */ + private _breakpointObserver = inject(BreakpointObserver); + private _handsetLandscapeSubscription = Subscription.EMPTY; + /** * Whether the autocomplete can open the next time it is focused. Used to prevent a focused, * closed autocomplete from being reopened if the user switches to another browser tab and then @@ -282,6 +287,7 @@ export class MatAutocompleteTrigger window.removeEventListener('blur', this._windowBlurHandler); } + this._handsetLandscapeSubscription.unsubscribe(); this._viewportSubscription.unsubscribe(); this._componentDestroyed = true; this._destroyPanel(); @@ -790,6 +796,26 @@ export class MatAutocompleteTrigger overlayRef.updateSize({width: this._getPanelWidth()}); } }); + // Subscribe to the breakpoint events stream to detect when screen is in + // handsetLandscape. + this._handsetLandscapeSubscription = this._breakpointObserver + .observe(Breakpoints.HandsetLandscape) + .subscribe(result => { + const isHandsetLandscape = result.matches; + // Check if result.matches Breakpoints.HandsetLandscape. Apply HandsetLandscape + // settings to prevent overlay cutoff in that breakpoint. Fixes b/284148377 + if (isHandsetLandscape) { + this._positionStrategy + .withFlexibleDimensions(true) + .withGrowAfterOpen(true) + .withViewportMargin(8); + } else { + this._positionStrategy + .withFlexibleDimensions(false) + .withGrowAfterOpen(false) + .withViewportMargin(0); + } + }); } else { // Update the trigger, panel width and direction, in case anything has changed. this._positionStrategy.setOrigin(this._getConnectedElement()); @@ -881,6 +907,7 @@ export class MatAutocompleteTrigger } private _getOverlayPosition(): PositionStrategy { + // Set default Overlay Position const strategy = this._overlay .position() .flexibleConnectedTo(this._getConnectedElement()) diff --git a/src/material/autocomplete/autocomplete.spec.ts b/src/material/autocomplete/autocomplete.spec.ts index e3fb456880b0..cee2f191382b 100644 --- a/src/material/autocomplete/autocomplete.spec.ts +++ b/src/material/autocomplete/autocomplete.spec.ts @@ -2183,7 +2183,7 @@ describe('MDC-based MatAutocomplete', () => { let inputReference = fixture.debugElement.query(By.css('.mdc-text-field'))!.nativeElement; // Push the element down so it has a little bit of space, but not enough to render. - inputReference.style.bottom = '75px'; + inputReference.style.bottom = '100px'; inputReference.style.position = 'fixed'; dispatchFakeEvent(inputEl, 'focusin'); diff --git a/src/material/badge/badge.md b/src/material/badge/badge.md index 9a636d75d053..c3263b2e94df 100644 --- a/src/material/badge/badge.md +++ b/src/material/badge/badge.md @@ -1,4 +1,4 @@ -Badges are small status descriptors for UI elements. A badge consists of a small circle, +Badges are small status descriptors for UI elements. A badge consists of a small circle, typically containing a number or other short set of characters, that appears in proximity to another object. @@ -13,7 +13,7 @@ By default, the badge will be placed `above after`. The direction can be changed the attribute `matBadgePosition` follow by `above|below` and `before|after`. The overlap of the badge in relation to its inner contents can also be defined @@ -21,32 +21,27 @@ using the `matBadgeOverlap` tag. Typically, you want the badge to overlap an ico a text phrase. By default it will overlap. ### Badge sizing The badge has 3 sizes: `small`, `medium` and `large`. By default, the badge is set to `medium`. + +Badges that are `small` do not show the label text. This can be useful in contexts such as showing there are unread notifications but not needing to show the exact amount. + You can change the size by adding `matBadgeSize` to the host element. ### Badge visibility The badge visibility can be toggled programmatically by defining `matBadgeHidden`. -### Theming -Badges can be colored in terms of the current theme using the `matBadgeColor` property to set the -background color to `primary`, `accent`, or `warn`. - - - ### Accessibility You must provide a meaningful description via `matBadgeDescription`. When attached to an interactive element, `MatBadge` applies this description to its host via `aria-describedby`. When attached to diff --git a/src/material/badge/badge.ts b/src/material/badge/badge.ts index 14f8a9daf616..4b8676981409 100644 --- a/src/material/badge/badge.ts +++ b/src/material/badge/badge.ts @@ -83,7 +83,10 @@ export class _MatBadgeStyleLoader {} standalone: true, }) export class MatBadge implements OnInit, OnDestroy { - /** The color of the badge. Can be `primary`, `accent`, or `warn`. */ + /** + * The color of the badge. Can be `primary`, `accent`, or `warn`. + * Not recommended in M3, for more information see https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants. + */ @Input('matBadgeColor') get color(): ThemePalette { return this._color; diff --git a/src/material/button-toggle/button-toggle.md b/src/material/button-toggle/button-toggle.md index 9f7c5259cdea..7634db910ab4 100644 --- a/src/material/button-toggle/button-toggle.md +++ b/src/material/button-toggle/button-toggle.md @@ -19,7 +19,7 @@ and `ngModel` is not supported. ### Appearance By default, the appearance of `mat-button-toggle-group` and `mat-button-toggle` will follow the latest Material Design guidelines. If you want to, you can switch back to the appearance that was -following the previous Material Design spec by using the `appearance` input. The `appearance` can +following a previous Material Design spec by using the `appearance` input. The `appearance` can be configured globally using the `MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS` injection token. diff --git a/src/material/button/button-base.ts b/src/material/button/button-base.ts index 33c80a167db1..59b81efb4321 100644 --- a/src/material/button/button-base.ts +++ b/src/material/button/button-base.ts @@ -107,7 +107,13 @@ export class MatButtonBase implements AfterViewInit, OnDestroy { this._rippleLoader?.attachRipple(this._elementRef.nativeElement, v); } - /** Theme color palette of the button */ + /** + * Theme color of the button. This API is supported in M2 themes only, it has + * no effect in M3 themes. + * + * For information on applying color variants in M3, see + * https://material.angular.io/guide/theming#using-component-color-variants. + */ @Input() color?: string | null; /** Whether the ripple effect is disabled or not. */ diff --git a/src/material/button/button.md b/src/material/button/button.md index 9e2a135b96f8..6b51d9963fc0 100644 --- a/src/material/button/button.md +++ b/src/material/button/button.md @@ -12,26 +12,15 @@ There are several button variants, each applied as an attribute: | Attribute | Description | |----------------------|--------------------------------------------------------------------------| -| `mat-button` | Rectangular text button w/ no elevation | -| `mat-raised-button` | Rectangular contained button w/ elevation | -| `mat-flat-button` | Rectangular contained button w/ no elevation | -| `mat-stroked-button` | Rectangular outlined button w/ no elevation | +| `mat-button` | Rectangular text button w/ no elevation and rounded corners | +| `mat-raised-button` | Rectangular contained button w/ elevation and rounded corners | +| `mat-flat-button` | Rectangular contained button w/ no elevation and rounded corners | +| `mat-stroked-button` | Rectangular outlined button w/ no elevation and rounded corners | | `mat-icon-button` | Circular button with a transparent background, meant to contain an icon | -| `mat-fab` | Circular button w/ elevation, defaults to theme's accent color | +| `mat-fab` | Square button w/ elevation and rounded corners, meant to contain an icon. Can be [extended](https://material.angular.io/components/button/overview#extended-fab-buttons) to a rectangle to also fit a label | | `mat-mini-fab` | Same as `mat-fab` but smaller | -### Theming -Buttons can be colored in terms of the current theme using the `color` property to set the -background color to `primary`, `accent`, or `warn`. - -### Capitalization -According to the Material design spec button text has to be capitalized, however we have opted not -to capitalize buttons automatically via `text-transform: uppercase`, because it can cause issues in -certain locales. It is also worth noting that using ALL CAPS in the text itself causes issues for -screen-readers, which will read the text character-by-character. We leave the decision of how to -approach this to the consuming app. - ### Extended fab buttons Traditional fab buttons are circular and only have space for a single icon. However, you can add the `extended` attribute to allow the fab to expand into a rounded rectangle shape with space for a text @@ -64,6 +53,11 @@ default. A `