_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
components/src/dev-app/expansion/expansion-demo.scss_0_230
.demo-expansion-width { width: 600px; display: block; } .demo-expansion-code { background: #d3d3d3; display: block; height: 10em; overflow: auto; padding: 0 5px; width: 400px; pre { margin: 0.25em 0; } }
{ "end_byte": 230, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/expansion/expansion-demo.scss" }
components/src/dev-app/expansion/expansion-demo.ts_0_1734
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {CdkAccordionModule} from '@angular/cdk/accordion'; import {ChangeDetectionStrategy, Component, ViewChild} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {MatButtonModule} from '@angular/material/button'; import {MatCheckboxModule} from '@angular/material/checkbox'; import { MatAccordion, MatAccordionDisplayMode, MatAccordionTogglePosition, MatExpansionModule, } from '@angular/material/expansion'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatInputModule} from '@angular/material/input'; import {MatRadioModule} from '@angular/material/radio'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; @Component({ selector: 'expansion-demo', styleUrl: 'expansion-demo.css', templateUrl: 'expansion-demo.html', imports: [ CdkAccordionModule, FormsModule, MatButtonModule, MatCheckboxModule, MatExpansionModule, MatFormFieldModule, MatInputModule, MatRadioModule, MatSlideToggleModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExpansionDemo { @ViewChild(MatAccordion) accordion: MatAccordion; displayMode: MatAccordionDisplayMode = 'default'; multi = false; hideToggle = false; disabled = false; showPanel3 = true; togglePosition: MatAccordionTogglePosition = 'after'; expandedHeight: string; collapsedHeight: string; events: string[] = []; addEvent(eventName: string) { this.events.push(`${eventName} - ${new Date().toISOString()}`); } }
{ "end_byte": 1734, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/expansion/expansion-demo.ts" }
components/src/dev-app/expansion/BUILD.bazel_0_675
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "expansion", srcs = glob(["**/*.ts"]), assets = [ "expansion-demo.html", ":expansion_demo_scss", ], deps = [ "//src/cdk/accordion", "//src/material/button", "//src/material/checkbox", "//src/material/expansion", "//src/material/form-field", "//src/material/input", "//src/material/radio", "//src/material/slide-toggle", "@npm//@angular/forms", ], ) sass_binary( name = "expansion_demo_scss", src = "expansion-demo.scss", )
{ "end_byte": 675, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/expansion/BUILD.bazel" }
components/src/dev-app/button-toggle/button-toggle-demo.html_0_4405
<p> <mat-checkbox (change)="isVertical = $event.checked">Show Button Toggles Vertical</mat-checkbox> </p> <p> <mat-checkbox (change)="isDisabled = $event.checked">Disable Button Toggle Items</mat-checkbox> </p> <p> <mat-checkbox (change)="disabledInteractive = $event.checked">Allow Interaction with Disabled Button Toggles</mat-checkbox> </p> <p> <mat-checkbox (change)="hideSingleSelectionIndicator = $event.checked">Hide Single Selection Indicator</mat-checkbox> </p> <p> <mat-checkbox (change)="hideMultipleSelectionIndicator = $event.checked">Hide Multiple Selection Indicator</mat-checkbox> </p> <h1>Exclusive Selection</h1> <section> <mat-button-toggle-group name="alignment" [vertical]="isVertical" [hideSingleSelectionIndicator]="hideSingleSelectionIndicator" [disabledInteractive]="disabledInteractive"> <mat-button-toggle value="left" [disabled]="isDisabled"> <mat-icon>format_align_left</mat-icon> </mat-button-toggle> <mat-button-toggle value="center" [disabled]="isDisabled"> <mat-icon>format_align_center</mat-icon> </mat-button-toggle> <mat-button-toggle value="right" [disabled]="isDisabled"> <mat-icon>format_align_right</mat-icon> </mat-button-toggle> <mat-button-toggle value="justify" [disabled]="isDisabled"> <mat-icon>format_align_justify</mat-icon> </mat-button-toggle> </mat-button-toggle-group> </section> <section> <mat-button-toggle-group appearance="legacy" name="alignment" [vertical]="isVertical" [hideSingleSelectionIndicator]="hideSingleSelectionIndicator" [disabledInteractive]="disabledInteractive"> <mat-button-toggle value="left" [disabled]="isDisabled"> <mat-icon>format_align_left</mat-icon> </mat-button-toggle> <mat-button-toggle value="center" [disabled]="isDisabled"> <mat-icon>format_align_center</mat-icon> </mat-button-toggle> <mat-button-toggle value="right" [disabled]="isDisabled"> <mat-icon>format_align_right</mat-icon> </mat-button-toggle> <mat-button-toggle value="justify" [disabled]="isDisabled"> <mat-icon>format_align_justify</mat-icon> </mat-button-toggle> </mat-button-toggle-group> </section> <h1>Disabled Group</h1> <section> <mat-button-toggle-group name="checkbox" [vertical]="isVertical" [disabled]="isDisabled" [hideSingleSelectionIndicator]="hideSingleSelectionIndicator" [disabledInteractive]="disabledInteractive"> <mat-button-toggle value="bold"> <mat-icon>format_bold</mat-icon> </mat-button-toggle> <mat-button-toggle value="italic"> <mat-icon>format_italic</mat-icon> </mat-button-toggle> <mat-button-toggle value="underline"> <mat-icon>format_underlined</mat-icon> </mat-button-toggle> </mat-button-toggle-group> </section> <h1>Multiple Selection</h1> <section> <mat-button-toggle-group multiple [vertical]="isVertical" [hideMultipleSelectionIndicator]="hideMultipleSelectionIndicator" [disabledInteractive]="disabledInteractive"> <mat-button-toggle>Flour</mat-button-toggle> <mat-button-toggle>Eggs</mat-button-toggle> <mat-button-toggle>Sugar</mat-button-toggle> <mat-button-toggle [disabled]="isDisabled">Milk</mat-button-toggle> </mat-button-toggle-group> </section> <section> <mat-button-toggle-group appearance="legacy" multiple [vertical]="isVertical" [hideMultipleSelectionIndicator]="hideMultipleSelectionIndicator" [disabledInteractive]="disabledInteractive"> <mat-button-toggle>Flour</mat-button-toggle> <mat-button-toggle>Eggs</mat-button-toggle> <mat-button-toggle>Sugar</mat-button-toggle> <mat-button-toggle [disabled]="isDisabled">Milk</mat-button-toggle> </mat-button-toggle-group> </section> <h1>Single Toggle</h1> <mat-button-toggle>Yes</mat-button-toggle> <mat-button-toggle appearance="legacy">Yes</mat-button-toggle> <h1>Dynamic Exclusive Selection</h1> <section> <mat-button-toggle-group name="pies" [(ngModel)]="favoritePie" [vertical]="isVertical" [hideSingleSelectionIndicator]="hideSingleSelectionIndicator" [disabledInteractive]="disabledInteractive"> @for (pie of pieOptions; track pie) { <mat-button-toggle [value]="pie">{{pie}}</mat-button-toggle> } </mat-button-toggle-group> <p>Your favorite type of pie is: {{favoritePie}}</p> </section>
{ "end_byte": 4405, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/button-toggle/button-toggle-demo.html" }
components/src/dev-app/button-toggle/button-toggle-demo.scss_0_35
section { margin-bottom: 16px; }
{ "end_byte": 35, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/button-toggle/button-toggle-demo.scss" }
components/src/dev-app/button-toggle/button-toggle-demo.ts_0_1036
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {MatButtonToggleModule} from '@angular/material/button-toggle'; import {MatCheckboxModule} from '@angular/material/checkbox'; import {MatIconModule} from '@angular/material/icon'; @Component({ selector: 'button-toggle-demo', templateUrl: 'button-toggle-demo.html', styleUrl: 'button-toggle-demo.css', imports: [FormsModule, MatButtonToggleModule, MatCheckboxModule, MatIconModule], changeDetection: ChangeDetectionStrategy.OnPush, }) export class ButtonToggleDemo { isVertical = false; isDisabled = false; disabledInteractive = false; hideSingleSelectionIndicator = false; hideMultipleSelectionIndicator = false; favoritePie = 'Apple'; pieOptions = ['Apple', 'Cherry', 'Pecan', 'Lemon']; }
{ "end_byte": 1036, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/button-toggle/button-toggle-demo.ts" }
components/src/dev-app/button-toggle/BUILD.bazel_0_494
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "button-toggle", srcs = glob(["**/*.ts"]), assets = [ "button-toggle-demo.html", ":button_toggle_demo_scss", ], deps = [ "//src/material/button-toggle", "//src/material/checkbox", "//src/material/icon", ], ) sass_binary( name = "button_toggle_demo_scss", src = "button-toggle-demo.scss", )
{ "end_byte": 494, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/button-toggle/BUILD.bazel" }
components/src/dev-app/column-resize/column-resize-home.html_0_851
<mat-expansion-panel> <mat-expansion-panel-header> <mat-panel-title> Enabled-by-default column resize for MatTable </mat-panel-title> </mat-expansion-panel-header> <default-enabled-column-resize-example></default-enabled-column-resize-example> </mat-expansion-panel> <mat-expansion-panel> <mat-expansion-panel-header> <mat-panel-title> Enabled-by-default column resize for flex MatTable </mat-panel-title> </mat-expansion-panel-header> <default-enabled-column-resize-flex-example></default-enabled-column-resize-flex-example> </mat-expansion-panel> <mat-expansion-panel> <mat-expansion-panel-header> <mat-panel-title> Opt-in column resize for MatTable </mat-panel-title> </mat-expansion-panel-header> <opt-in-column-resize-example></opt-in-column-resize-example> </mat-expansion-panel>
{ "end_byte": 851, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/column-resize/column-resize-home.html" }
components/src/dev-app/column-resize/BUILD.bazel_0_373
load("//tools:defaults.bzl", "ng_module") package(default_visibility = ["//visibility:public"]) ng_module( name = "column-resize", srcs = glob(["**/*.ts"]), assets = ["column-resize-home.html"], deps = [ "//src/components-examples/material-experimental/column-resize", "//src/dev-app/example", "//src/material/expansion", ], )
{ "end_byte": 373, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/column-resize/BUILD.bazel" }
components/src/dev-app/column-resize/column-resize-home.ts_0_821
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { DefaultEnabledColumnResizeExample, DefaultEnabledColumnResizeFlexExample, OptInColumnResizeExample, } from '@angular/components-examples/material-experimental/column-resize'; import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatExpansionModule} from '@angular/material/expansion'; @Component({ templateUrl: 'column-resize-home.html', imports: [ MatExpansionModule, DefaultEnabledColumnResizeExample, DefaultEnabledColumnResizeFlexExample, OptInColumnResizeExample, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class ColumnResizeHome {}
{ "end_byte": 821, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/column-resize/column-resize-home.ts" }
components/src/dev-app/button/button-demo.ts_0_1209
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormsModule} from '@angular/forms'; import { MatAnchor, MatButton, MatFabAnchor, MatFabButton, MatIconAnchor, MatIconButton, MatMiniFabAnchor, MatMiniFabButton, } from '@angular/material/button'; import {MatCheckbox} from '@angular/material/checkbox'; import {MatIcon} from '@angular/material/icon'; import {MatTooltip} from '@angular/material/tooltip'; @Component({ selector: 'button-demo', templateUrl: 'button-demo.html', styleUrl: 'button-demo.css', imports: [ MatButton, MatAnchor, MatFabButton, MatFabAnchor, MatMiniFabButton, MatMiniFabAnchor, MatIconButton, MatIconAnchor, MatIcon, MatTooltip, MatCheckbox, FormsModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class ButtonDemo { isDisabled = false; clickCounter = 0; toggleDisable = false; tooltipText = 'This is a button tooltip!'; disabledInteractive = false; }
{ "end_byte": 1209, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/button/button-demo.ts" }
components/src/dev-app/button/BUILD.bazel_0_486
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "button", srcs = glob(["**/*.ts"]), assets = [ "button-demo.html", ":button_demo_scss", ], deps = [ "//src/material/button", "//src/material/checkbox", "//src/material/icon", "//src/material/tooltip", ], ) sass_binary( name = "button_demo_scss", src = "button-demo.scss", )
{ "end_byte": 486, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/button/BUILD.bazel" }
components/src/dev-app/button/button-demo.scss_0_250
button, a { margin: 8px; text-transform: uppercase; } section { display: flex; align-items: center; margin: 8px; } p { padding: 5px 15px; } .demo-section-header { font-weight: 500; margin: 0; } .demo-no-flex { display: block; }
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/button/button-demo.scss" }
components/src/dev-app/button/button-demo.html_0_7675
<div class="demo-button"> <h4 class="demo-section-header">Buttons</h4> <section> <button mat-button>normal</button> <button mat-raised-button>raised</button> <button mat-stroked-button>stroked</button> <button mat-flat-button>flat</button> <button mat-fab> <mat-icon>check</mat-icon> </button> <button mat-mini-fab> <mat-icon>check</mat-icon> </button> <button mat-fab extended>Search</button> <button mat-fab extended> <mat-icon>check</mat-icon> Search <mat-icon iconPositionEnd>check</mat-icon> </button> </section> <section> <button mat-button disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText">normal</button> <button mat-raised-button disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText">raised</button> <button mat-stroked-button disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText">stroked</button> <button mat-flat-button disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText">flat</button> <button mat-fab disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText"> <mat-icon>check</mat-icon> </button> <button mat-mini-fab disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText"> <mat-icon>check</mat-icon> </button> <button mat-fab extended disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText">Search</button> <button mat-fab extended disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText"> <mat-icon>check</mat-icon> Search <mat-icon iconPositionEnd>check</mat-icon> </button> </section> <h4 class="demo-section-header">Anchors</h4> <section> <a href="//www.google.com" mat-button>SEARCH</a> <a href="//www.google.com" mat-raised-button>SEARCH</a> <a href="//www.google.com" mat-stroked-button>SEARCH</a> <a href="//www.google.com" mat-flat-button>SEARCH</a> <a href="//www.google.com" mat-fab> <mat-icon>check</mat-icon> </a> <a href="//www.google.com" mat-mini-fab> <mat-icon>check</mat-icon> </a> <a href="//www.google.com" mat-fab extended>Search</a> <a href="//www.google.com" mat-fab extended> <mat-icon>check</mat-icon> Search <mat-icon iconPositionEnd>check</mat-icon> </a> </section> <section> <a href="//www.google.com" disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText" mat-button color="primary">SEARCH</a> <a href="//www.google.com" disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText" mat-raised-button>SEARCH</a> <a href="//www.google.com" disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText" mat-stroked-button color="primary">SEARCH</a> <a href="//www.google.com" disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText" mat-flat-button>SEARCH</a> <a href="//www.google.com" disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText" mat-fab> <mat-icon>check</mat-icon> </a> <a href="//www.google.com" disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText" mat-mini-fab> <mat-icon>check</mat-icon> </a> <a href="//www.google.com" disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText" mat-fab extended>Search</a> <a href="//www.google.com" disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText" mat-fab extended> <mat-icon>check</mat-icon> Search <mat-icon iconPositionEnd>check</mat-icon> </a> </section> <h4 class="demo-section-header">Text Buttons [mat-button]</h4> <section> <button mat-button>unthemed</button> <button mat-button color="primary">primary</button> <button mat-button color="accent">accent</button> <button mat-button color="warn">warn</button> <button mat-button disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText">disabled</button> <button mat-button> <mat-icon>home</mat-icon> with icons <mat-icon iconPositionEnd>favorite</mat-icon> </button> <button mat-button> <mat-icon>home</mat-icon> with icons </button> </section> <h4 class="demo-section-header">Raised Buttons [mat-raised-button]</h4> <section> <button mat-raised-button>unthemed</button> <button mat-raised-button color="primary">primary</button> <button mat-raised-button color="accent">accent</button> <button mat-raised-button color="warn">warn</button> <button mat-raised-button disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText">disabled</button> <button mat-raised-button> <mat-icon>home</mat-icon> with icons <mat-icon iconPositionEnd>favorite</mat-icon> </button> <button mat-raised-button> <mat-icon>home</mat-icon> with icons </button> </section> <h4 class="demo-section-header">Stroked Buttons [mat-stroked-button]</h4> <section> <button mat-stroked-button>unthemed</button> <button mat-stroked-button color="primary">primary</button> <button mat-stroked-button color="accent">accent</button> <button mat-stroked-button color="warn">warn</button> <button mat-stroked-button disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText">disabled</button> <button mat-stroked-button> <mat-icon>home</mat-icon> with icons <mat-icon iconPositionEnd>favorite</mat-icon> </button> <button mat-stroked-button> <mat-icon>home</mat-icon> with icons </button> </section> <h4 class="demo-section-header">Flat Buttons [mat-flat-button]</h4> <section> <button mat-flat-button>unthemed</button> <button mat-flat-button color="primary">primary</button> <button mat-flat-button color="accent">accent</button> <button mat-flat-button color="warn">warn</button> <button mat-flat-button disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText">disabled</button> <button mat-flat-button> <mat-icon>home</mat-icon> with icons <mat-icon iconPositionEnd>favorite</mat-icon> </button> <button mat-flat-button> <mat-icon>home</mat-icon> with icons </button> </section> <h4 class="demo-section-header">Icon Buttons [mat-icon-button]</h4> <section> <button mat-icon-button> <mat-icon>cached</mat-icon> </button> <button mat-icon-button color="primary"> <mat-icon>cached</mat-icon> </button> <button mat-icon-button color="accent"> <mat-icon>backup</mat-icon> </button> <button mat-icon-button color="warn"> <mat-icon>trending_up</mat-icon> </button> <button mat-icon-button disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText"> <mat-icon>visibility</mat-icon> </button> </section>
{ "end_byte": 7675, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/button/button-demo.html" }
components/src/dev-app/button/button-demo.html_7679_11028
<h4 class="demo-section-header">Icon Button Anchors [mat-icon-button]</h4> <section> <a href="#" mat-icon-button> <mat-icon>cached</mat-icon> </a> <a href="#" mat-icon-button color="primary"> <mat-icon>cached</mat-icon> </a> <a href="#" mat-icon-button color="accent"> <mat-icon>backup</mat-icon> </a> <a href="#" mat-icon-button color="warn"> <mat-icon>trending_up</mat-icon> </a> <a href="#" mat-icon-button disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText"> <mat-icon>visibility</mat-icon> </a> </section> <h4 class="demo-section-header">Fab Buttons [mat-fab]</h4> <section> <button mat-fab> <mat-icon>delete</mat-icon> </button> <button mat-fab color="primary"> <mat-icon>delete</mat-icon> </button> <button mat-fab color="accent"> <mat-icon>bookmark</mat-icon> </button> <button mat-fab color="warn"> <mat-icon>home</mat-icon> </button> <button mat-fab disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText"> <mat-icon>favorite</mat-icon> </button> </section> <h4 class="demo-section-header"> Mini Fab Buttons [mat-mini-fab]</h4> <section> <button mat-mini-fab> <mat-icon>menu</mat-icon> </button> <button mat-mini-fab color="primary"> <mat-icon>menu</mat-icon> </button> <button mat-mini-fab color="accent"> <mat-icon>plus_one</mat-icon> </button> <button mat-mini-fab color="warn"> <mat-icon>filter_list</mat-icon> </button> <button mat-mini-fab disabled [disabledInteractive]="disabledInteractive" [matTooltip]="tooltipText"> <mat-icon>home</mat-icon> </button> </section> <h4 class="demo-section-header">Interaction/State</h4> <section class="demo-no-flex"> <div> <p>isDisabled: {{isDisabled}}</p> <p>Button 1 as been clicked {{clickCounter}} times</p> <p> <mat-checkbox [(ngModel)]="disabledInteractive">Allow disabled button interactivity</mat-checkbox> </p> <p> <mat-checkbox [(ngModel)]="isDisabled">All disabled</mat-checkbox> </p> <button mat-flat-button (click)="button1.focus()">Focus 1</button> <button mat-flat-button (click)="button2.focus()">Focus 2</button> <button mat-flat-button (click)="button3.focus()">Focus 3</button> <button mat-flat-button (click)="button4.focus()">Focus 4</button> </div> <div> <button mat-button #button1 [disabled]="isDisabled" (click)="clickCounter=clickCounter+1"> Button 1 </button> <button mat-button #button2 color="primary" [disabled]="isDisabled"> Button 2 </button> <a href="//www.google.com" #button3 mat-button color="accent" [disabled]="isDisabled"> Button 3 </a> <button mat-raised-button #button4 color="primary" [disabled]="isDisabled"> Button 4 </button> <button mat-mini-fab [disabled]="isDisabled"> <mat-icon>check</mat-icon> </button> <button mat-icon-button color="accent" [disabled]="isDisabled"> <mat-icon>favorite</mat-icon> </button> </div> </section> </div>
{ "end_byte": 11028, "start_byte": 7679, "url": "https://github.com/angular/components/blob/main/src/dev-app/button/button-demo.html" }
components/src/dev-app/theme/theme-demo.scss_0_4308
@use '@angular/material' as mat; :host { display: block; max-width: 1000px; } h1 { font: var(--mat-sys-title-large); font-size: 28px; padding-top: 32px; } h2 { font: var(--mat-sys-title-large); } a { color: var(--mat-sys-primary); } .demo-warn { background: var(--mat-sys-error-container); color: var(--mat-sys-on-error-container); border: 1px solid var(--mat-sys-outline-variant); border-radius: var(--mat-sys-corner-extra-small); padding: 8px; } .demo-group { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 24px; margin-top: 24px; } @media (max-width: 1000px) { .demo-group { grid-template-columns: auto;} } .demo-color-container { border-radius: var(--mat-sys-corner-small); display: inline-block; font: var(--mat-sys-body-medium); vertical-align: top; } .demo-heading { color: var(--mat-sys-on-primary); background: var(--mat-sys-primary); border: 1px solid var(--mat-sys-outline); border-top-right-radius: var(--mat-sys-corner-small); border-top-left-radius: var(--mat-sys-corner-small); border-bottom: none; padding: 16px; display: flex; align-items: center; justify-content: space-between; } .demo-name { font: var(--mat-sys-title-medium); } .demo-variable { font: var(--mat-sys-title-small); font-family: monospace; text-align: right; } .demo-description { border: 1px solid var(--mat-sys-outline); border-bottom-right-radius: var(--mat-sys-corner-small); border-bottom-left-radius: var(--mat-sys-corner-small); padding: 0 16px; } .demo-code { font-family: monospace; } .demo-surface-variable { display: inline-block; font-family: monospace; background: var(--mat-sys-primary-container); color: var(--mat-sys-on-primary-container); padding: 2px 6px; margin: 0 2px; border-radius: 4px; } mat-expansion-panel { margin-top: 24px; overflow: visible; @include mat.expansion-overrides(( 'container-text-font': var(--mat-sys-body-medium-font), 'container-text-size': var(--mat-sys-body-medium-size), 'container-text-weight': var(--mat-sys-body-medium-weight), 'container-text-line-height': var(--mat-sys-body-medium-line-height), 'container-text-tracking': var(--mat-sys-body-medium-tracking), )); } .demo-compact-color-container { border-radius: var(--mat-sys-corner-small); border: 1px solid var(--mat-sys-outline); overflow: hidden; // Hide child heading background color margin-top: 24px; .demo-heading { border: none; border-radius: 0; &:not(:nth-child(1)) { border-top: 1px solid var(--mat-sys-outline); } } .demo-variables { text-align: end; } } .demo-typography-group { border: 1px solid var(--mat-sys-outline); border-radius: var(--mat-sys-corner-small); margin-top: 40px; overflow: hidden; } .demo-typography-title { text-transform: capitalize; font: var(--mat-sys-title-medium); padding: 16px; border-bottom: 1px solid var(--mat-sys-outline); background: var(--mat-sys-primary-container); color: var(--mat-sys-on-primary-container); } .demo-typography-variable { min-width: 240px; } .demo-typography-example { padding: 16px; display: flex; align-items: baseline; border-top: 1px solid var(--mat-sys-outline-variant); &:nth-child(1) { border: none; } .demo-surface-variable { margin-right: 16px; } } .demo-typography-text { display: inline-block; } .demo-elevation { height: 40px; width: 300px; margin: 32px; display: flex; align-items: center; justify-content: center; background: var(--mat-sys-surface-container); color: var(--mat-sys-on-surface); border-radius: var(--mat-sys-corner-extra-small); } .demo-code-block { background: var(--mat-sys-surface-container-low); padding: 16px; border-radius: var(--mat-sys-corner-small); border: 1px solid var(--mat-sys-outline); } .demo-overrides { background-color: var(--mat-sys-primary); color: var(--mat-sys-on-primary); font: var(--mat-sys-body-medium); border-radius: var(--mat-sys-corner-large); box-shadow: var(--mat-sys-level3); padding: 16px; @include mat.theme-overrides(( primary: #ebdcff, on-primary: #230f46, body-medium: 600 1.5rem / 2.25rem Arial, corner-large: 32px, level3: 0 4px 6px 1px var(--mat-sys-surface-dim), )); }
{ "end_byte": 4308, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/theme/theme-demo.scss" }
components/src/dev-app/theme/theme-demo.html_0_7784
<p class="demo-warn"> This page uses an experimental prototype version of a <span class="demo-surface-variable">material.theme</span> API. To enable it, click the <mat-icon>public</mat-icon> icon in the header. </p> <p> Angular Material components depend on CSS variables defined by the <span class="demo-surface-variable">material.theme</span> Sass mixin. This page provides guidance and documentation for using these variables to customize components. </p> <h1>Colors</h1> <p> Material Design uses color to create accessible, personal color schemes that communicate your product's hierarchy, state, and brand. See Material Design's <a href="https://m3.material.io/styles/color/system/overview">Color System</a> page to learn more about its use and purpose. </p> <p> The following colors are the most often used in Angular Material components. Use these colors and follow their uses to add theme colors to your application's custom components. </p> <p> Note that variables starting with "--mat-sys-on-*" are designed to be used for text or icons placed on top of its paired parent color. For example, <span class="demo-surface-variable">--mat-sys-on-primary</span> is used for text and icons in elements filled with the <span class="demo-surface-variable">--mat-sys-primary</span> color. </p> <div class="demo-group"> <div class="demo-color-container"> <div class="demo-heading" [style.background-color]="'var(--mat-sys-primary)'" [style.color]="'var(--mat-sys-on-primary)'"> <div class="demo-name"> Primary</div> <div class="demo-variable demo-code"> --mat-sys-primary</div> </div> <div class="demo-description"> <p> The most common color used by Angular Material components to participate in the application theme. </p> <p> Examples include the background color of filled buttons, the icon color of selected radio buttons, and the outline color of form fields. </p> <p> Use the color <span class="demo-surface-variable">--mat-sys-on-primary</span> for icons, text, and other visual elements placed on a primary background. This color is calculated to be optimal for accessibility and legibility. </p> </div> </div> <div class="demo-color-container"> <div class="demo-heading" [style.background-color]="'var(--mat-sys-surface)'" [style.color]="'var(--mat-sys-on-surface)'"> <div class="demo-name"> Surface</div> <div class="demo-variable code"> --mat-sys-surface</div> </div> <div class="demo-description"> <p> A low-emphasis background color that provides a clear contrast for both light and dark themes and their varied theme colors. </p> <p> Examples include the background color of the application and most components such as the dialog, card, table, and more. </p> <p> Use the color <span class="demo-surface-variable">--mat-sys-on-surface</span> for icons, text, and other visual elements placed on a surface background. This color is calculated to be optimal for accessibility and legibility. </p> </div> </div> <div class="demo-color-container"> <div class="demo-heading" [style.background-color]="'var(--mat-sys-error)'" [style.color]="'var(--mat-sys-on-error)'"> <div class="demo-name"> Error</div> <div class="demo-variable demo-code"> --mat-sys-error</div> </div> <div class="demo-description"> <p> High-contrast color meant to alert the user to attract immediate attention. </p> <p> Examples include the background color of the badge and the text color of invalid form fields inputs. </p> <p> Use the color <span class="demo-surface-variable">--mat-sys-on-error</span> for icons, text, and other visual elements placed on an error background. This color is calculated to be optimal for accessibility and legibility. </p> </div> </div> <div class="demo-color-container"> <div class="demo-heading" [style.background-color]="'var(--mat-sys-outline)'" [style.color]="'var(--mat-sys-surface)'"> <div class="demo-name"> Outline</div> <div class="demo-variable demo-code"> --mat-sys-outline </div> </div> <div class="demo-description"> <p> Used for borders and dividers to help provide visual separation between and around elements. </p> <p> Examples include the color of the divider and border color of an outlined form field. </p> <p> Use the color <span class="demo-surface-variable">--mat-sys-outline-variant</span> for a less prominent outline. </p> </div> </div> </div> <mat-expansion-panel> <mat-expansion-panel-header>Other available colors</mat-expansion-panel-header> <p> These colors are less commonly used in Angular Material components but are available for adding color variety and creating additional emphasis to components. </p> <p> Colors may be paired with a <span class="demo-surface-variable">--mat-sys-on-</span> variable that should be used for text and icons placed within a filled container. </p> <h2>Alternative Theme Colors</h2> <theme-demo-colors [colors]="alternativeThemeColors"></theme-demo-colors> <h2>Surface Colors</h2> <p> The following colors should be used for backgrounds and large, low-emphasis areas of the screen. </p> <p> Containers filled with a surface color should apply the <span class="demo-surface-variable">--mat-sys-on-surface</span> color to text and icons placed within. </p> <theme-demo-colors [colors]="surfaceColors"></theme-demo-colors> <h2>Fixed Colors</h2> <p> These colors are the same for both light and dark themes. They are unused by any Angular Material components. </p> <theme-demo-colors [colors]="fixedColors"></theme-demo-colors> </mat-expansion-panel> <h1>Typography</h1> <p> There are five categories of font types defined by Material Design: body, display, headline, label, and title. Each category has three sizes: small, medium, and large. </p> <p> Learn more about how these categories and their sizes should be used in your application by visiting Material Design's <a href="https://m3.material.io/styles/typography/overview">Typography</a> documentation. </p> @for (category of ['body', 'display', 'headline', 'label', 'title']; track $index) { <div class="demo-typography-group"> <div class="demo-typography-title">{{category}}</div> @for (size of ['small', 'medium', 'large']; track $index) { <div class="demo-typography-example"> <div class="demo-typography-variable"> <div class="demo-surface-variable">--mat-sys-{{category}}-{{size}}</div> </div> <div class="demo-typography-text" [style.font]="'var(--mat-sys-' + category + '-' + size + ')'">Lorem ipsum dolor</div> </div> } </div> } <p> Each variable can be applied to the `font` CSS style. Additionally, the parts of the variable definition can be accessed individually by appending the keywords "font", "line-height", "size", "tracking", and "weight". </p> <p> For example, the values for medium body text may be defined as follows: </p> <pre class="demo-code-block"> --mat-sys-body-medium: 400 0.875rem / 1.25rem Roboto, sans-serif; --mat-sys-body-medium-font: Roboto, sans-serif; --mat-sys-body-medium-line-height: 1.25rem; --mat-sys-body-medium-size: 0.875rem; --mat-sys-body-medium-tracking: 0.016rem; --mat-sys-body-medium-weight: 400; </pre> <h1>Elevation</h1>
{ "end_byte": 7784, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/theme/theme-demo.html" }
components/src/dev-app/theme/theme-demo.html_7786_8586
<p> Material Design provides six levels of elevation that can be used to provide a sense of depth and organization to an application's UI. Learn more at Material Design's <a href="https://m3.material.io/styles/elevation/overview">Elevation</a> guide. </p> <p> These levels are defined as CSS box-shadow values that can be styled to an element. </p> @for (level of [0, 1, 2, 3, 4, 5]; track $index) { <div class="demo-elevation code" [style.box-shadow]="'var(--mat-sys-level' + level + ')'"> box-shadow: var(--mat-sys-level{{level}}) </div> } <h1>Overrides</h1> <div class="demo-overrides"> This container has several system variables applied and includes the <span class="demo-surface-variable">mat.theme-overrides</span> mixin to change their values from the existing theme. </div>
{ "end_byte": 8586, "start_byte": 7786, "url": "https://github.com/angular/components/blob/main/src/dev-app/theme/theme-demo.html" }
components/src/dev-app/theme/BUILD.bazel_0_566
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "theme", srcs = glob(["**/*.ts"]), assets = [ "theme-demo.html", ":theme_demo_scss", ], deps = [ "//src/dev-app/dev-app", "//src/material/card", "//src/material/expansion", "//src/material/icon", "@npm//@angular/forms", ], ) sass_binary( name = "theme_demo_scss", src = "theme-demo.scss", deps = [ "//src/material:sass_lib", ], )
{ "end_byte": 566, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/theme/BUILD.bazel" }
components/src/dev-app/theme/theme-demo.ts_0_4493
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, Component, input} from '@angular/core'; import {MatCardModule} from '@angular/material/card'; import {MatExpansionModule} from '@angular/material/expansion'; import {MatIconModule} from '@angular/material/icon'; import {getAppState} from '../dev-app/dev-app-state'; interface Color { name: string; background: string; text: string; hideText?: boolean; } @Component({ selector: 'theme-demo-colors', template: ` <div class="demo-compact-color-container"> @for (color of colors(); track $index) { <div class="demo-heading" [style.background-color]="'var(' + color.background + ')'" [style.color]="'var(' + color.text + ')'"> <div class="demo-name"> {{color.name}} </div> <div class="demo-variables"> <div class="demo-variable demo-code">{{color.background}}</div> @if (!color.hideText) { <div class="demo-variable demo-code">{{color.text}}</div> } </div> </div> } </div> `, styleUrl: 'theme-demo.css', changeDetection: ChangeDetectionStrategy.OnPush, }) export class ThemeDemoColors { colors = input<Color[]>(); } @Component({ selector: 'theme-demo', templateUrl: 'theme-demo.html', styleUrl: 'theme-demo.css', imports: [MatCardModule, MatExpansionModule, MatIconModule, ThemeDemoColors], changeDetection: ChangeDetectionStrategy.OnPush, }) export class ThemeDemo { state = getAppState(); alternativeThemeColors: Color[] = [ { name: 'Primary Container', background: '--mat-sys-primary-container', text: '--mat-sys-on-primary-container', }, { name: 'Secondary', background: '--mat-sys-secondary', text: '--mat-sys-on-secondary', }, { name: 'Secondary Container', background: '--mat-sys-secondary-container', text: '--mat-sys-on-secondary-container', }, { name: 'Tertiary', background: '--mat-sys-tertiary', text: '--mat-sys-on-tertiary', }, { name: 'Tertiary Container', background: '--mat-sys-tertiary-container', text: '--mat-sys-on-tertiary-container', }, { name: 'Error Container', background: '--mat-sys-error-container', text: '--mat-sys-on-error-container', }, ]; surfaceColors: Color[] = [ { name: 'Surface Dim', background: '--mat-sys-surface-dim', text: '--mat-sys-on-surface', hideText: true, }, { name: 'Surface Bright', background: '--mat-sys-surface-bright', text: '--mat-sys-on-surface', hideText: true, }, { name: 'Surface Container Lowest', background: '--mat-sys-surface-container-lowest', text: '--mat-sys-on-surface', hideText: true, }, { name: 'Surface Container Low', background: '--mat-sys-surface-container-low', text: '--mat-sys-on-surface', hideText: true, }, { name: 'Surface Container', background: '--mat-sys-surface-container', text: '--mat-sys-on-surface', hideText: true, }, { name: 'Surface Container High', background: '--mat-sys-surface-container-high', text: '--mat-sys-on-surface', hideText: true, }, { name: 'Surface Container Highest', background: '--mat-sys-surface-container-highest', text: '--mat-sys-on-surface', hideText: true, }, ]; fixedColors: Color[] = [ { name: 'Primary Fixed', background: '--mat-sys-primary-fixed', text: '--mat-sys-on-primary-fixed', }, { name: 'Primary Fixed Dim', background: '--mat-sys-primary-fixed-dim', text: '--mat-sys-on-primary-fixed', }, { name: 'Secondary Fixed', background: '--mat-sys-secondary-fixed', text: '--mat-sys-on-secondary-fixed', }, { name: 'Secondary Fixed Dim', background: '--mat-sys-secondary-fixed-dim', text: '--mat-sys-on-secondary-fixed', }, { name: 'Tertiary Fixed', background: '--mat-sys-tertiary-fixed', text: '--mat-sys-on-tertiary-fixed', }, { name: 'Tertiary Fixed Dim', background: '--mat-sys-tertiary-fixed-dim', text: '--mat-sys-on-tertiary-fixed', }, ]; }
{ "end_byte": 4493, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/theme/theme-demo.ts" }
components/src/dev-app/table/table-demo.ts_0_2187
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { CdkTableBasicExample, CdkTableFixedLayoutExample, CdkTableFlexBasicExample, CdkTableRecycleRowsExample, } from '@angular/components-examples/cdk/table'; import { TableBasicExample, TableDynamicColumnsExample, TableExpandableRowsExample, TableFilteringExample, TableFlexBasicExample, TableFlexLargeRowExample, TableFooterRowExample, TableHttpExample, TableMultipleHeaderFooterExample, TableMultipleRowTemplateExample, TableOverviewExample, TablePaginationExample, TableRecycleRowsExample, TableReorderableExample, TableRowContextExample, TableSelectionExample, TableSortingExample, TableStickyColumnsExample, TableStickyComplexExample, TableStickyComplexFlexExample, TableStickyFooterExample, TableStickyHeaderExample, TableTextColumnAdvancedExample, TableTextColumnExample, TableWrappedExample, } from '@angular/components-examples/material/table'; import {ChangeDetectionStrategy, Component} from '@angular/core'; @Component({ templateUrl: './table-demo.html', imports: [ CdkTableFlexBasicExample, CdkTableBasicExample, CdkTableFixedLayoutExample, CdkTableRecycleRowsExample, TableFlexBasicExample, TableBasicExample, TableDynamicColumnsExample, TableExpandableRowsExample, TableFilteringExample, TableFooterRowExample, TableHttpExample, TableMultipleHeaderFooterExample, TableMultipleRowTemplateExample, TableOverviewExample, TablePaginationExample, TableRowContextExample, TableSelectionExample, TableSortingExample, TableStickyColumnsExample, TableStickyComplexFlexExample, TableStickyComplexExample, TableStickyFooterExample, TableStickyHeaderExample, TableTextColumnAdvancedExample, TableTextColumnExample, TableWrappedExample, TableReorderableExample, TableRecycleRowsExample, TableFlexLargeRowExample, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class TableDemo {}
{ "end_byte": 2187, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/table/table-demo.ts" }
components/src/dev-app/table/table-demo.html_0_2762
<h3>Cdk table basic</h3> <cdk-table-basic-example></cdk-table-basic-example> <h3>Cdk table with recycled rows</h3> <cdk-table-recycle-rows-example></cdk-table-recycle-rows-example> <h3>Cdk table basic with fixed column widths</h3> <cdk-table-fixed-layout-example></cdk-table-fixed-layout-example> <h3>Cdk table basic flex</h3> <cdk-table-flex-basic-example></cdk-table-flex-basic-example> <h3>Table basic</h3> <table-basic-example></table-basic-example> <h3>Table basic with recycled rows</h3> <table-recycle-rows-example></table-recycle-rows-example> <h3>Table basic flex</h3> <table-flex-basic-example></table-flex-basic-example> <h3>Table flex with large row</h3> <table-flex-large-row-example></table-flex-large-row-example> <h3>Table dynamic columns</h3> <table-dynamic-columns-example></table-dynamic-columns-example> <h3>Table expandable rows</h3> <table-expandable-rows-example></table-expandable-rows-example> <h3>Table filtering</h3> <table-filtering-example></table-filtering-example> <h3>Table footer row</h3> <table-footer-row-example></table-footer-row-example> <h3>Table with http</h3> <table-http-example></table-http-example> <h3>Table with multiple headers and footers</h3> <table-multiple-header-footer-example></table-multiple-header-footer-example> <h3>Table overview</h3> <table-overview-example></table-overview-example> <h3>Table row context</h3> <table-row-context-example></table-row-context-example> <h3>Table with pagination</h3> <table-pagination-example></table-pagination-example> <h3>Table with selection</h3> <table-selection-example></table-selection-example> <h3>Table with sorting</h3> <table-sorting-example></table-sorting-example> <h3>Table with sticky columns</h3> <table-sticky-columns-example></table-sticky-columns-example> <h3>Table with sticky headers, footers and columns</h3> <table-sticky-complex-example></table-sticky-complex-example> <h3>Table flex with sticky headers, footers and columns</h3> <table-sticky-complex-flex-example></table-sticky-complex-flex-example> <h3>Table with sticky footer</h3> <table-sticky-footer-example></table-sticky-footer-example> <h3>Table with sticky header</h3> <table-sticky-header-example></table-sticky-header-example> <h3>Table with multiple rows per data item</h3> <table-multiple-row-template-example></table-multiple-row-template-example> <h3>Table with mat-text-column</h3> <table-text-column-example></table-text-column-example> <h3>Table with mat-text-column advanced</h3> <table-text-column-advanced-example></table-text-column-advanced-example> <h3>Table wrapped in reusable component</h3> <table-wrapped-example></table-wrapped-example> <h3>Table wrapped re-orderable columns</h3> <table-reorderable-example></table-reorderable-example>
{ "end_byte": 2762, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/table/table-demo.html" }
components/src/dev-app/table/BUILD.bazel_0_347
load("//tools:defaults.bzl", "ng_module") package(default_visibility = ["//visibility:public"]) ng_module( name = "table", srcs = glob(["**/*.ts"]), assets = ["table-demo.html"], deps = [ "//src/components-examples/cdk/table", "//src/components-examples/material/table", "//src/dev-app/example", ], )
{ "end_byte": 347, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/table/BUILD.bazel" }
components/src/dev-app/list/list-demo.html_1_7671
<h1>mat-list demo</h1> <button mat-raised-button (click)="thirdLine = !thirdLine">Show third line</button> <button mat-raised-button (click)="showBoxes = !showBoxes">Show item boxes</button> <div class="demo-list" [class.demo-show-boxes]="showBoxes"> <div> <h2>Normal lists</h2> <mat-list> <div mat-subheader>Items</div> @for (item of items; track item) { <mat-list-item>{{item}}</mat-list-item> } </mat-list> <mat-list> @for (contact of contacts; track contact) { <mat-list-item> <div matListItemTitle>{{contact.name}}</div> @if (thirdLine) { <div matListItemLine>extra line</div> } <div matListItemLine>{{contact.headline}}</div> </mat-list-item> } </mat-list> <mat-list> <div mat-subheader>Today</div> @for (message of messages; track message) { <mat-list-item> <img matListItemAvatar [src]="message.image" alt="Image of {{message.from}}"> <div matListItemTitle>{{message.from}}</div> <div matListItemLine> <span>{{message.subject}} -- </span> <span>{{message.message}}</span> </div> @if (!$last) { <mat-divider inset></mat-divider> } </mat-list-item> } <mat-divider></mat-divider> @for (message of messages; track message) { <mat-list-item> <div matListItemTitle>{{message.from}}</div> <div matListItemLine>{{message.subject}}</div> <div matListItemLine>{{message.message}}</div> </mat-list-item> } </mat-list> <mat-list> @for (link of links; track link) { <mat-list-item> <span matListItemTitle>{{ link.name }}</span> <button matListItemMeta mat-icon-button (click)="infoClicked=!infoClicked"> <mat-icon>info</mat-icon> </button> </mat-list-item> } </mat-list> </div> <div> <h2>Dense lists</h2> <mat-list dense> <div mat-subheader>Items</div> @for (item of items; track item) { <mat-list-item>{{item}}</mat-list-item> } </mat-list> <mat-list dense> @for (contact of contacts; track contact) { <mat-list-item> <div matListItemTitle>{{contact.name}}</div> <div matListItemLine>{{contact.headline}}</div> </mat-list-item> } </mat-list> <mat-list dense> <div mat-subheader>Today</div> @for (message of messages; track message) { <mat-list-item> <img matListItemAvatar [src]="message.image" alt="Image of {{message.from}}"> <div matListItemTitle>{{message.from}}</div> <div matListItemLine>{{message.subject}}</div> <div matListItemLine>{{message.message}}</div> </mat-list-item> } </mat-list> <mat-list dense> @for (link of links; track link) { <mat-list-item> <span matListItemTitle>{{ link.name }}</span> <button matListItemMeta mat-icon-button (click)="infoClicked=!infoClicked"> <mat-icon class="material-icons">info</mat-icon> </button> </mat-list-item> } </mat-list> </div> <div> <h2>Nav lists</h2> <mat-nav-list> @for (link of links; track link) { <a mat-list-item [href]="link.href" [activated]="isActivated(link)"> {{ link.name }} </a> } </mat-nav-list> @if (infoClicked) { <div>More info!</div> } <mat-nav-list> @for (link of links; track link; let last = $last) { <a mat-list-item [href]="link.href" [activated]="isActivated(link)"> <mat-icon matListItemIcon>folder</mat-icon> <span matListItemTitle>{{ link.name }}</span> </a> } </mat-nav-list> </div> <div> <h2>Action list</h2> <mat-action-list> @for (link of links; track link) { <button mat-list-item (click)="alertItem(link.name)">{{link.name}}</button> } </mat-action-list> </div> <div> <h2>Selection list</h2> <mat-selection-list #groceries [ngModel]="selectedOptions" (ngModelChange)="onSelectedOptionsChange($event)" (selectionChange)="changeEventCount = changeEventCount + 1" [disabled]="selectionListDisabled" [disableRipple]="selectionListRippleDisabled" [hideSingleSelectionIndicator]="selectionListSingleSelectionIndicatorHidden" color="primary"> <div mat-subheader>Groceries</div> <mat-list-option value="bananas" togglePosition="before">Bananas</mat-list-option> <mat-list-option selected value="oranges" color="accent">Oranges</mat-list-option> <mat-list-option value="apples" color="warn">Apples</mat-list-option> <mat-list-option value="strawberries" disabled>Strawberries</mat-list-option> </mat-selection-list> <mat-selection-list [disableRipple]="selectionListRippleDisabled"> <div mat-subheader>Dogs</div> <mat-list-option togglePosition="before"> <img matListItemAvatar src="https://material.angular.io/assets/img/examples/shiba1.jpg"> <span matListItemTitle>Shiba Inu</span> </mat-list-option> <mat-list-option togglePosition="after"> <img matListItemAvatar src="https://material.angular.io/assets/img/examples/shiba2.jpg"> <span matListItemTitle>Other Shiba Inu</span> </mat-list-option> </mat-selection-list> <p>Selected: {{selectedOptions | json}}</p> <p>Change Event Count {{changeEventCount}}</p> <p>Model Change Event Count {{modelChangeEventCount}}</p> <p> <label> Disable selection list <input type="checkbox" [(ngModel)]="selectionListDisabled"> </label> </p> <p> <label> Disable Selection List ripples <input type="checkbox" [(ngModel)]="selectionListRippleDisabled"> </label> </p> <p> <label> Hide Single-Selection indicators <input type="checkbox" [(ngModel)]="selectionListSingleSelectionIndicatorHidden"> </label> </p> <p> <button mat-raised-button (click)="groceries.selectAll()">Select all</button> <button mat-raised-button (click)="groceries.deselectAll()">Deselect all</button> </p> </div> <div> <h2>Single Selection list</h2> <mat-selection-list #favorite [(ngModel)]="favoriteOptions" [multiple]="false" [hideSingleSelectionIndicator]="selectionListSingleSelectionIndicatorHidden" color="primary"> <div mat-subheader>Favorite Grocery</div> <mat-list-option value="bananas">Bananas</mat-list-option> <mat-list-option selected value="oranges" color="accent">Oranges</mat-list-option> <mat-list-option value="apples" color="warn">Apples</mat-list-option> <mat-list-option value="strawberries" disabled>Strawberries</mat-list-option> </mat-selection-list> <p>Selected: {{favoriteOptions | json}}</p> <h4>Single Selection List with Reactive Forms</h4> <form [formGroup]="form"> <mat-selection-list #shoesList [formControl]="shoesControl" name="shoes" [multiple]="false"> @for (shoe of shoes; track shoe) { <mat-list-option [value]="shoe.value">{{shoe.name}}</mat-list-option> } </mat-selection-list> <p> Option selected: {{shoesControl.value ? shoesControl.value[0] : 'None'}} </p> </form> </div>
{ "end_byte": 7671, "start_byte": 1, "url": "https://github.com/angular/components/blob/main/src/dev-app/list/list-demo.html" }
components/src/dev-app/list/list-demo.html_7675_11557
<div> <h2>Line scenarios</h2> <mat-list> <mat-list-item>Title</mat-list-item> <mat-list-item lines="2"> <span matListItemTitle>Title</span> <span>This is unscoped text content that is supposed to not wrap. The list has only acquired two lines and therefore there is no space for wrapping.</span> </mat-list-item> <mat-list-item lines="3"> <span matListItemTitle>Title</span> <span>This is unscoped text content that is supposed to wrap to the third line. The list item acquire spaces for three lines and text should have an ellipsis in the third line upon text overflow.</span> </mat-list-item> <mat-list-item> <span matListItemTitle>Title</span> <span>This is unscoped text content that is supposed to not wrap. The list has only acquired two lines (automatically) and therefore there is no space for wrapping.</span> </mat-list-item> <mat-list-item> <span matListItemTitle>Title</span> <span matListItemLine>Secondary line</span> <span matListItemLine>Tertiary line</span> </mat-list-item> </mat-list> <mat-selection-list> <mat-list-option>Title</mat-list-option> <mat-list-option lines="2"> <span matListItemTitle>Title</span> <span>This is unscoped text content that is supposed to not wrap. The list has only acquired two lines and therefore there is no space for wrapping.</span> </mat-list-option> <mat-list-option lines="3"> <span matListItemTitle>Title</span> <span>This is unscoped text content that is supposed to wrap to the third line. The list item acquire spaces for three lines and text should have an ellipsis in the third line upon text overflow.</span> </mat-list-option> <mat-list-option> <span matListItemTitle>Title</span> <span>This is unscoped text content that is supposed to not wrap. The list has only acquired two lines (automatically) and therefore there is no space for wrapping.</span> </mat-list-option> <mat-list-option> <span matListItemTitle>Title</span> <span matListItemLine>Secondary line</span> <span matListItemLine>Tertiary line</span> </mat-list-option> </mat-selection-list> <button mat-raised-button (click)="showBoxes = !showBoxes">Show item boxes</button> </div> <div> <h2>Line alignment</h2> <mat-list> @for (link of links; track link) { <mat-list-item> <span matListItemTitle>{{ link.name }}</span> <span>Unscoped content</span> </mat-list-item> } </mat-list> <mat-selection-list> <mat-list-option value="first">First</mat-list-option> <mat-list-option value="second"> <span matListItemTitle>Second</span> <span>Unscoped content</span> </mat-list-option> </mat-selection-list> </div> <div> <h2>Icon alignment in selection list</h2> <mat-selection-list> <mat-list-option value="bananas" [togglePosition]="togglePosition"> <mat-icon matListItemIcon>info</mat-icon> Bananas </mat-list-option> <mat-list-option value="oranges" [togglePosition]="togglePosition"> <mat-icon matListItemIcon #ok>info</mat-icon> Oranges </mat-list-option> <mat-list-option value="cake" [togglePosition]="togglePosition"> <mat-icon matListItemIcon>info</mat-icon> Cake </mat-list-option> <mat-list-option value="fries" [togglePosition]="togglePosition"> <mat-icon matListItemIcon>info</mat-icon> Fries </mat-list-option> </mat-selection-list> <button mat-raised-button (click)="toggleCheckboxPosition()"> Toggle checkbox position </button> </div> </div>
{ "end_byte": 11557, "start_byte": 7675, "url": "https://github.com/angular/components/blob/main/src/dev-app/list/list-demo.html" }
components/src/dev-app/list/list-demo.scss_0_340
.demo-list { display: flex; flex-flow: row wrap; .mat-mdc-list-base { border: 1px solid var(--mat-divider-color); width: 350px; margin: 20px 20px 0 0; } h2 { margin-top: 20px; } &.demo-show-boxes .mat-mdc-list-item { border: 1px solid grey; } } .demo-secondary-text { color: rgba(0, 0, 0, 0.54); }
{ "end_byte": 340, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/list/list-demo.scss" }
components/src/dev-app/list/BUILD.bazel_0_471
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "list", srcs = glob(["**/*.ts"]), assets = [ "list-demo.html", ":list_demo_scss", ], deps = [ "//src/material/button", "//src/material/icon", "//src/material/list", "@npm//@angular/router", ], ) sass_binary( name = "list_demo_scss", src = "list-demo.scss", )
{ "end_byte": 471, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/list/BUILD.bazel" }
components/src/dev-app/list/list-demo.ts_0_3578
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, ChangeDetectorRef, Component, inject} from '@angular/core'; import {JsonPipe} from '@angular/common'; import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {MatButtonModule} from '@angular/material/button'; import {MatIconModule} from '@angular/material/icon'; import {MatListModule, MatListOptionTogglePosition} from '@angular/material/list'; import {ActivatedRoute} from '@angular/router'; interface Link { name: string; href: string; } interface Shoes { value: string; name: string; } @Component({ selector: 'list-demo', templateUrl: 'list-demo.html', styleUrl: 'list-demo.css', imports: [ JsonPipe, FormsModule, MatButtonModule, MatIconModule, MatListModule, ReactiveFormsModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class ListDemo { items: string[] = ['Pepper', 'Salt', 'Paprika']; form: FormGroup; shoes: Shoes[] = [ {value: 'boots', name: 'Boots'}, {value: 'clogs', name: 'Clogs'}, {value: 'loafers', name: 'Loafers'}, {value: 'moccasins', name: 'Moccasins'}, {value: 'sneakers', name: 'Sneakers'}, ]; shoesControl = new FormControl(); togglePosition: MatListOptionTogglePosition = 'before'; contacts: {name: string; headline: string}[] = [ {name: 'Nancy', headline: 'Software engineer'}, {name: 'Mary', headline: 'TPM'}, {name: 'Bobby', headline: 'UX designer'}, ]; messages: {from: string; subject: string; message: string; image: string}[] = [ { from: 'John', subject: 'Brunch?', message: 'Did you want to go on Sunday? I was thinking that might work.', image: 'https://angular.io/generated/images/bios/devversion.jpg', }, { from: 'Mary', subject: 'Summer BBQ', message: 'Wish I could come, but I have some prior obligations.', image: 'https://angular.io/generated/images/bios/twerske.jpg', }, { from: 'Bobby', subject: 'Oui oui', message: 'Do you have Paris reservations for the 15th? I just booked!', image: 'https://angular.io/generated/images/bios/jelbourn.jpg', }, ]; links: Link[] = [ {name: 'Inbox', href: '/list#inbox'}, {name: 'Outbox', href: '/list#outbox'}, {name: 'Spam', href: '/list#spam'}, {name: 'Trash', href: '/list#trash'}, ]; thirdLine = false; showBoxes = false; infoClicked = false; selectionListDisabled = false; selectionListRippleDisabled = false; selectionListSingleSelectionIndicatorHidden = false; selectedOptions: string[] = ['apples']; changeEventCount = 0; modelChangeEventCount = 0; readonly cdr = inject(ChangeDetectorRef); readonly activatedRoute = inject(ActivatedRoute); constructor() { this.activatedRoute.url.subscribe(() => { this.cdr.markForCheck(); }); this.form = new FormGroup({ shoes: this.shoesControl, }); } onSelectedOptionsChange(values: string[]) { this.selectedOptions = values; this.modelChangeEventCount++; } toggleCheckboxPosition() { this.togglePosition = this.togglePosition === 'before' ? 'after' : 'before'; } favoriteOptions: string[] = []; alertItem(msg: string) { alert(msg); } isActivated(link: Link) { return `${window.location.pathname}${window.location.hash}` === link.href; } }
{ "end_byte": 3578, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/list/list-demo.ts" }
components/src/dev-app/menu/menu-demo.ts_0_1214
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; import {MatDividerModule} from '@angular/material/divider'; import {MatIconModule} from '@angular/material/icon'; import {MatMenuModule} from '@angular/material/menu'; import {MatToolbarModule} from '@angular/material/toolbar'; @Component({ selector: 'menu-demo', templateUrl: 'menu-demo.html', styleUrl: 'menu-demo.css', imports: [MatMenuModule, MatButtonModule, MatToolbarModule, MatIconModule, MatDividerModule], changeDetection: ChangeDetectionStrategy.OnPush, }) export class MenuDemo { selected = ''; items = [ {text: 'Refresh'}, {text: 'Settings'}, {text: 'Help', disabled: true}, {text: 'Sign Out'}, ]; iconItems = [ {text: 'Redial', icon: 'dialpad'}, {text: 'Check voicemail', icon: 'voicemail', disabled: true}, {text: 'Disable alerts', icon: 'notifications_off'}, ]; select(text: string) { this.selected = text; } }
{ "end_byte": 1214, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/menu/menu-demo.ts" }
components/src/dev-app/menu/BUILD.bazel_0_506
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "menu", srcs = glob(["**/*.ts"]), assets = [ "menu-demo.html", ":menu_demo_scss", ], deps = [ "//src/material/button", "//src/material/divider", "//src/material/icon", "//src/material/menu", "//src/material/toolbar", ], ) sass_binary( name = "menu_demo_scss", src = "menu-demo.scss", )
{ "end_byte": 506, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/menu/BUILD.bazel" }
components/src/dev-app/menu/menu-demo.scss_0_174
.demo-menu { display: flex; flex-flow: row wrap; .demo-menu-section { width: 300px; margin: 20px; } .demo-end-icon { justify-content: flex-end; } }
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/menu/menu-demo.scss" }
components/src/dev-app/menu/menu-demo.html_0_6264
<div class="demo-menu"> <div class="demo-menu-section"> <p>You clicked on: {{ selected }}</p> <mat-toolbar> <button mat-icon-button [matMenuTriggerFor]="menu" aria-label="Open basic menu"> <mat-icon>more_vert</mat-icon> </button> </mat-toolbar> <mat-menu #menu="matMenu"> @for (item of items; track item) { <button mat-menu-item (click)="select(item.text)" [disabled]="item.disabled"> {{ item.text }} </button> } </mat-menu> </div> <div class="demo-menu-section"> <p>Menu with divider</p> <mat-toolbar> <button mat-icon-button [matMenuTriggerFor]="divider" aria-label="Open basic menu"> <mat-icon>more_vert</mat-icon> </button> </mat-toolbar> <mat-menu #divider="matMenu"> @for (item of items; track item) { <button mat-menu-item [disabled]="item.disabled">{{ item.text }}</button> @if (!$last) { <mat-divider></mat-divider> } } </mat-menu> </div> <div class="demo-menu-section"> <p>Nested menu</p> <mat-toolbar> <button mat-icon-button [matMenuTriggerFor]="animals"> <mat-icon>more_vert</mat-icon> </button> </mat-toolbar> <mat-menu #animals="matMenu"> <button mat-menu-item [matMenuTriggerFor]="vertebrates">Vertebrates</button> <button mat-menu-item [matMenuTriggerFor]="invertebrates">Invertebrates</button> </mat-menu> <mat-menu #vertebrates="matMenu"> <button mat-menu-item [matMenuTriggerFor]="fish">Fishes</button> <button mat-menu-item [matMenuTriggerFor]="amphibians">Amphibians</button> <button mat-menu-item [matMenuTriggerFor]="reptiles">Reptiles</button> <button mat-menu-item>Birds</button> <button mat-menu-item>Mammals</button> </mat-menu> <mat-menu #invertebrates="matMenu"> <button mat-menu-item>Insects</button> <button mat-menu-item>Molluscs</button> <button mat-menu-item>Crustaceans</button> <button mat-menu-item>Corals</button> <button mat-menu-item>Arachnids</button> <button mat-menu-item>Velvet worms</button> <button mat-menu-item>Horseshoe crabs</button> </mat-menu> <mat-menu #fish="matMenu"> <button mat-menu-item>Baikal oilfish</button> <button mat-menu-item>Bala shark</button> <button mat-menu-item>Ballan wrasse</button> <button mat-menu-item>Bamboo shark</button> <button mat-menu-item>Banded killifish</button> </mat-menu> <mat-menu #amphibians="matMenu"> <button mat-menu-item>Sonoran desert toad</button> <button mat-menu-item>Western toad</button> <button mat-menu-item>Arroyo toad</button> <button mat-menu-item>Yosemite toad</button> </mat-menu> <mat-menu #reptiles="matMenu"> <button mat-menu-item>Banded Day Gecko</button> <button mat-menu-item>Banded Gila Monster</button> <button mat-menu-item>Black Tree Monitor</button> <button mat-menu-item>Blue Spiny Lizard</button> </mat-menu> </div> <div class="demo-menu-section"> <p>Clicking these will navigate:</p> <mat-toolbar> <button mat-icon-button [matMenuTriggerFor]="anchorMenu" aria-label="Open anchor menu"> <mat-icon>more_vert</mat-icon> </button> </mat-toolbar> <mat-menu #anchorMenu="matMenu"> @for (item of items; track item) { <a mat-menu-item href="https://www.google.com" [disabled]="item.disabled"> {{ item.text }} </a> } </mat-menu> </div> <div class="demo-menu-section"> <p> Position x: before </p> <mat-toolbar class="demo-end-icon"> <button mat-icon-button [matMenuTriggerFor]="posXMenu" aria-label="Open x-positioned menu"> <mat-icon>more_vert</mat-icon> </button> </mat-toolbar> <mat-menu xPosition="before" #posXMenu="matMenu"> @for (item of iconItems; track item) { <button mat-menu-item [disabled]="item.disabled"> <mat-icon>{{ item.icon }}</mat-icon> {{ item.text }} </button> } </mat-menu> </div> <div class="demo-menu-section"> <p> Position y: above </p> <mat-toolbar> <button mat-icon-button [matMenuTriggerFor]="posYMenu" aria-label="Open y-positioned menu"> <mat-icon>more_vert</mat-icon> </button> </mat-toolbar> <mat-menu yPosition="above" #posYMenu="matMenu"> @for (item of items; track item) { <button mat-menu-item [disabled]="item.disabled">{{ item.text }}</button> } </mat-menu> </div> </div> <div class="demo-menu"> <div class="demo-menu-section"> <p>overlapTrigger: true</p> <mat-toolbar> <button mat-icon-button [mat-menu-trigger-for]="menuOverlay"> <mat-icon>more_vert</mat-icon> </button> </mat-toolbar> <mat-menu [overlapTrigger]="true" #menuOverlay="matMenu"> @for (item of items; track item) { <button mat-menu-item [disabled]="item.disabled">{{ item.text }}</button> } </mat-menu> </div> <div class="demo-menu-section"> <p> Position x: before, overlapTrigger: true </p> <mat-toolbar class="demo-end-icon"> <button mat-icon-button [mat-menu-trigger-for]="posXMenuOverlay"> <mat-icon>more_vert</mat-icon> </button> </mat-toolbar> <mat-menu xPosition="before" [overlapTrigger]="true" #posXMenuOverlay="matMenu"> @for (item of iconItems; track item) { <button mat-menu-item [disabled]="item.disabled"> <mat-icon>{{ item.icon }}</mat-icon> {{ item.text }} </button> } </mat-menu> </div> <div class="demo-menu-section"> <p> Position y: above, overlapTrigger: true </p> <mat-toolbar> <button mat-icon-button [mat-menu-trigger-for]="posYMenuOverlay"> <mat-icon>more_vert</mat-icon> </button> </mat-toolbar> <mat-menu yPosition="above" [overlapTrigger]="true" #posYMenuOverlay="matMenu"> @for (item of items; track item) { <button mat-menu-item [disabled]="item.disabled">{{ item.text }}</button> } </mat-menu> </div> </div> <div style="height: 500px">This div is for testing scrolled menus.</div>
{ "end_byte": 6264, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/menu/menu-demo.html" }
components/src/dev-app/input-modality/input-modality-detector-demo.ts_0_1678
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {A11yModule, InputModality, InputModalityDetector} from '@angular/cdk/a11y'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, NgZone, OnDestroy, inject, } from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatInputModule} from '@angular/material/input'; import {MatRadioModule} from '@angular/material/radio'; import {MatSelectModule} from '@angular/material/select'; import {Subject} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; @Component({ selector: 'input-modality-detector-demo', templateUrl: 'input-modality-detector-demo.html', imports: [ A11yModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatRadioModule, MatSelectModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class InputModalityDetectorDemo implements OnDestroy { _modality: InputModality = null; _destroyed = new Subject<void>(); readonly cdr = inject(ChangeDetectorRef); constructor() { const inputModalityDetector = inject(InputModalityDetector); const ngZone = inject(NgZone); inputModalityDetector.modalityChanged.pipe(takeUntil(this._destroyed)).subscribe(modality => ngZone.run(() => { this._modality = modality; this.cdr.markForCheck(); }), ); } ngOnDestroy() { this._destroyed.next(); this._destroyed.complete(); } }
{ "end_byte": 1678, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/input-modality/input-modality-detector-demo.ts" }
components/src/dev-app/input-modality/input-modality-detector-demo.html_0_1099
<div> <h2>Input Modality</h2> <section class="demo-section"> <p> Interact with the controls below with keyboard, mouse, or touch to see the detected input modality change. </p> <p> Detected input modality: <strong>{{_modality || '(unknown)'}}</strong> </p> <button mat-raised-button>Launch</button> <br><br> <mat-form-field appearance="outline"> <mat-label>Name</mat-label> <input matInput> </mat-form-field> <br><br> <mat-form-field appearance="fill"> <mat-label>Food</mat-label> <mat-select> <mat-option>Apple</mat-option> <mat-option>Banana</mat-option> <mat-option>Carrot</mat-option> </mat-select> </mat-form-field> <br><br> <mat-radio-group name="color"> <mat-radio-button value="red" checked [style.margin-right.px]="16">Red</mat-radio-button> <mat-radio-button value="orange" [style.margin-right.px]="16">Orange</mat-radio-button> <mat-radio-button value="yellow">Yellow</mat-radio-button> </mat-radio-group> </section> </div>
{ "end_byte": 1099, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/input-modality/input-modality-detector-demo.html" }
components/src/dev-app/input-modality/BUILD.bazel_0_435
load("//tools:defaults.bzl", "ng_module") package(default_visibility = ["//visibility:public"]) ng_module( name = "input-modality", srcs = glob(["**/*.ts"]), assets = ["input-modality-detector-demo.html"], deps = [ "//src/cdk/a11y", "//src/material/button", "//src/material/form-field", "//src/material/input", "//src/material/radio", "//src/material/select", ], )
{ "end_byte": 435, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/input-modality/BUILD.bazel" }
components/src/dev-app/popover-edit/BUILD.bazel_0_392
load("//tools:defaults.bzl", "ng_module") package(default_visibility = ["//visibility:public"]) ng_module( name = "popover-edit", srcs = glob(["**/*.ts"]), deps = [ "//src/components-examples/cdk-experimental/popover-edit", "//src/components-examples/material-experimental/popover-edit", "//src/dev-app/example", "@npm//@angular/forms", ], )
{ "end_byte": 392, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/popover-edit/BUILD.bazel" }
components/src/dev-app/popover-edit/popover-edit-demo.ts_0_2850
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { CdkPopoverEditCdkTableExample, CdkPopoverEditCdkTableFlexExample, CdkPopoverEditCellSpanVanillaTableExample, CdkPopoverEditTabOutVanillaTableExample, CdkPopoverEditVanillaTableExample, } from '@angular/components-examples/cdk-experimental/popover-edit'; import { PopoverEditCellSpanMatTableExample, PopoverEditMatTableExample, PopoverEditMatTableFlexExample, PopoverEditTabOutMatTableExample, } from '@angular/components-examples/material-experimental/popover-edit'; import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormsModule} from '@angular/forms'; @Component({ template: ` <h3 id="cdk-popover-edit">CDK popover-edit with cdk-table</h3> <cdk-popover-edit-cdk-table-example></cdk-popover-edit-cdk-table-example> <h3 id="cdk-popover-edit-flex">CDK popover-edit with cdk-table flex</h3> <cdk-popover-edit-cdk-table-flex-example></cdk-popover-edit-cdk-table-flex-example> <h3 id="cdk-popover-edit-vanilla-span">CDK popover-edit with vanilla table</h3> <cdk-popover-edit-cell-span-vanilla-table-example> </cdk-popover-edit-cell-span-vanilla-table-example> <h3 id="cdk-popover-edit-vanilla-tabout">CDK popover-edit with vanilla table and tab out</h3> <cdk-popover-edit-tab-out-vanilla-table-example> </cdk-popover-edit-tab-out-vanilla-table-example> <h3 id="cdk-popover-edit-vanilla">CDK popover-edit with vanilla table</h3> <cdk-popover-edit-vanilla-table-example></cdk-popover-edit-vanilla-table-example> <h3 id="mat-popover-edit-span">Material popover-edit with mat-table and cell span</h3> <popover-edit-cell-span-mat-table-example></popover-edit-cell-span-mat-table-example> <h3 id="mat-popover-edit">Material popover-edit with mat-table</h3> <popover-edit-mat-table-example></popover-edit-mat-table-example> <h3 id="mat-popover-edit-flex">Material popover-edit with mat-table flex</h3> <popover-edit-mat-table-flex-example></popover-edit-mat-table-flex-example> <h3 id="mat-popover-edit-tabout">Material popover-edit with mat-table and tab out</h3> <popover-edit-tab-out-mat-table-example></popover-edit-tab-out-mat-table-example> `, imports: [ CdkPopoverEditCdkTableFlexExample, CdkPopoverEditCdkTableExample, CdkPopoverEditCellSpanVanillaTableExample, CdkPopoverEditTabOutVanillaTableExample, CdkPopoverEditVanillaTableExample, PopoverEditCellSpanMatTableExample, PopoverEditMatTableFlexExample, PopoverEditMatTableExample, PopoverEditTabOutMatTableExample, FormsModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class PopoverEditDemo {}
{ "end_byte": 2850, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/popover-edit/popover-edit-demo.ts" }
components/src/dev-app/typography/typography-demo.scss_0_34
.mat-body { max-width: 800px; }
{ "end_byte": 34, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/typography/typography-demo.scss" }
components/src/dev-app/typography/typography-demo.html_0_2411
<!-- via https://en.wikipedia.org/wiki/Pangram --> <div class="mat-typography"> <h1 class="mat-headline-1">How vexingly quick daft zebras jump!</h1> <h1 class="mat-headline-2">The wizard quickly jinxed the gnomes before they vaporized.</h1> <h1 class="mat-headline-3">The quick brown fox jumps over the lazy dog.</h1> <h1 class="mat-headline-4">Grumpy wizards make toxic brew for the evil queen and jack.</h1> <h1>Jackdaws love my big sphinx of quartz.</h1> <h2>The five boxing wizards jump quickly.</h2> <h3>Pack my box with five dozen liquor jugs.</h3> <h4>Bright vixens jump; dozy fowl quack.</h4> <div class="mat-body"> <p> Lucas ipsum dolor sit amet coruscant fisto hutt dantooine darth binks amidala kessel grievous mara. Ackbar mandalore skywalker calamari. Calrissian binks tusken raider kit. Darth binks chewbacca skywalker. Moff baba padmé antilles darth ponda twi'lek darth. Dagobah naboo mara jawa dagobah ackbar ackbar darth. Mara mace r2-d2 mon naboo darth dantooine leia. Droid chewbacca mace han. Wampa hutt qui-gon solo jango secura tusken raider yoda. Droid boba mon mandalore jinn han binks. Maul darth kit wedge mace utapau darth darth fett. </p> <p> Antilles antilles secura yavin. Leia luke owen hutt baba yoda hoth obi-wan. Moff thrawn solo jango mon. Antilles lobot hutt tusken raider moff jade kessel binks. Moff ewok sidious naboo darth ventress tusken raider. Bothan yavin moff fett organa binks jade binks. Mara moff darth jade sidious. Darth binks obi-wan padmé dagobah hutt ponda antilles ackbar. Fett gamorrean obi-wan sidious hutt maul. Organa darth k-3po kessel aayla. Hoth c-3po amidala biggs kenobi twi'lek twi'lek ahsoka. Obi-wan ackbar windu wicket kit c-3po. </p> <p> Hutt naboo greedo skywalker hutt luuke ben. Hutt chewbacca jabba solo calrissian jade yoda amidala zabrak. Solo luke antilles c-3p0. Sith darth skywalker fett solo hutt skywalker c-3p0 skywalker. Skywalker skywalker solo kessel darth fett. Skywalker skywalker c-3po jango. Alderaan darth boba calamari. Wicket alderaan darth darth chewbacca jango. Darth darth chewbacca ponda solo grievous hutt calrissian lando. Darth mon watto vader chewbacca. Lando mace luke yavin darth wookiee c-3po. Moff kessel skywalker yoda c-3po yavin. </p> </div> </div>
{ "end_byte": 2411, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/typography/typography-demo.html" }
components/src/dev-app/typography/BUILD.bazel_0_440
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "typography", srcs = glob(["**/*.ts"]), assets = [ "typography-demo.html", ":typography_demo_scss", ], deps = [ "//src/material/checkbox", "@npm//@angular/forms", ], ) sass_binary( name = "typography_demo_scss", src = "typography-demo.scss", )
{ "end_byte": 440, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/typography/BUILD.bazel" }
components/src/dev-app/typography/typography-demo.ts_0_625
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {MatCheckboxModule} from '@angular/material/checkbox'; @Component({ selector: 'typography-demo', templateUrl: 'typography-demo.html', styleUrl: 'typography-demo.css', imports: [MatCheckboxModule, FormsModule], changeDetection: ChangeDetectionStrategy.OnPush, }) export class TypographyDemo {}
{ "end_byte": 625, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/typography/typography-demo.ts" }
components/src/dev-app/grid-list/grid-list-demo.scss_0_218
.demo-grid-list { width: 1100px; .mat-mdc-card { margin: 16px 0; } p { margin: 16px; } .demo-basic-list .mat-grid-tile { background: rgba(0, 0, 0, 0.32); } img { width: 350px; } }
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/grid-list/grid-list-demo.scss" }
components/src/dev-app/grid-list/grid-list-demo.html_0_4962
<div class="demo-grid-list"> <mat-card> <mat-card-title>Basic grid list</mat-card-title> <mat-card-content class="demo-basic-list"> <mat-grid-list cols="4" [rowHeight]="basicRowHeight"> <mat-grid-tile> One </mat-grid-tile> <mat-grid-tile> Two </mat-grid-tile> <mat-grid-tile> Three </mat-grid-tile> <mat-grid-tile> Four </mat-grid-tile> </mat-grid-list> </mat-card-content> </mat-card> <mat-card> <mat-card-title>Grid with 1 cell at the beginning of a new row</mat-card-title> <mat-card-content class="demo-basic-list"> <mat-grid-list [cols]="6" gutterSize="20px" rowHeight="20px"> <mat-grid-tile [colspan]="3" [rowspan]="4" class="mat-elevation-z15"> </mat-grid-tile> <mat-grid-tile [colspan]="3" [rowspan]="4" class="mat-elevation-z15"> </mat-grid-tile> <mat-grid-tile [colspan]="1" [rowspan]="2" class="mat-elevation-z15"> </mat-grid-tile> </mat-grid-list> </mat-card-content> </mat-card> <mat-card> <mat-card-title>Grid with col-span</mat-card-title> <mat-card-content class="demo-basic-list"> <mat-grid-list [cols]="10" gutterSize="20px" rowHeight="20px"> <mat-grid-tile [colspan]="4" [rowspan]="4" class="mat-elevation-z15"> </mat-grid-tile> <mat-grid-tile [colspan]="2" [rowspan]="2" class="mat-elevation-z15"> </mat-grid-tile> <mat-grid-tile [colspan]="4" [rowspan]="4" class="mat-elevation-z15"> </mat-grid-tile> <mat-grid-tile [colspan]="4" [rowspan]="4" class="mat-elevation-z15"> </mat-grid-tile> <mat-grid-tile [colspan]="4" [rowspan]="4" class="mat-elevation-z15"> </mat-grid-tile> </mat-grid-list> </mat-card-content> </mat-card> <mat-card> <mat-card-title>Fixed-height grid list</mat-card-title> <mat-card-content> <mat-grid-list [cols]="fixedCols" [rowHeight]="fixedRowHeight"> @for (tile of tiles; track tile) { <mat-grid-tile [colspan]="tile.cols" [rowspan]="tile.rows" [style.background]="tile.color"> {{tile.text}} </mat-grid-tile> } </mat-grid-list> </mat-card-content> <mat-card-actions> <p>Change list cols: <input type="number" [(ngModel)]="fixedCols"></p> <p>Change row height: <input type="number" [(ngModel)]="fixedRowHeight"></p> <button mat-button (click)="addTileCols()" color="primary">ADD COLSPAN (THREE)</button> </mat-card-actions> </mat-card> <mat-card> <mat-card-title>Ratio-height grid list</mat-card-title> <mat-card-content> <mat-grid-list cols="2" [rowHeight]="ratio" gutterSize="4px"> @for (tile of tiles; track tile) { <mat-grid-tile [style.background]="'lightblue'">{{tile.text}}</mat-grid-tile> } </mat-grid-list> </mat-card-content> <mat-card-actions> <p>Change ratio: <input [(ngModel)]="ratio"></p> </mat-card-actions> </mat-card> <mat-card> <mat-card-title>Fit-height grid list</mat-card-title> <mat-card-content> <mat-grid-list cols="2" rowHeight="fit" [gutterSize]="ratioGutter" [style.height]="fitListHeight"> @for (tile of tiles; track tile) { <mat-grid-tile [style.background]="'#F1EBBA'">{{tile.text}}</mat-grid-tile> } </mat-grid-list> </mat-card-content> <mat-card-actions> <p>Change list height: <input [(ngModel)]="fitListHeight"></p> <p>Change gutter: <input type="number" [(ngModel)]="ratioGutter"></p> </mat-card-actions> </mat-card> <mat-card> <mat-card-title>Grid list with header</mat-card-title> <mat-card-content> <mat-grid-list cols="3" rowHeight="200px"> @for (dog of dogs; track dog) { <mat-grid-tile style="background:gray"> <mat-grid-tile-header> <mat-icon mat-grid-avatar>info_outline</mat-icon> {{dog.name}} </mat-grid-tile-header> </mat-grid-tile> } </mat-grid-list> </mat-card-content> </mat-card> <mat-card> <mat-card-title>Grid list with footer</mat-card-title> <mat-card-content> <mat-grid-list cols="3" rowHeight="200px"> @for (dog of dogs; track dog) { <mat-grid-tile> <img [alt]="dog.name" src="https://material.angularjs.org/material2_assets/ngconf/{{dog.name}}.png"> <mat-grid-tile-footer> <h3 mat-line>{{dog.name}}</h3> <span mat-line>Human: {{dog.human}}</span> <mat-icon>star_border</mat-icon> </mat-grid-tile-footer> </mat-grid-tile> } </mat-grid-list> </mat-card-content> </mat-card> </div>
{ "end_byte": 4962, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/grid-list/grid-list-demo.html" }
components/src/dev-app/grid-list/grid-list-demo.ts_0_1591
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {MatButtonModule} from '@angular/material/button'; import {MatCardModule} from '@angular/material/card'; import {MatGridListModule} from '@angular/material/grid-list'; import {MatIconModule} from '@angular/material/icon'; @Component({ selector: 'grid-list-demo', templateUrl: 'grid-list-demo.html', styleUrl: 'grid-list-demo.css', imports: [FormsModule, MatButtonModule, MatCardModule, MatGridListModule, MatIconModule], changeDetection: ChangeDetectionStrategy.OnPush, }) export class GridListDemo { tiles: {text: string; cols: number; rows: number; color: string}[] = [ {text: 'One', cols: 3, rows: 1, color: 'lightblue'}, {text: 'Two', cols: 1, rows: 2, color: 'lightgreen'}, {text: 'Three', cols: 1, rows: 1, color: 'lightpink'}, {text: 'Four', cols: 2, rows: 1, color: '#DDBDF1'}, ]; dogs: {name: string; human: string}[] = [ {name: 'Porter', human: 'Kara'}, {name: 'Mal', human: 'Jeremy'}, {name: 'Koby', human: 'Igor'}, {name: 'Razzle', human: 'Ward'}, {name: 'Molly', human: 'Rob'}, {name: 'Husi', human: 'Matias'}, ]; basicRowHeight = 80; fixedCols = 4; fixedRowHeight = 100; ratioGutter = '1px'; fitListHeight = '400px'; ratio = '4:1'; addTileCols() { this.tiles[2].cols++; } }
{ "end_byte": 1591, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/grid-list/grid-list-demo.ts" }
components/src/dev-app/grid-list/BUILD.bazel_0_499
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "grid-list", srcs = glob(["**/*.ts"]), assets = [ "grid-list-demo.html", ":grid_list_demo_scss", ], deps = [ "//src/material/button", "//src/material/card", "//src/material/grid-list", "//src/material/icon", ], ) sass_binary( name = "grid_list_demo_scss", src = "grid-list-demo.scss", )
{ "end_byte": 499, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/grid-list/BUILD.bazel" }
components/src/dev-app/bottom-sheet/bottom-sheet-demo.scss_0_109
.demo-dialog-card { max-width: 405px; margin: 20px 0; } .mat-mdc-raised-button { margin-right: 5px; }
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/bottom-sheet/bottom-sheet-demo.scss" }
components/src/dev-app/bottom-sheet/bottom-sheet-demo.html_0_1340
<h1>Bottom sheet demo</h1> <button mat-raised-button color="primary" (click)="openComponent()">Open component sheet</button> <button mat-raised-button color="accent" (click)="openTemplate()">Open template sheet</button> <mat-card class="demo-dialog-card"> <mat-card-content> <h2>Options</h2> <p> <mat-checkbox [(ngModel)]="config.hasBackdrop">Has backdrop</mat-checkbox> </p> <p> <mat-checkbox [(ngModel)]="config.disableClose">Disable close</mat-checkbox> </p> <p> <mat-form-field> <input matInput [(ngModel)]="config.backdropClass" placeholder="Backdrop class"> </mat-form-field> </p> <p> <mat-form-field> <mat-select placeholder="Direction" [(ngModel)]="config.direction"> <mat-option value="ltr">LTR</mat-option> <mat-option value="rtl">RTL</mat-option> </mat-select> </mat-form-field> </p> </mat-card-content> </mat-card> <ng-template let-bottomSheetRef="bottomSheetRef"> <mat-nav-list> @for (action of [1, 2, 3]; track action) { <mat-list-item (click)="bottomSheetRef.dismiss()"> <mat-icon matListItemIcon>folder</mat-icon> <span matListItemTitle>Action {{ action }}</span> <span matLine>Description</span> </mat-list-item> } </mat-nav-list> </ng-template>
{ "end_byte": 1340, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/bottom-sheet/bottom-sheet-demo.html" }
components/src/dev-app/bottom-sheet/bottom-sheet-demo.ts_0_2533
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, Component, TemplateRef, ViewChild, inject} from '@angular/core'; import {FormsModule} from '@angular/forms'; import { MatBottomSheet, MatBottomSheetConfig, MatBottomSheetModule, MatBottomSheetRef, } from '@angular/material/bottom-sheet'; import {MatButtonModule} from '@angular/material/button'; import {MatCardModule} from '@angular/material/card'; import {MatCheckboxModule} from '@angular/material/checkbox'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatIconModule} from '@angular/material/icon'; import {MatInputModule} from '@angular/material/input'; import {MatListModule} from '@angular/material/list'; import {MatSelectModule} from '@angular/material/select'; const defaultConfig = new MatBottomSheetConfig(); @Component({ selector: 'bottom-sheet-demo', styleUrl: 'bottom-sheet-demo.css', templateUrl: 'bottom-sheet-demo.html', imports: [ FormsModule, MatBottomSheetModule, MatButtonModule, MatCardModule, MatCheckboxModule, MatFormFieldModule, MatIconModule, MatInputModule, MatSelectModule, MatListModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class BottomSheetDemo { private _bottomSheet = inject(MatBottomSheet); config: MatBottomSheetConfig = { hasBackdrop: defaultConfig.hasBackdrop, disableClose: defaultConfig.disableClose, backdropClass: defaultConfig.backdropClass, direction: 'ltr', ariaLabel: 'Example bottom sheet', }; @ViewChild(TemplateRef) template: TemplateRef<any>; openComponent() { this._bottomSheet.open(ExampleBottomSheet, this.config); } openTemplate() { this._bottomSheet.open(this.template, this.config); } } @Component({ template: ` <mat-nav-list> @for (action of [1, 2, 3]; track action) { <a href="#" mat-list-item (click)="handleClick($event)"> <span matListItemTitle>Action {{ action }}</span> <span matListItemLine>Description</span> </a> } </mat-nav-list> `, imports: [MatListModule], changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExampleBottomSheet { private _bottomSheet = inject(MatBottomSheetRef); handleClick(event: MouseEvent) { event.preventDefault(); this._bottomSheet.dismiss(); } }
{ "end_byte": 2533, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/bottom-sheet/bottom-sheet-demo.ts" }
components/src/dev-app/bottom-sheet/BUILD.bazel_0_717
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "bottom-sheet", srcs = glob(["**/*.ts"]), assets = [ "bottom-sheet-demo.html", ":bottom_sheet_demo_scss", ], deps = [ "//src/material/bottom-sheet", "//src/material/button", "//src/material/card", "//src/material/checkbox", "//src/material/form-field", "//src/material/icon", "//src/material/input", "//src/material/list", "//src/material/select", "@npm//@angular/forms", ], ) sass_binary( name = "bottom_sheet_demo_scss", src = "bottom-sheet-demo.scss", )
{ "end_byte": 717, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/bottom-sheet/BUILD.bazel" }
components/src/dev-app/selection/selection-demo.ts_0_1332
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { CdkSelectionColumnExample, CdkSelectionListExample, } from '@angular/components-examples/cdk-experimental/selection'; import { MatSelectionColumnExample, MatSelectionListExample, } from '@angular/components-examples/material-experimental/selection'; import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormsModule} from '@angular/forms'; @Component({ template: ` <h3>CDK selection with a list</h3> <cdk-selection-list-example></cdk-selection-list-example> <h3>CDK selection column and CDK row selection with CDK table</h3> <cdk-selection-column-example></cdk-selection-column-example> <h3>Mat selection with a list</h3> <mat-selection-list-example></mat-selection-list-example> <h3>Mat selection column and Mat row selection with Mat table</h3> <mat-selection-column-example></mat-selection-column-example> `, imports: [ CdkSelectionColumnExample, CdkSelectionListExample, MatSelectionColumnExample, MatSelectionListExample, FormsModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class SelectionDemo {}
{ "end_byte": 1332, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/selection/selection-demo.ts" }
components/src/dev-app/selection/BUILD.bazel_0_383
load("//tools:defaults.bzl", "ng_module") package(default_visibility = ["//visibility:public"]) ng_module( name = "selection", srcs = glob(["**/*.ts"]), deps = [ "//src/components-examples/cdk-experimental/selection", "//src/components-examples/material-experimental/selection", "//src/dev-app/example", "@npm//@angular/forms", ], )
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/selection/BUILD.bazel" }
components/src/dev-app/select/select-demo.ts_0_6536
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, Component} from '@angular/core'; import {JsonPipe} from '@angular/common'; import {FormControl, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms'; import {MatButtonModule} from '@angular/material/button'; import {MatCardModule} from '@angular/material/card'; import {MatCheckboxModule} from '@angular/material/checkbox'; import {ErrorStateMatcher, ThemePalette} from '@angular/material/core'; import {FloatLabelType} from '@angular/material/form-field'; import {MatIconModule} from '@angular/material/icon'; import {MatInputModule} from '@angular/material/input'; import {MatSelectChange, MatSelectModule} from '@angular/material/select'; /** Error any time control is invalid */ export class MyErrorStateMatcher implements ErrorStateMatcher { isErrorState(control: FormControl | null): boolean { if (control) { return control.invalid; } return false; } } type DisableDrinkOption = 'none' | 'first-middle-last' | 'all'; @Component({ selector: 'select-demo', templateUrl: 'select-demo.html', styleUrl: 'select-demo.css', imports: [ JsonPipe, FormsModule, MatButtonModule, MatCardModule, MatCheckboxModule, MatIconModule, MatInputModule, MatSelectModule, ReactiveFormsModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class SelectDemo { drinksRequired = false; drinkObjectRequired = false; pokemonRequired = false; drinksDisabled = false; drinksOptionsDisabled: DisableDrinkOption = 'none'; pokemonDisabled = false; pokemonOptionsDisabled = false; showSelect = false; currentDrink: string; currentDrinkObject: {} | undefined = {value: 'tea-5', viewValue: 'Tea'}; currentPokemon: string[]; currentPokemonFromGroup: string; currentDigimon: string; currentAppearanceValue: string | null; latestChangeEvent: MatSelectChange | undefined; floatLabel: FloatLabelType = 'auto'; drinksWidth = 'default'; foodControl = new FormControl('pizza-1'); topHeightCtrl = new FormControl(0); drinksTheme: ThemePalette = 'primary'; pokemonTheme: ThemePalette = 'primary'; compareByValue = true; selectFormControl = new FormControl('', Validators.required); sandwichBread = ''; sandwichMeat = ''; sandwichCheese = ''; sandwichHideSingleSelectionIndicator = false; foods = [ {value: null, viewValue: 'None'}, {value: 'steak-0', viewValue: 'Steak'}, {value: 'pizza-1', viewValue: 'Pizza'}, {value: 'tacos-2', viewValue: 'Tacos'}, ]; drinks = [ {value: 'coke-0', viewValue: 'Coke'}, { value: 'long-name-1', viewValue: 'Decaf Chocolate Brownie Vanilla Gingerbread Frappuccino', disabled: false, }, {value: 'water-2', viewValue: 'Water'}, {value: 'pepper-3', viewValue: 'Dr. Pepper'}, {value: 'coffee-4', viewValue: 'Coffee'}, {value: 'tea-5', viewValue: 'Tea'}, {value: 'juice-6', viewValue: 'Orange juice'}, {value: 'wine-7', viewValue: 'Wine'}, {value: 'milk-8', viewValue: 'Milk'}, ]; pokemon = [ {value: 'bulbasaur-0', viewValue: 'Bulbasaur'}, {value: 'charizard-1', viewValue: 'Charizard'}, {value: 'squirtle-2', viewValue: 'Squirtle'}, {value: 'pikachu-3', viewValue: 'Pikachu'}, {value: 'jigglypuff-4', viewValue: 'Jigglypuff with a really long name that will truncate'}, {value: 'ditto-5', viewValue: 'Ditto'}, {value: 'psyduck-6', viewValue: 'Psyduck'}, ]; availableThemes = [ {value: 'primary', name: 'Primary'}, {value: 'accent', name: 'Accent'}, {value: 'warn', name: 'Warn'}, ]; pokemonGroups = [ { name: 'Grass', pokemon: [ {value: 'bulbasaur-0', viewValue: 'Bulbasaur'}, {value: 'oddish-1', viewValue: 'Oddish'}, {value: 'bellsprout-2', viewValue: 'Bellsprout'}, ], }, { name: 'Water', pokemon: [ {value: 'squirtle-3', viewValue: 'Squirtle'}, {value: 'psyduck-4', viewValue: 'Psyduck'}, {value: 'horsea-5', viewValue: 'Horsea'}, ], }, { name: 'Fire', disabled: true, pokemon: [ {value: 'charmander-6', viewValue: 'Charmander'}, {value: 'vulpix-7', viewValue: 'Vulpix'}, {value: 'flareon-8', viewValue: 'Flareon'}, ], }, { name: 'Psychic', pokemon: [ {value: 'mew-9', viewValue: 'Mew'}, {value: 'mewtwo-10', viewValue: 'Mewtwo'}, ], }, ]; digimon = [ {value: 'mihiramon-0', viewValue: 'Mihiramon'}, {value: 'sandiramon-1', viewValue: 'Sandiramon'}, {value: 'sinduramon-2', viewValue: 'Sinduramon'}, {value: 'pajiramon-3', viewValue: 'Pajiramon'}, {value: 'vajiramon-4', viewValue: 'Vajiramon'}, {value: 'indramon-5', viewValue: 'Indramon'}, ]; breads = [ {value: 'white', viewValue: 'White'}, {value: 'white', viewValue: 'Wheat'}, {value: 'white', viewValue: 'Sourdough'}, ]; meats = [ {value: 'turkey', viewValue: 'Turkey'}, {value: 'bacon', viewValue: 'Bacon'}, {value: 'veggiePatty', viewValue: 'Veggie Patty'}, {value: 'tuna', viewValue: 'Tuna'}, ]; cheeses = [ {value: 'none', viewValue: 'None'}, {value: 'swiss', viewValue: 'Swiss'}, {value: 'american', viewValue: 'American'}, {value: 'cheddar', viewValue: 'Cheddar'}, ]; toggleDisabled() { this.foodControl.enabled ? this.foodControl.disable() : this.foodControl.enable(); } setPokemonValue() { this.currentPokemon = ['jigglypuff-4', 'psyduck-6']; } reassignDrinkByCopy() { this.currentDrinkObject = {...this.currentDrinkObject}; } compareDrinkObjectsByValue(d1: {value: string}, d2: {value: string}) { return d1 && d2 && d1.value === d2.value; } compareByReference(o1: any, o2: any) { return o1 === o2; } matcher = new MyErrorStateMatcher(); toggleSelected() { this.currentAppearanceValue = this.currentAppearanceValue ? null : this.digimon[0].value; } isDrinkOptionDisabled(index: number) { if (this.drinksOptionsDisabled === 'all') { return true; } if (this.drinksOptionsDisabled === 'first-middle-last') { return ( index === 0 || index === this.drinks.length - 1 || index === Math.floor(this.drinks.length / 2) ); } return false; } }
{ "end_byte": 6536, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/select/select-demo.ts" }
components/src/dev-app/select/select-demo.html_0_195
Space above cards: <input type="number" [formControl]="topHeightCtrl"> <button mat-button (click)="showSelect=!showSelect">SHOW SELECT</button> <div [style.height.px]="topHeightCtrl.value"></div>
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/select/select-demo.html" }
components/src/dev-app/select/select-demo.html_197_8372
<div class="demo-select"> <mat-card> <mat-card-subtitle>ngModel</mat-card-subtitle> <mat-card-content> <mat-form-field [floatLabel]="floatLabel" [color]="drinksTheme" [class.demo-drinks-width-large]="drinksWidth === '400px'"> <mat-label>Drink</mat-label> <mat-select [(ngModel)]="currentDrink" [required]="drinksRequired" [disabled]="drinksDisabled" #drinkControl="ngModel"> <mat-option [disabled]="drinksOptionsDisabled === 'all'">None</mat-option> @for (drink of drinks; track drink; let index = $index) { <mat-option [value]="drink.value" [disabled]="isDrinkOptionDisabled(index)"> {{ drink.viewValue }} </mat-option> } </mat-select> <mat-icon matPrefix class="demo-drink-icon">local_drink</mat-icon> <mat-hint>Pick a drink!</mat-hint> <mat-error>You must make a selection</mat-error> </mat-form-field> <p> Value: {{ currentDrink }} </p> <p> Touched: {{ drinkControl.touched }} </p> <p> Dirty: {{ drinkControl.dirty }} </p> <p> Status: {{ drinkControl.status }} </p> <p> <label for="floating-label">Floating label:</label> <select [(ngModel)]="floatLabel" id="floating-label"> <option value="auto">Auto</option> <option value="always">Always</option> <option value="never">Never</option> </select> </p> <p> <label for="drinks-width">Width:</label> <select [(ngModel)]="drinksWidth" id="drinks-width"> <option value="default">Default</option> <option value="400px">400px</option> </select> </p> <p> <label for="drinks-theme">Theme:</label> <select [(ngModel)]="drinksTheme" id="drinks-theme"> @for (theme of availableThemes; track theme) { <option [value]="theme.value">{{theme.name}}</option> } </select> </p> <p> <label for="drinks-disabled-options">Disabled options:</label> <select [(ngModel)]="drinksOptionsDisabled" id="drinks-disabled-options"> <option value="none">None</option> <option value="first-middle-last">Disable First, Middle, and Last Options</option> <option value="all">Disable All Options</option> </select> </p> <button mat-button (click)="currentDrink='water-2'">SET VALUE</button> <button mat-button (click)="drinksRequired=!drinksRequired">TOGGLE REQUIRED</button> <button mat-button (click)="drinksDisabled=!drinksDisabled">TOGGLE DISABLED</button> <button mat-button (click)="drinkControl.reset()">RESET</button> </mat-card-content> </mat-card> <mat-card> <mat-card-subtitle>Multiple selection</mat-card-subtitle> <mat-card-content> <mat-form-field [color]="pokemonTheme"> <mat-label>Pokemon</mat-label> <mat-select multiple [(ngModel)]="currentPokemon" [required]="pokemonRequired" [disabled]="pokemonDisabled" #pokemonControl="ngModel"> @for (creature of pokemon; track creature) { <mat-option [value]="creature.value" [disabled]="pokemonOptionsDisabled"> {{ creature.viewValue }} </mat-option> } </mat-select> </mat-form-field> <p> Value: {{ currentPokemon }} </p> <p> Touched: {{ pokemonControl.touched }} </p> <p> Dirty: {{ pokemonControl.dirty }} </p> <p> Status: {{ pokemonControl.status }} </p> <p> <label for="pokemon-theme">Theme:</label> <select [(ngModel)]="pokemonTheme" id="pokemon-theme"> @for (theme of availableThemes; track theme) { <option [value]="theme.value">{{ theme.name }}</option> } </select> </p> <button mat-button (click)="setPokemonValue()">SET VALUE</button> <button mat-button (click)="pokemonRequired=!pokemonRequired">TOGGLE REQUIRED</button> <button mat-button (click)="pokemonDisabled=!pokemonDisabled">TOGGLE DISABLED</button> <button mat-button (click)="pokemonOptionsDisabled=!pokemonOptionsDisabled">TOGGLE DISABLED OPTIONS</button> <button mat-button (click)="pokemonControl.reset()">RESET</button> </mat-card-content> </mat-card> <mat-card> <mat-card-subtitle>Without Angular forms</mat-card-subtitle> <mat-card-content> <mat-form-field> <mat-label>Digimon</mat-label> <mat-select [(value)]="currentDigimon"> <mat-option>None</mat-option> @for (creature of digimon; track creature) { <mat-option [value]="creature.value">{{ creature.viewValue }}</mat-option> } </mat-select> </mat-form-field> <p>Value: {{ currentDigimon }}</p> <button mat-button (click)="currentDigimon='pajiramon-3'">SET VALUE</button> <button mat-button (click)="currentDigimon=''">RESET</button> </mat-card-content> </mat-card> <mat-card> <mat-card-subtitle>Option groups</mat-card-subtitle> <mat-card-content> <mat-form-field> <mat-label>Pokemon</mat-label> <mat-select [(ngModel)]="currentPokemonFromGroup"> @for (group of pokemonGroups; track group) { <mat-optgroup [label]="group.name" [disabled]="group.disabled"> @for (creature of group.pokemon; track creature) { <mat-option [value]="creature.value">{{ creature.viewValue }}</mat-option> } </mat-optgroup> } </mat-select> </mat-form-field> </mat-card-content> </mat-card> <mat-card> <mat-card-subtitle>compareWith</mat-card-subtitle> <mat-card-content> <mat-form-field [color]="drinksTheme"> <mat-label>Drink</mat-label> <mat-select [(ngModel)]="currentDrinkObject" [required]="drinkObjectRequired" [compareWith]="compareByValue ? compareDrinkObjectsByValue : compareByReference" #drinkObjectControl="ngModel"> @for (drink of drinks; track drink) { <mat-option [value]="drink" [disabled]="drink.disabled">{{ drink.viewValue }}</mat-option> } </mat-select> </mat-form-field> <p> Value: {{ currentDrinkObject | json }} </p> <p> Touched: {{ drinkObjectControl.touched }} </p> <p> Dirty: {{ drinkObjectControl.dirty }} </p> <p> Status: {{ drinkObjectControl.status }} </p> <p> Comparison Mode: {{ compareByValue ? 'VALUE' : 'REFERENCE' }} </p> <button mat-button (click)="reassignDrinkByCopy()" matTooltip="This action should clear the display value when comparing by reference."> REASSIGN DRINK BY COPY </button> <button mat-button (click)="drinkObjectRequired=!drinkObjectRequired">TOGGLE REQUIRED</button> <button mat-button (click)="compareByValue=!compareByValue">TOGGLE COMPARE BY VALUE</button> <button mat-button (click)="drinkObjectControl.reset()">RESET</button> </mat-card-content> </mat-card> <mat-card> <mat-card-subtitle>Appearance comparison</mat-card-subtitle> <mat-card-content> <p> <mat-form-field appearance="fill"> <mat-label>Fill</mat-label> <mat-select [(value)]="currentAppearanceValue"> <mat-option>None</mat-option> @for (creature of digimon; track creature) { <mat-option [value]="creature.value">{{ creature.viewValue }}</mat-option> } </mat-select> </mat-form-field> </p> <p> <mat-form-field appearance="outline"> <mat-label>Outline</mat-label> <mat-select [(value)]="currentAppearanceValue"> <mat-option>None</mat-option> @for (creature of digimon; track creature) { <mat-option [value]="creature.value">{{ creature.viewValue }}</mat-option> } </mat-select> </mat-form-field> </p> <button mat-button (click)="toggleSelected()">TOGGLE SELECTED</button> </mat-card-content> </mat-card>
{ "end_byte": 8372, "start_byte": 197, "url": "https://github.com/angular/components/blob/main/src/dev-app/select/select-demo.html" }
components/src/dev-app/select/select-demo.html_8376_15144
@if (showSelect) { <div> <mat-card> <mat-card-subtitle>formControl</mat-card-subtitle> <mat-card-content> <mat-form-field> <mat-label>Food I would like to eat</mat-label> <mat-select [formControl]="foodControl"> @for (food of foods; track food) { <mat-option [value]="food.value">{{ food.viewValue }}</mat-option> } </mat-select> </mat-form-field> <p> Value: {{ foodControl.value }} </p> <p> Touched: {{ foodControl.touched }} </p> <p> Dirty: {{ foodControl.dirty }} </p> <p> Status: {{ foodControl.status }} </p> <button mat-button (click)="foodControl.setValue('pizza-1')">SET VALUE</button> <button mat-button (click)="toggleDisabled()">TOGGLE DISABLED</button> <button mat-button (click)="foodControl.reset()">RESET</button> </mat-card-content> </mat-card> </div> } @if (showSelect) { <div> <mat-card> <mat-card-subtitle>Change event</mat-card-subtitle> <mat-card-content> <mat-form-field> <mat-label>Starter pokemon</mat-label> <mat-select (selectionChange)="latestChangeEvent = $event"> @for (creature of pokemon; track creature) { <mat-option [value]="creature.value">{{ creature.viewValue }}</mat-option> } </mat-select> </mat-form-field> <p> Change event value: {{ latestChangeEvent?.value }} </p> </mat-card-content> </mat-card> </div> } </div> <mat-card class="demo-card demo-basic"> <mat-card-content> <form> <h4>Basic</h4> <mat-form-field class="demo-full-width"> <mat-label>Select your car</mat-label> <select matNativeControl id="mySelectId"> <option value="" disabled selected></option> <option value="volvo">Volvo</option> <option value="saab" disabled>Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> </mat-form-field> <h4>Disabled and required</h4> <mat-form-field class="demo-full-width"> <mat-label>Select your car (disabled)</mat-label> <select matNativeControl disabled required> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> </mat-form-field> <h4>Floating label</h4> <mat-form-field> <mat-label>Float with value</mat-label> <select matNativeControl> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> </mat-form-field> <mat-form-field> <mat-label>Not float when empty</mat-label> <select matNativeControl> <option value="" selected></option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> </mat-form-field> <mat-form-field> <mat-label>Float with no value, but with label</mat-label> <select matNativeControl> <option value="" selected label="--select one--"></option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> </mat-form-field> <mat-form-field> <mat-label>Float with no value, but with html</mat-label> <select matNativeControl> <option value="" selected>--select one--</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> </mat-form-field> <h4>Looks</h4> <mat-form-field appearance="fill"> <mat-label>Fill</mat-label> <select matNativeControl required> <option value="" selected></option> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> </mat-form-field> <mat-form-field appearance="outline"> <mat-label>Outline</mat-label> <select matNativeControl> <option value="" selected></option> <option value="volvo">volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> </mat-form-field> <h4>Option group</h4> <mat-form-field> <select matNativeControl> <optgroup label="Swedish Cars"> <option value="volvo">volvo</option> <option value="saab">Saab</option> </optgroup> <optgroup label="German Cars"> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </optgroup> </select> </mat-form-field> <h4>Error message, hint, form sumbit</h4> <mat-form-field class="demo-full-width"> <mat-label>Select your car (required)</mat-label> <select matNativeControl required [formControl]="selectFormControl"> <option label="--select something --"></option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> @if (selectFormControl.hasError('required')) { <mat-error>This field is required</mat-error> } <mat-hint>You can pick up your favorite car here</mat-hint> </mat-form-field> <h4>Error message with errorStateMatcher</h4> <mat-form-field class="demo-full-width"> <mat-label>Select your car</mat-label> <select matNativeControl required [formControl]="selectFormControl" [errorStateMatcher]="matcher"> <option label="--select something --"></option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> @if (selectFormControl.hasError('required')) { <mat-error>This field is required</mat-error> } <mat-hint>You can pick up your favorite car here</mat-hint> </mat-form-field> <button color="primary" mat-raised-button>Submit</button> </form> </mat-card-content> </mat-card>
{ "end_byte": 15144, "start_byte": 8376, "url": "https://github.com/angular/components/blob/main/src/dev-app/select/select-demo.html" }
components/src/dev-app/select/select-demo.html_15146_16591
<mat-card class="demo-card demo-narrow"> <mat-card-subtitle>Narrow</mat-card-subtitle> <mat-card-content> <p class="demo-narrow-sandwich"> <mat-form-field> <mat-label>Bread</mat-label> <mat-select [(ngModel)]="sandwichBread" [hideSingleSelectionIndicator]="sandwichHideSingleSelectionIndicator"> @for (bread of breads; track bread) { <mat-option [value]="bread.value">{{ bread.viewValue }}</mat-option> } </mat-select> </mat-form-field> <mat-form-field> <mat-label>Meat</mat-label> <mat-select [(ngModel)]="sandwichMeat" [hideSingleSelectionIndicator]="sandwichHideSingleSelectionIndicator"> @for (meat of meats; track meat) { <mat-option [value]="meat.value">{{ meat.viewValue }}</mat-option> } </mat-select> </mat-form-field> <mat-form-field> <mat-label>Cheese</mat-label> <mat-select [(ngModel)]="sandwichCheese" [hideSingleSelectionIndicator]="sandwichHideSingleSelectionIndicator"> @for (cheese of cheeses; track cheese) { <mat-option [value]="cheese.value">{{ cheese.viewValue }}</mat-option> } </mat-select> </mat-form-field> </p> <mat-checkbox [(ngModel)]="sandwichHideSingleSelectionIndicator"> Hide Single-Selection Indicator </mat-checkbox> </mat-card-content> </mat-card>
{ "end_byte": 16591, "start_byte": 15146, "url": "https://github.com/angular/components/blob/main/src/dev-app/select/select-demo.html" }
components/src/dev-app/select/select-demo.scss_0_477
.demo-select { display: flex; flex-flow: row wrap; .mat-mdc-card { width: 450px; margin: 24px 24px 0 0; display: block; [dir='rtl'] :host & { margin: 24px 0 0 24px; } } .demo-drink-icon { vertical-align: bottom; padding-right: 0.25em; } .demo-drinks-width-large { width: 400px; } } .demo-card { margin: 30px 0; } .demo-narrow { max-width: 450px; .demo-narrow-sandwich { display: flex; gap: 16px; } }
{ "end_byte": 477, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/select/select-demo.scss" }
components/src/dev-app/select/BUILD.bazel_0_617
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "select", srcs = glob(["**/*.ts"]), assets = [ "select-demo.html", ":select_demo_scss", ], deps = [ "//src/material/button", "//src/material/card", "//src/material/checkbox", "//src/material/form-field", "//src/material/icon", "//src/material/input", "//src/material/select", "@npm//@angular/forms", ], ) sass_binary( name = "select_demo_scss", src = "select-demo.scss", )
{ "end_byte": 617, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/select/BUILD.bazel" }
components/src/dev-app/dev-app/dev-app-404.ts_0_690
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; import {RouterModule} from '@angular/router'; @Component({ template: ` <h1>404</h1> <p>This page does not exist</p> <a mat-raised-button routerLink="/">Go back to the home page</a> `, host: {'class': 'mat-typography'}, imports: [MatButtonModule, RouterModule], changeDetection: ChangeDetectionStrategy.OnPush, }) export class DevApp404 {}
{ "end_byte": 690, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/dev-app/dev-app-404.ts" }
components/src/dev-app/dev-app/dev-app-state.ts_0_2022
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Direction} from '@angular/cdk/bidi'; const KEY = 'MAT_DEV_APP_STATE'; /** State of the appearance of the dev app. */ export interface DevAppState { density: string | number; animations: boolean; zoneless: boolean; darkTheme: boolean; systemTheme: boolean; rippleDisabled: boolean; strongFocusEnabled: boolean; m3Enabled: boolean; direction: Direction; colorApiBackCompat: boolean; } /** Gets the current appearance state of the dev app. */ export function getAppState(): DevAppState { let value: DevAppState | null = null; // Needs a try/catch since some browsers throw an error when accessing in incognito. try { const storageValue = localStorage.getItem(KEY); if (storageValue) { value = JSON.parse(storageValue); } } catch {} if (!value) { value = { density: 0, animations: true, zoneless: false, darkTheme: false, systemTheme: false, rippleDisabled: false, strongFocusEnabled: false, m3Enabled: true, direction: 'ltr', colorApiBackCompat: true, }; saveToStorage(value); } return value; } /** Saves the state of the dev app apperance in local storage. */ export function setAppState(newState: DevAppState): void { const currentState = getAppState(); const keys = new Set([...Object.keys(currentState), ...Object.keys(newState)]) as Set< keyof DevAppState >; // Only write to storage if something actually changed. for (const key of keys) { if (currentState[key] !== newState[key]) { saveToStorage(newState); break; } } } function saveToStorage(value: DevAppState): void { // Needs a try/catch since some browsers throw an error when accessing in incognito. try { localStorage.setItem(KEY, JSON.stringify(value)); } catch {} }
{ "end_byte": 2022, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/dev-app/dev-app-state.ts" }
components/src/dev-app/dev-app/dev-app-layout.ts_0_1113
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Direction, Directionality} from '@angular/cdk/bidi'; import {DOCUMENT} from '@angular/common'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, NgZone, ViewEncapsulation, inject, ɵNoopNgZone, } from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; import {MatIconModule, MatIconRegistry} from '@angular/material/icon'; import {MatListModule} from '@angular/material/list'; import {MatSidenavModule} from '@angular/material/sidenav'; import {MatToolbarModule} from '@angular/material/toolbar'; import {MatTooltip, MatTooltipModule} from '@angular/material/tooltip'; import {RouterModule} from '@angular/router'; import {getAppState, setAppState} from './dev-app-state'; import {DevAppRippleOptions} from './ripple-options'; import {DevAppDirectionality} from './dev-app-directionality'; /** Root component for the dev-app demos. */
{ "end_byte": 1113, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/dev-app/dev-app-layout.ts" }
components/src/dev-app/dev-app/dev-app-layout.ts_1114_8134
Component({ selector: 'dev-app-layout', templateUrl: 'dev-app-layout.html', styleUrl: 'dev-app-layout.css', encapsulation: ViewEncapsulation.None, imports: [ MatButtonModule, MatIconModule, MatListModule, MatSidenavModule, MatToolbarModule, MatTooltipModule, RouterModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class DevAppLayout { private _element = inject<ElementRef<HTMLElement>>(ElementRef); private _rippleOptions = inject(DevAppRippleOptions); private _dir = inject(Directionality) as DevAppDirectionality; private _changeDetectorRef = inject(ChangeDetectorRef); private _document = inject(DOCUMENT); private _iconRegistry = inject(MatIconRegistry); state = getAppState(); navItems = [ {name: 'Examples', route: '/examples'}, {name: 'CDK Dialog', route: '/cdk-dialog'}, {name: 'CDK Experimental Combobox', route: '/cdk-experimental-combobox'}, {name: 'CDK Listbox', route: '/cdk-listbox'}, {name: 'CDK Menu', route: '/cdk-menu'}, {name: 'Autocomplete', route: '/autocomplete'}, {name: 'Badge', route: '/badge'}, {name: 'Bottom Sheet', route: '/bottom-sheet'}, {name: 'Button Toggle', route: '/button-toggle'}, {name: 'Button', route: '/button'}, {name: 'Card', route: '/card'}, {name: 'Checkbox', route: '/checkbox'}, {name: 'Chips', route: '/chips'}, {name: 'Clipboard', route: '/clipboard'}, {name: 'Column Resize', route: 'column-resize'}, {name: 'Connected Overlay', route: '/connected-overlay'}, {name: 'Datepicker', route: '/datepicker'}, {name: 'Dialog', route: '/dialog'}, {name: 'Drag and Drop', route: '/drag-drop'}, {name: 'Drawer', route: '/drawer'}, {name: 'Expansion Panel', route: '/expansion'}, {name: 'Focus Origin', route: '/focus-origin'}, {name: 'Focus Trap', route: '/focus-trap'}, {name: 'Google Map', route: '/google-map'}, {name: 'Grid List', route: '/grid-list'}, {name: 'Icon', route: '/icon'}, {name: 'Input Modality', route: '/input-modality'}, {name: 'Input', route: '/input'}, {name: 'Layout', route: '/layout'}, {name: 'List', route: '/list'}, {name: 'Live Announcer', route: '/live-announcer'}, {name: 'Menu', route: '/menu'}, {name: 'Menubar', route: '/menubar'}, {name: 'Paginator', route: '/paginator'}, {name: 'Platform', route: '/platform'}, {name: 'Popover Edit', route: '/popover-edit'}, {name: 'Portal', route: '/portal'}, {name: 'Progress Bar', route: '/progress-bar'}, {name: 'Progress Spinner', route: '/progress-spinner'}, {name: 'Radio', route: '/radio'}, {name: 'Ripple', route: '/ripple'}, {name: 'Screen Type', route: '/screen-type'}, {name: 'Select', route: '/select'}, {name: 'Selection', route: '/selection'}, {name: 'Sidenav', route: '/sidenav'}, {name: 'Slide Toggle', route: '/slide-toggle'}, {name: 'Slider', route: '/slider'}, {name: 'Snack Bar', route: '/snack-bar'}, {name: 'Stepper', route: '/stepper'}, {name: 'Table Scroll Container', route: '/table-scroll-container'}, {name: 'Table', route: '/table'}, {name: 'Tabs', route: '/tabs'}, {name: 'Theme', route: '/theme'}, {name: 'Timepicker', route: '/timepicker'}, {name: 'Toolbar', route: '/toolbar'}, {name: 'Tooltip', route: '/tooltip'}, {name: 'Tree', route: '/tree'}, {name: 'Typography', route: '/typography'}, {name: 'Virtual Scrolling', route: '/virtual-scroll'}, {name: 'YouTube Player', route: '/youtube-player'}, ]; /** List of possible global density scale values. */ private _densityScales = [0, -1, -2, -3, -4, 'minimum', 'maximum']; private _ngZone = inject(NgZone); readonly isZoneless = this._ngZone instanceof ɵNoopNgZone; constructor() { this.toggleTheme(this.state.darkTheme); this.toggleSystemTheme(this.state.systemTheme); this.toggleStrongFocus(this.state.strongFocusEnabled); this.toggleDensity(Math.max(this._densityScales.indexOf(this.state.density), 0)); this.toggleRippleDisabled(this.state.rippleDisabled); this.toggleDirection(this.state.direction); this.toggleM3(this.state.m3Enabled); this.toggleColorApiBackCompat(this.state.colorApiBackCompat); } toggleTheme(value = !this.state.darkTheme) { this.state.darkTheme = value; this._document.body.classList.toggle('demo-unicorn-dark-theme', value); setAppState(this.state); } toggleSystemTheme(value = !this.state.systemTheme) { this.state.systemTheme = value; this._document.body.classList.toggle('demo-experimental-theme', value); setAppState(this.state); } toggleFullscreen() { this._element.nativeElement.querySelector('.demo-content')?.requestFullscreen(); } toggleStrongFocus(value = !this.state.strongFocusEnabled) { this.state.strongFocusEnabled = value; this._document.body.classList.toggle('demo-strong-focus', value); setAppState(this.state); } toggleZoneless(value = !this.isZoneless) { this.state.zoneless = value; setAppState(this.state); location.reload(); } toggleAnimations() { this.state.animations = !this.state.animations; setAppState(this.state); location.reload(); } toggleDensity(index?: number, tooltipInstance?: MatTooltip) { if (index == null) { index = (this._densityScales.indexOf(this.state.density) + 1) % this._densityScales.length; } this.state.density = this._densityScales[index]; setAppState(this.state); // Keep the tooltip open so we can see what the density was changed to. Ideally we'd // always show the density in a badge, but the M2 badge is too large for the toolbar. if (tooltipInstance) { requestAnimationFrame(() => tooltipInstance.show(0)); } } toggleRippleDisabled(value = !this.state.rippleDisabled) { this._rippleOptions.disabled = this.state.rippleDisabled = value; setAppState(this.state); } toggleDirection(value: Direction = this.state.direction === 'ltr' ? 'rtl' : 'ltr') { if (value !== this._dir.value) { this._dir.value = this.state.direction = value; this._changeDetectorRef.markForCheck(); setAppState(this.state); } } toggleM3(value = !this.state.m3Enabled) { // We need to diff this one since it's a bit more expensive to toggle. if (value !== this.state.m3Enabled) { (document.getElementById('theme-styles') as HTMLLinkElement).href = value ? 'theme-m3.css' : 'theme.css'; } this._iconRegistry.setDefaultFontSetClass( value ? 'material-symbols-outlined' : 'material-icons', ); this.state.m3Enabled = value; setAppState(this.state); } toggleColorApiBackCompat(value = !this.state.colorApiBackCompat) { this.state.colorApiBackCompat = value; this._document.body.classList.toggle('demo-color-api-back-compat', value); setAppState(this.state); } getDensityClass() { return `demo-density-${this.state.density}`; } }
{ "end_byte": 8134, "start_byte": 1114, "url": "https://github.com/angular/components/blob/main/src/dev-app/dev-app/dev-app-layout.ts" }
components/src/dev-app/dev-app/dev-app-home.ts_0_568
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ /** Home component which includes a welcome message for the dev-app. */ import {ChangeDetectionStrategy, Component} from '@angular/core'; @Component({ template: ` <p>Welcome to the development demos for Angular Material!</p> <p>Open the sidenav to select a demo.</p> `, changeDetection: ChangeDetectionStrategy.OnPush, }) export class DevAppHome {}
{ "end_byte": 568, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/dev-app/dev-app-home.ts" }
components/src/dev-app/dev-app/dev-app-layout.html_0_5757
<mat-sidenav-container class="demo-container"> <mat-sidenav #navigation role="navigation"> <mat-nav-list class="demo-nav-list"> @for (navItem of navItems; track navItem) { <a mat-list-item (click)="navigation.close()" routerLinkActive #routerLinkActiveInstance="routerLinkActive" [attr.tabindex]="routerLinkActiveInstance.isActive ? 0 : -1" [routerLink]="[navItem.route]" >{{navItem.name}}</a > } <mat-divider></mat-divider> <a mat-list-item tabindex="-1" (click)="navigation.close()" [routerLink]="['/baseline']"> Baseline </a> <a mat-list-item tabindex="-1" (click)="navigation.close()" [routerLink]="['/performance']"> Performance </a> </mat-nav-list> <button mat-button tabindex="-1" (click)="navigation.close()">CLOSE</button> </mat-sidenav> <!-- Note that the setup with the directionality and density is a little convoluted, but it's organized this way so that we can test MDC's density styles in both LTR and RTL. Their mixins output styles in the form of `[dir='rtl'] .density-min .foo` which means that the `dir` has to be one level above the density class in the DOM. At the same time, we want the density to apply to the toolbar while always keeping it in LTR at the same time. --> <main [attr.dir]="state.direction" [class]="getDensityClass()" class="demo-main"> <!-- The toolbar should always be in the LTR direction --> <mat-toolbar color="primary" dir="ltr"> <button mat-icon-button (click)="navigation.open('mouse')"> <mat-icon>menu</mat-icon> </button> <div class="demo-toolbar"> <h1>Angular Material Demos</h1> <div class="demo-config-buttons"> @if (state.m3Enabled) { <button mat-icon-button (click)="toggleColorApiBackCompat()" matTooltip="{{state.colorApiBackCompat ? 'Disable' : 'Enable'}} color API back-compat" > <mat-icon>colorize</mat-icon> </button> } <button mat-icon-button (click)="toggleFullscreen()" matTooltip="Toggle fullscreen"> <mat-icon>fullscreen</mat-icon> </button> <button mat-icon-button (click)="toggleM3()" [matTooltip]="state.m3Enabled ? 'Use M2 theme' : 'Use M3 theme'" > @if (state.m3Enabled) { <mat-icon>invert_colors_off</mat-icon> } @else { <mat-icon>invert_colors</mat-icon> } </button> <button mat-icon-button (click)="toggleZoneless()" [matTooltip]="isZoneless ? 'Use zones' : 'Use zoneless'" > @if (isZoneless) { <mat-icon>visibility</mat-icon> } @else { <mat-icon>visibility_off</mat-icon> } </button> <button mat-icon-button (click)="toggleAnimations()" [matTooltip]="state.animations ? 'Disable animations' : 'Enable animations'" > @if (state.animations) { <mat-icon>pause_circle</mat-icon> } @else { <mat-icon>animation</mat-icon> } </button> <button mat-icon-button (click)="toggleTheme()" [matTooltip]="state.darkTheme ? 'Switch to light theme' : 'Switch to dark theme'" > @if (state.darkTheme) { <mat-icon>light_mode</mat-icon> } @else { <mat-icon>dark_mode</mat-icon> } </button> <button mat-icon-button (click)="toggleSystemTheme()" [matTooltip]="state.systemTheme ? 'Switch to standard theme' : 'Switch to system theme'" > @if (state.systemTheme) { <mat-icon>public_off</mat-icon> } @else { <mat-icon>public</mat-icon> } </button> <button mat-icon-button (click)="toggleRippleDisabled()" [matTooltip]="state.rippleDisabled ? 'Enable ripples' : 'Disable ripples'" > @if (state.rippleDisabled) { <mat-icon>waves</mat-icon> } @else { <mat-icon>water</mat-icon> } </button> <button mat-icon-button (click)="toggleStrongFocus()" [matTooltip]="state.strongFocusEnabled ? 'Disable strong focus' : 'Enable strong focus'" > @if (state.strongFocusEnabled) { <mat-icon>not_accessible</mat-icon> } @else { <mat-icon>accessibility</mat-icon> } </button> <button mat-icon-button (click)="toggleDirection()" [matTooltip]="state.direction === 'rtl' ? 'Switch to LTR' : 'Switch to RTL'" > @if (state.direction === 'rtl') { <mat-icon>west</mat-icon> } @else { <mat-icon>east</mat-icon> } </button> <button #densityTooltip="matTooltip" mat-icon-button (click)="toggleDensity(undefined, densityTooltip)" [matTooltip]="'Density: ' + state.density" > <mat-icon>grid_on</mat-icon> </button> </div> </div> </mat-toolbar> <div [class]="getDensityClass()" class="demo-content mat-app-background"> <ng-content></ng-content> </div> </main> </mat-sidenav-container>
{ "end_byte": 5757, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/dev-app/dev-app-layout.html" }
components/src/dev-app/dev-app/dev-app-layout.scss_0_1235
html, body { width: 100%; height: 100%; } body { font-family: Roboto, 'Helvetica Neue', sans-serif; margin: 0; // Helps fonts on OSX looks more consistent with other systems // Isn't currently in button styles due to performance concerns * { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .mat-sidenav { position: fixed; .mat-mdc-button { width: 100%; position: relative; bottom: 0; margin: 24px 0; } } .demo-content { padding: 32px; box-sizing: border-box; } .mat-toolbar { .mat-icon { cursor: pointer; } .demo-toolbar { display: flex; justify-content: space-between; align-items: center; width: 100%; // Avoids horizontal scrollbars on smaller screens. overflow: hidden; } } h1 { font-size: 20px; } } // stretch to screen size in fullscreen mode .demo-content { width: 100%; height: 100%; box-sizing: border-box; overflow: auto; } .demo-container { min-width: 100%; min-height: 100%; } .demo-main { // Removes extra space on top of toolbar on IE. display: block; } .demo-config-buttons { display: flex; align-items: center; }
{ "end_byte": 1235, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/dev-app/dev-app-layout.scss" }
components/src/dev-app/dev-app/BUILD.bazel_0_682
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "dev-app", srcs = glob(["**/*.ts"]), assets = [ "dev-app-layout.html", ":dev_app_layout_scss", ], deps = [ "//src/cdk/bidi", "//src/cdk/overlay", "//src/material/button", "//src/material/core", "//src/material/icon", "//src/material/list", "//src/material/sidenav", "//src/material/toolbar", "//src/material/tooltip", "@npm//@angular/router", ], ) sass_binary( name = "dev_app_layout_scss", src = "dev-app-layout.scss", )
{ "end_byte": 682, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/dev-app/BUILD.bazel" }
components/src/dev-app/dev-app/dev-app-directionality.ts_0_707
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Direction, Directionality} from '@angular/cdk/bidi'; import {EventEmitter, Injectable, OnDestroy} from '@angular/core'; @Injectable() export class DevAppDirectionality implements Directionality, OnDestroy { readonly change = new EventEmitter<Direction>(); get value(): Direction { return this._value; } set value(value: Direction) { this._value = value; this.change.next(value); } private _value: Direction = 'ltr'; ngOnDestroy() { this.change.complete(); } }
{ "end_byte": 707, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/dev-app/dev-app-directionality.ts" }
components/src/dev-app/dev-app/ripple-options.ts_0_628
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Injectable} from '@angular/core'; import {RippleGlobalOptions} from '@angular/material/core'; /** * Global ripple options for the dev-app. The ripple options are used as a class * so that the global options can be changed at runtime. */ @Injectable({providedIn: 'root'}) export class DevAppRippleOptions implements RippleGlobalOptions { /** Whether ripples should be disabled */ disabled: boolean = false; }
{ "end_byte": 628, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/dev-app/ripple-options.ts" }
components/src/dev-app/google-map/google-map-demo.scss_0_57
.demo-google-map { label { font-weight: 500; } }
{ "end_byte": 57, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/google-map/google-map-demo.scss" }
components/src/dev-app/google-map/google-map-demo.html_0_7247
@if (hasLoaded) { <div class="demo-google-map"> <google-map height="400px" width="750px" [center]="center" [zoom]="zoom" (authFailure)="authFailure()" (mapClick)="handleClick($event)" (mapMousemove)="handleMove($event)" (mapRightclick)="handleRightclick()" [mapTypeId]="mapTypeId" [mapId]="mapId"> <map-marker-clusterer> <map-advanced-marker #firstMarker="mapAdvancedMarker" [position]="center" (mapClick)="infoWindow.open(firstMarker)"></map-advanced-marker> @for (markerPosition of markerPositions; track markerPosition) { <map-advanced-marker #marker="mapAdvancedMarker" [position]="markerPosition" (mapClick)="infoWindow.open(marker)"></map-advanced-marker> } </map-marker-clusterer> @if (hasCustomContentMarker) { <map-advanced-marker #secondMarker="mapAdvancedMarker" (mapClick)="infoWindow.open(secondMarker)" title="Advanced Marker" [gmpDraggable]="false" [content]="advancedMarkerContent" [position]="mapAdvancedMarkerPosition"> <svg #advancedMarkerContent fill="oklch(69.02% .277 332.77)" viewBox="0 0 960 960" width="50px" height="50px" xml:space="preserve"> <g> <polygon points="562.6,109.8 804.1,629.5 829.2,233.1"/> <polygon points="624.9,655.9 334.3,655.9 297.2,745.8 479.6,849.8 662,745.8"/> <polygon points="384.1,539.3 575.2,539.3 479.6,307"/> <polygon points="396.6,109.8 130,233.1 155.1,629.5"/> </g> </svg> </map-advanced-marker> } <map-info-window #infoWindow="mapInfoWindow">Testing 1 2 3</map-info-window> @if (isPolylineDisplayed) { <map-polyline [options]="polylineOptions"></map-polyline> } @if (isPolygonDisplayed) { <map-polygon [options]="polygonOptions"></map-polygon> } @if (isRectangleDisplayed) { <map-rectangle [options]="rectangleOptions"></map-rectangle> } @if (isCircleDisplayed) { <map-circle [options]="circleOptions"></map-circle> } @if (isGroundOverlayDisplayed) { <map-ground-overlay [url]="groundOverlayUrl" [bounds]="groundOverlayBounds"></map-ground-overlay> } @if (isKmlLayerDisplayed) { <map-kml-layer [url]="demoKml"></map-kml-layer> } @if (isTrafficLayerDisplayed) { <map-traffic-layer></map-traffic-layer> } @if (isTransitLayerDisplayed) { <map-transit-layer></map-transit-layer> } @if (isBicyclingLayerDisplayed) { <map-bicycling-layer></map-bicycling-layer> } @if (directionsResult) { <map-directions-renderer [directions]="directionsResult"></map-directions-renderer> } @if (isHeatmapDisplayed) { <map-heatmap-layer [data]="heatmapData" [options]="heatmapOptions"></map-heatmap-layer> } </google-map> <p><label>Latitude:</label> {{display?.lat}}</p> <p><label>Longitude:</label> {{display?.lng}}</p> <div> <label for="map-type"> Select map type <select id="map-type" (change)="mapTypeChanged($event)" #mapType> @for (type of mapTypeIds; track type) { <option [value]="type">{{type}}</option> } </select> </label> </div> <div> <label for="polyline-checkbox"> Toggle Polyline <input type="checkbox" [(ngModel)]="isPolylineDisplayed"> </label> </div> <div> <label for="editable-polyline-checkbox"> Toggle Editable Polyline <input type="checkbox" [disabled]="!isPolylineDisplayed" [ngModel]="polylineOptions.editable" (ngModelChange)="editablePolylineChanged($event)"> </label> </div> <div> <label for="polygon-checkbox"> Toggle Polygon <input type="checkbox" [(ngModel)]="isPolygonDisplayed"> </label> </div> <div> <label for="editable-polygon-checkbox"> Toggle Editable Polygon <input type="checkbox" [disabled]="!isPolygonDisplayed" [ngModel]="polygonOptions.editable" (ngModelChange)="editablePolygonChanged($event)"> </label> </div> <div> <label for="rectangle-checkbox"> Toggle Rectangle <input type="checkbox" [(ngModel)]="isRectangleDisplayed"> </label> </div> <div> <label for="editable-rectangle-checkbox"> Toggle Editable Rectangle <input type="checkbox" [disabled]="!isRectangleDisplayed" [ngModel]="rectangleOptions.editable" (ngModelChange)="editableRectangleChanged($event)"> </label> </div> <div> <label for="circle-checkbox"> Toggle Circle <input type="checkbox" [(ngModel)]="isCircleDisplayed"> </label> </div> <div> <label for="editable-circle-checkbox"> Toggle Editable Circle <input type="checkbox" [disabled]="!isCircleDisplayed" [ngModel]="circleOptions.editable" (ngModelChange)="editableCircleChanged($event)"> </label> </div> <div> <label for="ground-overlay-checkbox"> Toggle Ground Overlay <input type="checkbox" [(ngModel)]="isGroundOverlayDisplayed"> </label> </div> <div> <label for="ground-overlay-image"> Ground Overlay image <select id="ground-overlay-image" [(ngModel)]="groundOverlayUrl"> @for (image of groundOverlayImages; track image) { <option [value]="image.url">{{image.title}}</option> } </select> </label> </div> <div> <label for="kml-layer-checkbox"> Toggle KML Layer <input type="checkbox" [(ngModel)]="isKmlLayerDisplayed"> </label> </div> <div> <label for="traffic-layer-checkbox"> Toggle Traffic Layer <input type="checkbox" [(ngModel)]="isTrafficLayerDisplayed"> </label> </div> <div> <label for="transit-layer-checkbox"> Toggle Transit Layer <input type="checkbox" [(ngModel)]="isTransitLayerDisplayed"> </label> </div> <div> <label for="bicycling-layer-checkbox"> Toggle Bicycling Layer <input type="checkbox" [(ngModel)]="isBicyclingLayerDisplayed"> </label> </div> <div> <label for="heatmap-layer-checkbox"> Toggle Heatmap Layer <input type="checkbox" (click)="toggleHeatmapLayerDisplay()"> </label> </div> <div> <label> Toggle Advanced Marker with custom content <input type="checkbox" [(ngModel)]="hasCustomContentMarker"> </label> </div> <div> <button mat-button (click)="calculateDirections()"> Calculate directions between first two markers </button> </div> </div> } @else { <div>Loading Google Maps API...</div> }
{ "end_byte": 7247, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/google-map/google-map-demo.html" }
components/src/dev-app/google-map/google-map-demo.ts_0_7037
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ViewChild, inject, } from '@angular/core'; import {FormsModule} from '@angular/forms'; import { GoogleMap, MapAdvancedMarker, MapBicyclingLayer, MapCircle, MapDirectionsRenderer, MapDirectionsService, MapGroundOverlay, MapHeatmapLayer, MapInfoWindow, MapKmlLayer, MapPolygon, MapPolyline, MapRectangle, MapTrafficLayer, MapTransitLayer, MapMarkerClusterer, } from '@angular/google-maps'; const POLYLINE_PATH: google.maps.LatLngLiteral[] = [ {lat: 25, lng: 26}, {lat: 26, lng: 27}, {lat: 30, lng: 34}, ]; const POLYGON_PATH: google.maps.LatLngLiteral[] = [ {lat: 20, lng: 21}, {lat: 22, lng: 23}, {lat: 24, lng: 25}, ]; const RECTANGLE_BOUNDS: google.maps.LatLngBoundsLiteral = { east: 30, north: 15, west: 10, south: -5, }; const CIRCLE_CENTER: google.maps.LatLngLiteral = { lat: 19, lng: 20, }; const CIRCLE_RADIUS = 500000; let apiLoadingPromise: Promise<unknown> | null = null; /** Demo Component for @angular/google-maps/map */ @Component({ selector: 'google-map-demo', templateUrl: 'google-map-demo.html', styleUrl: 'google-map-demo.css', imports: [ GoogleMap, MapBicyclingLayer, MapCircle, MapDirectionsRenderer, MapGroundOverlay, MapHeatmapLayer, MapInfoWindow, MapKmlLayer, MapMarkerClusterer, MapAdvancedMarker, MapPolygon, MapPolyline, MapRectangle, MapTrafficLayer, MapTransitLayer, FormsModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class GoogleMapDemo { private readonly _mapDirectionsService = inject(MapDirectionsService); @ViewChild(MapPolyline) polyline: MapPolyline; @ViewChild(MapPolygon) polygon: MapPolygon; @ViewChild(MapRectangle) rectangle: MapRectangle; @ViewChild(MapCircle) circle: MapCircle; readonly cdr = inject(ChangeDetectorRef); center = {lat: 24, lng: 12}; mapAdvancedMarkerPosition = {lat: 22, lng: 21}; markerPositions: google.maps.LatLngLiteral[] = []; zoom = 4; display?: google.maps.LatLngLiteral; isPolylineDisplayed = false; polylineOptions: google.maps.PolylineOptions = { path: POLYLINE_PATH, strokeColor: 'grey', strokeOpacity: 0.8, }; heatmapData = this._getHeatmapData(5, 1); heatmapOptions = {radius: 50}; isHeatmapDisplayed = false; isPolygonDisplayed = false; polygonOptions: google.maps.PolygonOptions = { paths: POLYGON_PATH, strokeColor: 'grey', strokeOpacity: 0.8, }; isRectangleDisplayed = false; rectangleOptions: google.maps.RectangleOptions = { bounds: RECTANGLE_BOUNDS, strokeColor: 'grey', strokeOpacity: 0.8, }; isCircleDisplayed = false; circleOptions: google.maps.CircleOptions = { center: CIRCLE_CENTER, radius: CIRCLE_RADIUS, strokeColor: 'grey', strokeOpacity: 0.8, }; isGroundOverlayDisplayed = false; hasLoaded = false; groundOverlayImages = [ { title: 'Red logo', url: 'https://angular.io/assets/images/logos/angular/angular.svg', }, { title: 'Black logo', url: 'https://angular.io/assets/images/logos/angular/angular_solidBlack.svg', }, ]; groundOverlayUrl = this.groundOverlayImages[0].url; groundOverlayBounds = RECTANGLE_BOUNDS; isKmlLayerDisplayed = false; demoKml = 'https://developers.google.com/maps/documentation/javascript/examples/kml/westcampus.kml'; isTrafficLayerDisplayed = false; isTransitLayerDisplayed = false; isBicyclingLayerDisplayed = false; hasCustomContentMarker = false; // This is necessary for testing advanced markers. It seems like any value works locally. mapId = '123'; mapTypeId: google.maps.MapTypeId; mapTypeIds = ['hybrid', 'roadmap', 'satellite', 'terrain'] as google.maps.MapTypeId[]; directionsResult?: google.maps.DirectionsResult; constructor() { this._loadApi(); } authFailure() { console.log('Auth failure event emitted'); } handleClick(event: google.maps.MapMouseEvent) { if (event.latLng) { this.markerPositions.push(event.latLng.toJSON()); } } handleMove(event: google.maps.MapMouseEvent) { this.display = event.latLng?.toJSON(); } handleRightclick() { this.markerPositions.pop(); } editablePolylineChanged(editable: boolean) { this.polylineOptions = { ...this.polylineOptions, editable, path: this.polyline.getPath(), }; } editablePolygonChanged(editable: boolean) { this.polygonOptions = { ...this.polygonOptions, editable, paths: this.polygon.getPaths(), }; } editableRectangleChanged(editable: boolean) { this.rectangleOptions = { ...this.rectangleOptions, editable, bounds: this.rectangle.getBounds(), }; } editableCircleChanged(editable: boolean) { this.circleOptions = { ...this.circleOptions, editable, center: this.circle.getCenter(), radius: this.circle.getRadius(), }; } mapTypeChanged(event: Event) { this.mapTypeId = (event.target as HTMLSelectElement).value as unknown as google.maps.MapTypeId; } calculateDirections() { if (this.markerPositions.length >= 2) { const request: google.maps.DirectionsRequest = { destination: this.markerPositions[1], origin: this.markerPositions[0], travelMode: google.maps.TravelMode.DRIVING, }; this._mapDirectionsService.route(request).subscribe(response => { this.directionsResult = response.result; this.cdr.markForCheck(); }); } } toggleHeatmapLayerDisplay() { this.isHeatmapDisplayed = !this.isHeatmapDisplayed; } private _getHeatmapData(offset: number, increment: number) { const result: google.maps.LatLngLiteral[] = []; for (let lat = this.center.lat - offset; lat < this.center.lat + offset; lat += increment) { for (let lng = this.center.lng - offset; lng < this.center.lng + offset; lng += increment) { result.push({lat, lng}); } } return result; } private _loadApi() { if (this.hasLoaded) { return; } if (!apiLoadingPromise) { apiLoadingPromise = this._loadScript( 'https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js', ); } apiLoadingPromise.then( () => { this.hasLoaded = true; this.cdr.markForCheck(); }, error => console.error('Failed to load Google Maps API', error), ); } private _loadScript(url: string): Promise<unknown> { return new Promise((resolve, reject) => { const script = document.createElement('script'); script.src = url; script.addEventListener('load', resolve); script.addEventListener('error', reject); document.body.appendChild(script); }); } }
{ "end_byte": 7037, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/google-map/google-map-demo.ts" }
components/src/dev-app/google-map/BUILD.bazel_0_434
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "google-map", srcs = glob(["**/*.ts"]), assets = [ "google-map-demo.html", ":google_map_demo_scss", ], deps = [ "//src/google-maps", "@npm//@angular/forms", ], ) sass_binary( name = "google_map_demo_scss", src = "google-map-demo.scss", )
{ "end_byte": 434, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/google-map/BUILD.bazel" }
components/src/dev-app/icon/icon-demo.html_0_2061
<div class="demo-icon"> <p> These are some icons. </p> <p> By name registered with MatIconProvider: <mat-icon svgIcon="thumb-up" class="demo-icon-green"></mat-icon> <mat-icon svgIcon="thumb-up"></mat-icon> </p> <p> From inline template with MatIconProvider: <mat-icon svgIcon="bike" class="green"></mat-icon> <mat-icon svgIcon="bike"></mat-icon> </p> <p> Mirrored in RTL: <mat-icon class="mat-icon-rtl-mirror green" svgIcon="thumb-up"></mat-icon> <mat-icon class="mat-icon-rtl-mirror" svgIcon="thumb-up"></mat-icon> <mat-icon class="mat-icon-rtl-mirror green" svgIcon="bike"></mat-icon> <mat-icon class="mat-icon-rtl-mirror" svgIcon="bike"></mat-icon> </p> <p> From icon set: <mat-icon svgIcon="core:alarm"></mat-icon> <mat-icon svgIcon="core:accessibility"></mat-icon> <mat-icon svgIcon="core:alarm"></mat-icon> </p> <p> From inline icon set: <mat-icon svgIcon="core-inline:account-balance"></mat-icon> <mat-icon svgIcon="core-inline:account-balance-wallet"></mat-icon> <mat-icon svgIcon="core-inline:account-box"></mat-icon> </p> <p> Ligature from Material Icons font by attribute: <mat-icon fontIcon="home"></mat-icon> </p> <p> Ligature from Material Icons font by content: <mat-icon>home</mat-icon> </p> <p> Using a theme: <mat-icon color="primary">home</mat-icon> <mat-icon color="accent">home</mat-icon> <mat-icon color="warn">home</mat-icon> </p> <p> Custom icon font and CSS: <mat-icon fontSet="fontawesome" fontIcon="fa-birthday-cake"></mat-icon> </p> <span>Inline styling allows icons to appear as the same size as text around them.</span> <p> My <span class="cdk-visually-hidden">dog</span><mat-icon inline="true">pets</mat-icon> is my <span class="cdk-visually-hidden">favorite</span><mat-icon inline="true">favorite</mat-icon>, he loves to go on <span class="cdk-visually-hidden">walks</span> <mat-icon inline="true">directions_walk</mat-icon> </p> </div>
{ "end_byte": 2061, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/icon/icon-demo.html" }
components/src/dev-app/icon/icon-demo.scss_0_57
.demo-icon .mat-icon.demo-icon-green { color: green; }
{ "end_byte": 57, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/icon/icon-demo.scss" }
components/src/dev-app/icon/icon-demo.ts_0_2731
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; import {MatIconModule, MatIconRegistry} from '@angular/material/icon'; import {DomSanitizer} from '@angular/platform-browser'; @Component({ selector: 'mat-icon-demo', templateUrl: 'icon-demo.html', styleUrl: 'icon-demo.css', imports: [MatIconModule], changeDetection: ChangeDetectionStrategy.OnPush, }) export class IconDemo { constructor() { const iconRegistry = inject(MatIconRegistry); const sanitizer = inject(DomSanitizer); iconRegistry .addSvgIcon( 'thumb-up', sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/thumbup-icon.svg'), ) .addSvgIconLiteral('bike', sanitizer.bypassSecurityTrustHtml(BIKE_ICON)) .addSvgIconSetInNamespace( 'core', sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/core-icon-set.svg'), ) .addSvgIconSetLiteralInNamespace( 'core-inline', sanitizer.bypassSecurityTrustHtml(INLINE_ICON_SET), ) .registerFontClassAlias('fontawesome', 'fa'); } } const BIKE_ICON = ` <svg xmlns="http://www.w3.org/2000/svg"> <path d="M0 0h24v24H0z" fill="none"/> <path d="M15.5 5.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM5 12c-2.8 0-5 2.2-5 ` + `5s2.2 5 5 5 5-2.2 5-5-2.2-5-5-5zm0 8.5c-1.9 0-3.5-1.6-3.5-3.5s1.6-3.5 3.5-3.5 3.5 ` + `1.6 3.5 3.5-1.6 3.5-3.5 3.5zm5.8-10l2.4-2.4.8.8c1.3 1.3 3 2.1 5.1 2.1V9c-1.5 ` + `0-2.7-.6-3.6-1.5l-1.9-1.9c-.5-.4-1-.6-1.6-.6s-1.1.2-1.4.6L7.8 8.4c-.4.4-.6.9-.6 ` + `1.4 0 .6.2 1.1.6 1.4L11 14v5h2v-6.2l-2.2-2.3zM19 12c-2.8 0-5 2.2-5 5s2.2 5 5 5 5-2.2 ` + `5-5-2.2-5-5-5zm0 8.5c-1.9 0-3.5-1.6-3.5-3.5s1.6-3.5 3.5-3.5 3.5 1.6 3.5 3.5-1.6 ` + `3.5-3.5 3.5z"/> </svg> `; const INLINE_ICON_SET = ` <svg> <defs> <svg id="account-balance"> <path d="M4 10v7h3v-7H4zm6 0v7h3v-7h-3zM2 22h19v-3H2v3zm14-12v7h3v-` + `7h-3zm-4.5-9L2 6v2h19V6l-9.5-5z"/> </svg> <svg id="account-balance-wallet"> <path d="M21 18v1c0 1.1-.9 2-2 2H5c-1.11 0-2-.9-2-2V5c0-1.1.89-2 2-` + `2h14c1.1 0 2 .9 2 2v1h-9c-1.11 0-2 .9-2 2v8c0 1.1.89 2 2 2h9zm-9` + `-2h10V8H12v8zm4-2.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z" /> </svg> <svg id="account-box"> <path d="M3 5v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H` + `5c-1.11 0-2 .9-2 2zm12 4c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-` + `3 3 1.34 3 3zm-9 8c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6v-1z"/> </svg> </defs> </svg> `;
{ "end_byte": 2731, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/icon/icon-demo.ts" }
components/src/dev-app/icon/BUILD.bazel_0_453
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "icon", srcs = glob(["**/*.ts"]), assets = [ "icon-demo.html", ":icon_demo_scss", ], deps = [ "//src/material/icon", ], ) sass_binary( name = "icon_demo_scss", src = "icon-demo.scss", ) filegroup( name = "icon_demo_assets", srcs = glob(["assets/**/*"]), )
{ "end_byte": 453, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/icon/BUILD.bazel" }
components/src/dev-app/icon/assets/thumbup-icon.svg_0_351
<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px"> <path d="M0 0h24v24H0z" fill="none"/> <path d="M1 21h4V9H1v12zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-1.91l-.01-.01L23 10z"/> </svg>
{ "end_byte": 351, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/icon/assets/thumbup-icon.svg" }
components/src/dev-app/icon/assets/search-icon.svg_0_341
<svg xmlns="http://www.w3.org/2000/svg"> <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/> <path d="M0 0h24v24H0z" fill="none"/> </svg>
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/icon/assets/search-icon.svg" }
components/src/dev-app/icon/assets/core-icon-set.svg_0_3055
<svg> <defs> <svg id="3d-rotation"> <path d="M7.52 21.48C4.25 19.94 1.91 16.76 1.55 13H.05C.56 19.16 5.71 24 12 24l.66-.03-3.81-3.81-1.33 1.32zm.89-6.52c-.19 0-.37-.03-.52-.08-.16-.06-.29-.13-.4-.24-.11-.1-.2-.22-.26-.37-.06-.14-.09-.3-.09-.47h-1.3c0 .36.07.68.21.95.14.27.33.5.56.69.24.18.51.32.82.41.3.1.62.15.96.15.37 0 .72-.05 1.03-.15.32-.1.6-.25.83-.44s.42-.43.55-.72c.13-.29.2-.61.2-.97 0-.19-.02-.38-.07-.56-.05-.18-.12-.35-.23-.51-.1-.16-.24-.3-.4-.43-.17-.13-.37-.23-.61-.31.2-.09.37-.2.52-.33.15-.13.27-.27.37-.42.1-.15.17-.3.22-.46.05-.16.07-.32.07-.48 0-.36-.06-.68-.18-.96-.12-.28-.29-.51-.51-.69-.2-.19-.47-.33-.77-.43C9.1 8.05 8.76 8 8.39 8c-.36 0-.69.05-1 .16-.3.11-.57.26-.79.45-.21.19-.38.41-.51.67-.12.26-.18.54-.18.85h1.3c0-.17.03-.32.09-.45s.14-.25.25-.34c.11-.09.23-.17.38-.22.15-.05.3-.08.48-.08.4 0 .7.1.89.31.19.2.29.49.29.86 0 .18-.03.34-.08.49-.05.15-.14.27-.25.37-.11.1-.25.18-.41.24-.16.06-.36.09-.58.09H7.5v1.03h.77c.22 0 .42.02.6.07s.33.13.45.23c.12.11.22.24.29.4.07.16.1.35.1.57 0 .41-.12.72-.35.93-.23.23-.55.33-.95.33zm8.55-5.92c-.32-.33-.7-.59-1.14-.77-.43-.18-.92-.27-1.46-.27H12v8h2.3c.55 0 1.06-.09 1.51-.27.45-.18.84-.43 1.16-.76.32-.33.57-.73.74-1.19.17-.47.26-.99.26-1.57v-.4c0-.58-.09-1.1-.26-1.57-.18-.47-.43-.87-.75-1.2zm-.39 3.16c0 .42-.05.79-.14 1.13-.1.33-.24.62-.43.85-.19.23-.43.41-.71.53-.29.12-.62.18-.99.18h-.91V9.12h.97c.72 0 1.27.23 1.64.69.38.46.57 1.12.57 1.99v.4zM12 0l-.66.03 3.81 3.81 1.33-1.33c3.27 1.55 5.61 4.72 5.96 8.48h1.5C23.44 4.84 18.29 0 12 0z" /> </svg> <svg id="accessibility"> <path d="M12 2c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm9 7h-6v13h-2v-6h-2v6H9V9H3V7h18v2z" /> </svg> <svg id="account-balance"> <path d="M4 10v7h3v-7H4zm6 0v7h3v-7h-3zM2 22h19v-3H2v3zm14-12v7h3v-7h-3zm-4.5-9L2 6v2h19V6l-9.5-5z" /> </svg> <svg id="account-balance-wallet"> <path d="M21 18v1c0 1.1-.9 2-2 2H5c-1.11 0-2-.9-2-2V5c0-1.1.89-2 2-2h14c1.1 0 2 .9 2 2v1h-9c-1.11 0-2 .9-2 2v8c0 1.1.89 2 2 2h9zm-9-2h10V8H12v8zm4-2.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z" /> </svg> <svg id="account-box"> <path d="M3 5v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2 2zm12 4c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3zm-9 8c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6v-1z" /> </svg> <svg id="account-child"> <circle cx="12" cy="13.49" r="1.5" /> <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 2.5c1.24 0 2.25 1.01 2.25 2.25S13.24 9 12 9 9.75 7.99 9.75 6.75 10.76 4.5 12 4.5zm5 10.56v2.5c-.45.41-.96.77-1.5 1.05v-.68c0-.34-.17-.65-.46-.92-.65-.62-1.89-1.02-3.04-1.02-.96 0-1.96.28-2.65.73l-.17.12-.21.17c.78.47 1.63.72 2.54.82l1.33.15c.37.04.66.36.66.75 0 .29-.16.53-.4.66-.28.15-.64.09-.95.09-.35 0-.69-.01-1.03-.05-.5-.06-.99-.17-1.46-.33-.49-.16-.97-.38-1.42-.64-.22-.13-.44-.27-.65-.43l-.31-.24c-.04-.02-.28-.18-.28-.23v-4.28c0-1.58 2.63-2.78 5-2.78s5 1.2 5 2.78v1.78z" /> </svg> <svg id="account-circle">
{ "end_byte": 3055, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/icon/assets/core-icon-set.svg" }
components/src/dev-app/icon/assets/core-icon-set.svg_3056_5619
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z" /> </svg> <svg id="add"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" /> </svg> <svg id="add-box"> <path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4v2z" /> </svg> <svg id="add-circle"> <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11h-4v4h-2v-4H7v-2h4V7h2v4h4v2z" /> </svg> <svg id="add-circle-outline"> <path d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z" /> </svg> <svg id="add-shopping-cart"> <path d="M11 9h2V6h3V4h-3V1h-2v3H8v2h3v3zm-4 9c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zm10 0c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2zm-9.83-3.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.86-7.01L19.42 4h-.01l-1.1 2-2.76 5H8.53l-.13-.27L6.16 6l-.95-2-.94-2H1v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.13 0-.25-.11-.25-.25z" /> </svg> <svg id="alarm"> <path d="M22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12.5 8H11v6l4.75 2.85.75-1.23-4-2.37V8zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z" /> </svg> <svg id="alarm-add"> <path d="M7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7zm1-11h-2v3H8v2h3v3h2v-3h3v-2h-3V9z" /> </svg> <svg id="alarm-off"> <path d="M12 6c3.87 0 7 3.13 7 7 0 .84-.16 1.65-.43 2.4l1.52 1.52c.58-1.19.91-2.51.91-3.92 0-4.97-4.03-9-9-9-1.41 0-2.73.33-3.92.91L9.6 6.43C10.35 6.16 11.16 6 12 6zm10-.28l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM2.92 2.29L1.65 3.57 2.98 4.9l-1.11.93 1.42 1.42 1.11-.94.8.8C3.83 8.69 3 10.75 3 13c0 4.97 4.02 9 9 9 2.25 0 4.31-.83 5.89-2.2l2.2 2.2 1.27-1.27L3.89 3.27l-.97-.98zm13.55 16.1C15.26 19.39 13.7 20 12 20c-3.87 0-7-3.13-7-7 0-1.7.61-3.26 1.61-4.47l9.86 9.86zM8.02 3.28L6.6 1.86l-.86.71 1.42 1.42.86-.71z" /> </svg> <svg id="alarm-on">
{ "end_byte": 5619, "start_byte": 3056, "url": "https://github.com/angular/components/blob/main/src/dev-app/icon/assets/core-icon-set.svg" }
components/src/dev-app/icon/assets/core-icon-set.svg_5620_8443
<path d="M22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7zm-1.46-5.47L8.41 12.4l-1.06 1.06 3.18 3.18 6-6-1.06-1.06-4.93 4.95z" /> </svg> <svg id="android"> <path d="M6 18c0 .55.45 1 1 1h1v3.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5V19h2v3.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5V19h1c.55 0 1-.45 1-1V8H6v10zM3.5 8C2.67 8 2 8.67 2 9.5v7c0 .83.67 1.5 1.5 1.5S5 17.33 5 16.5v-7C5 8.67 4.33 8 3.5 8zm17 0c-.83 0-1.5.67-1.5 1.5v7c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5v-7c0-.83-.67-1.5-1.5-1.5zm-4.97-5.84l1.3-1.3c.2-.2.2-.51 0-.71-.2-.2-.51-.2-.71 0l-1.48 1.48C13.85 1.23 12.95 1 12 1c-.96 0-1.86.23-2.66.63L7.85.15c-.2-.2-.51-.2-.71 0-.2.2-.2.51 0 .71l1.31 1.31C6.97 3.26 6 5.01 6 7h12c0-1.99-.97-3.75-2.47-4.84zM10 5H9V4h1v1zm5 0h-1V4h1v1z" /> </svg> <svg id="announcement"> <path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 9h-2V5h2v6zm0 4h-2v-2h2v2z" /> </svg> <svg id="apps"> <path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z" /> </svg> <svg id="archive"> <path d="M20.54 5.23l-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5L6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z" /> </svg> <svg id="arrow-back"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> <svg id="arrow-drop-down"> <path d="M7 10l5 5 5-5z" /> </svg> <svg id="arrow-drop-down-circle"> <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 12l-4-4h8l-4 4z" /> </svg> <svg id="arrow-drop-up"> <path d="M7 14l5-5 5 5z" /> </svg> <svg id="cached"> <path d="M19 8l-4 4h3c0 3.31-2.69 6-6 6-1.01 0-1.97-.25-2.8-.7l-1.46 1.46C8.97 19.54 10.43 20 12 20c4.42 0 8-3.58 8-8h3l-4-4zM6 12c0-3.31 2.69-6 6-6 1.01 0 1.97.25 2.8.7l1.46-1.46C15.03 4.46 13.57 4 12 4c-4.42 0-8 3.58-8 8H1l4 4 4-4H6z" /> </svg> <svg id="check"> <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" /> </svg> <svg id="undo"> <path d="M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z" /> </svg> <svg id="redo"> <path d="M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z" /> </svg> <svg id="content-copy">
{ "end_byte": 8443, "start_byte": 5620, "url": "https://github.com/angular/components/blob/main/src/dev-app/icon/assets/core-icon-set.svg" }
components/src/dev-app/icon/assets/core-icon-set.svg_8444_9365
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" /> </svg> <svg id="content-cut"> <path d="M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1L9.64 7.64zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM19 3l-6 6 2 2 7-7V3z" /> </svg> <svg id="content-paste"> <path d="M19 2h-4.18C14.4.84 13.3 0 12 0c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z" /> </svg> </defs> </svg>
{ "end_byte": 9365, "start_byte": 8444, "url": "https://github.com/angular/components/blob/main/src/dev-app/icon/assets/core-icon-set.svg" }
components/src/dev-app/examples-page/examples-page.ts_0_719
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {EXAMPLE_COMPONENTS} from '@angular/components-examples'; import {ChangeDetectionStrategy, Component} from '@angular/core'; import {ExampleList} from '../example/example-list'; /** Renders all material examples listed in the generated EXAMPLE_COMPONENTS. */ @Component({ template: `<material-example-list [ids]="examples"></material-example-list>`, imports: [ExampleList], changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExamplesPage { examples = Object.keys(EXAMPLE_COMPONENTS); }
{ "end_byte": 719, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/examples-page/examples-page.ts" }
components/src/dev-app/examples-page/BUILD.bazel_0_259
load("//tools:defaults.bzl", "ng_module") package(default_visibility = ["//visibility:public"]) ng_module( name = "examples-page", srcs = glob(["**/*.ts"]), deps = [ "//src/components-examples", "//src/dev-app/example", ], )
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/examples-page/BUILD.bazel" }
components/src/dev-app/performance/performance-demo.ts_0_4431
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { afterNextRender, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, inject, Injector, ViewChild, } from '@angular/core'; import {FormsModule} from '@angular/forms'; import {MatButtonModule} from '@angular/material/button'; import {MatDividerModule} from '@angular/material/divider'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatIconModule} from '@angular/material/icon'; import {MatInputModule} from '@angular/material/input'; import {MatPaginator, MatPaginatorModule} from '@angular/material/paginator'; import {MatSelectModule} from '@angular/material/select'; import {MatTableDataSource, MatTableModule} from '@angular/material/table'; @Component({ selector: 'performance-demo', templateUrl: 'performance-demo.html', styleUrl: 'performance-demo.css', imports: [ FormsModule, MatButtonModule, MatDividerModule, MatFormFieldModule, MatIconModule, MatInputModule, MatPaginatorModule, MatSelectModule, MatTableModule, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class PerformanceDemo implements AfterViewInit { /** Controls the rendering of components. */ show = false; /** The number of times metrics will be gathered. */ sampleSize = 100; /** The number of components being rendered. */ componentCount = 100; /** A flat array of every sample recorded. */ allSamples: number[] = []; /** Used to disable benchmark controls while a benchmark is being run. */ isRunningBenchmark = false; /** The columns in the metrics table. */ displayedColumns: string[] = ['index', 'time']; /** Basically the same thing as allSamples but organized as a mat-table data source. */ dataSource = new MatTableDataSource<{index: number; time: string}>(); /** The average plus/minus the stdev. */ computedResults = ''; /** Used in an `@for` to render the desired number of comonents. */ componentArray = [].constructor(this.componentCount); private _injector = inject(Injector); readonly cdr = inject(ChangeDetectorRef); /** The standard deviation of the recorded samples. */ get stdev(): number | undefined { if (!this.allSamples.length) { return undefined; } return Math.sqrt( this.allSamples.map(x => Math.pow(x - this.mean!, 2)).reduce((a, b) => a + b) / this.allSamples.length, ); } /** The average value of the recorded samples. */ get mean(): number | undefined { if (!this.allSamples.length) { return undefined; } return this.allSamples.reduce((a, b) => a + b) / this.allSamples.length; } @ViewChild(MatPaginator) paginator?: MatPaginator; ngAfterViewInit() { this.dataSource.paginator = this.paginator!; } getTotalRenderTime(): string { return this.allSamples.length ? `${this.format(this.mean!)} ± ${this.format(this.stdev!)}` : ''; } format(num: number): string { const roundedNum = Math.round(num * 100) / 100; return roundedNum >= 10 ? roundedNum.toFixed(2) : '0' + roundedNum.toFixed(2); } async runBenchmark(): Promise<void> { this.isRunningBenchmark = true; const samples = []; for (let i = 0; i < this.sampleSize; i++) { samples.push(await this.recordSample()); } this.dataSource.data = this.dataSource.data.concat( samples.map((sample, i) => ({ index: this.allSamples.length + i, time: this.format(sample), })), ); this.allSamples.push(...samples); this.isRunningBenchmark = false; this.computedResults = this.getTotalRenderTime(); this.cdr.markForCheck(); } clearMetrics() { this.allSamples = []; this.dataSource.data = []; this.computedResults = this.getTotalRenderTime(); } recordSample(): Promise<number> { return new Promise(res => { setTimeout(() => { this.show = true; this.cdr.markForCheck(); const start = performance.now(); afterNextRender( () => { const end = performance.now(); this.show = false; this.cdr.markForCheck(); res(end - start); }, {injector: this._injector}, ); }); }); } }
{ "end_byte": 4431, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/performance/performance-demo.ts" }
components/src/dev-app/performance/BUILD.bazel_0_678
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "performance", srcs = glob(["**/*.ts"]), assets = [ "performance-demo.html", ":performance_demo_scss", ], deps = [ "//src/material/button", "//src/material/divider", "//src/material/form-field", "//src/material/icon", "//src/material/input", "//src/material/paginator", "//src/material/select", "//src/material/table", "@npm//@angular/forms", ], ) sass_binary( name = "performance_demo_scss", src = "performance-demo.scss", )
{ "end_byte": 678, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/performance/BUILD.bazel" }
components/src/dev-app/performance/performance-demo.scss_0_367
.demo-table-and-paginator-container { margin-bottom: 22px; border: 1px solid #ccc; border-radius: 5px; overflow: hidden; } .demo-table-container { max-height: 60vh; overflow: auto; } .demo-disclaimer { display: flex; justify-content: center; align-items: center; margin: 0 0 32px; mat-icon { flex-shrink: 0; margin-right: 16px; } }
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/performance/performance-demo.scss" }
components/src/dev-app/performance/performance-demo.html_0_2880
<p class="demo-disclaimer"> <mat-icon color="warn">warning</mat-icon> Disclaimer: This is an approximate measurement, for more precise performance benchmarking use Chrome devtools </p> <div> <mat-form-field appearance="outline" style="margin-right: 32px"> <mat-label>Sample size</mat-label> <mat-select [(value)]="sampleSize" [disabled]="isRunningBenchmark"> <mat-option [value]="1">1</mat-option> <mat-option [value]="10">10</mat-option> <mat-option [value]="100">100</mat-option> <mat-option [value]="1000">1000</mat-option> </mat-select> </mat-form-field> <mat-form-field appearance="outline"> <mat-label>Component count</mat-label> <mat-select [(value)]="componentCount" [disabled]="isRunningBenchmark" (selectionChange)="componentArray = [].constructor(componentCount)" > <mat-option [value]="1">1</mat-option> <mat-option [value]="10">10</mat-option> <mat-option [value]="100">100</mat-option> <mat-option [value]="1000">1000</mat-option> </mat-select> </mat-form-field> </div> <div class="demo-table-and-paginator-container"> <div class="demo-table-container"> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <ng-container matColumnDef="index"> <th mat-header-cell *matHeaderCellDef>No.</th> <td mat-cell *matCellDef="let item">{{ item.index }}</td> <td mat-footer-cell *matFooterCellDef> @if (allSamples.length) { <strong>Average render time</strong> } @if (!allSamples.length) { No data yet } </td> </ng-container> <ng-container matColumnDef="time"> <th mat-header-cell *matHeaderCellDef>Time</th> <td mat-cell *matCellDef="let item">{{ item.time }}</td> <td mat-footer-cell *matFooterCellDef> <strong>{{ computedResults }}</strong> </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr> <tr mat-footer-row *matFooterRowDef="displayedColumns; sticky: true"></tr> </table> </div> <mat-divider></mat-divider> <mat-paginator [pageSizeOptions]="[10, 50, 100]" [pageSize]="100" showFirstLastButtons [disabled]="isRunningBenchmark" ></mat-paginator> </div> @if (allSamples.length) { <button color="accent" mat-button (click)="clearMetrics()" [disabled]="isRunningBenchmark" style="margin-right: 32px" > Clear Metrics </button> } <button color="primary" mat-raised-button (click)="runBenchmark()" [disabled]="isRunningBenchmark"> Run Benchmark </button> @if (show) { @for (_ of componentArray; track _) { <mat-form-field> <mat-label>Input</mat-label> <input matInput /> </mat-form-field> } }
{ "end_byte": 2880, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/performance/performance-demo.html" }
components/src/dev-app/snack-bar/snack-bar-demo.html_0_1942
<h1>SnackBar demo</h1> <div> <div> Message: <mat-form-field><input matInput type="text" [(ngModel)]="message"></mat-form-field> </div> <div> <div>Position in page: </div> <mat-form-field> <mat-label>Horizontal</mat-label> <mat-select [(ngModel)]="horizontalPosition"> <mat-option value="start">Start</mat-option> <mat-option value="end">End</mat-option> <mat-option value="left">Left</mat-option> <mat-option value="right">Right</mat-option> <mat-option value="center">Center</mat-option> </mat-select> </mat-form-field> <mat-form-field> <mat-label>Vertical</mat-label> <mat-select [(ngModel)]="verticalPosition"> <mat-option value="top">Top</mat-option> <mat-option value="bottom">Bottom</mat-option> </mat-select> </mat-form-field> </div> <div> <mat-checkbox [(ngModel)]="action"> @if (action) { <mat-form-field> <mat-label>Snack bar action label</mat-label> <input matInput type="text" [(ngModel)]="actionButtonLabel"> </mat-form-field> } @else { <p>Show button on snack bar</p> } </mat-checkbox> </div> <div> <mat-checkbox [(ngModel)]="setAutoHide"> @if (setAutoHide) { <mat-form-field> <mat-label>Auto hide duration in ms</mat-label> <input matInput type="number" [(ngModel)]="autoHide"> </mat-form-field> } @else { <p>Auto hide after duration</p> } </mat-checkbox> </div> <p> <mat-checkbox [(ngModel)]="addExtraClass">Add extra class to container</mat-checkbox> </p> </div> <p> <button mat-raised-button (click)="open()">OPEN</button> </p> <button mat-raised-button (click)="openTemplate()">OPEN TEMPLATE</button> <ng-template #template> Template snack bar: {{message}} </ng-template>
{ "end_byte": 1942, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/snack-bar/snack-bar-demo.html" }
components/src/dev-app/snack-bar/snack-bar-demo.scss_0_436
.demo-party .mdc-snackbar__surface { animation: demo-party 5000ms infinite; } @keyframes demo-party { 0% { background: #00f; } 10% { background: #8e44ad; } 20% { background: #1abc9c; } 30% { background: #d35400; } 40% { background: #00f; } 50% { background: #34495e; } 60% { background: #00f; } 70% { background: #2980b9; } 80% { background: #f1c40f; } 90% { background: #2980b9; } 100% { background: #0ff; } }
{ "end_byte": 436, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/snack-bar/snack-bar-demo.scss" }
components/src/dev-app/snack-bar/snack-bar-demo.ts_0_2205
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Directionality} from '@angular/cdk/bidi'; import { ChangeDetectionStrategy, Component, TemplateRef, ViewChild, ViewEncapsulation, inject, } from '@angular/core'; import {FormsModule} from '@angular/forms'; import {MatButtonModule} from '@angular/material/button'; import {MatCheckboxModule} from '@angular/material/checkbox'; import {MatInputModule} from '@angular/material/input'; import {MatSelectModule} from '@angular/material/select'; import { MatSnackBar, MatSnackBarConfig, MatSnackBarHorizontalPosition, MatSnackBarVerticalPosition, } from '@angular/material/snack-bar'; @Component({ selector: 'snack-bar-demo', templateUrl: 'snack-bar-demo.html', styleUrl: 'snack-bar-demo.css', encapsulation: ViewEncapsulation.None, imports: [FormsModule, MatButtonModule, MatCheckboxModule, MatInputModule, MatSelectModule], changeDetection: ChangeDetectionStrategy.OnPush, }) export class SnackBarDemo { snackBar = inject(MatSnackBar); private _dir = inject(Directionality); @ViewChild('template') template: TemplateRef<any>; message = 'Snack Bar opened.'; actionButtonLabel = 'Retry'; action = false; setAutoHide = true; autoHide = 10000; addExtraClass = false; horizontalPosition: MatSnackBarHorizontalPosition = 'center'; verticalPosition: MatSnackBarVerticalPosition = 'bottom'; open() { const config = this._createConfig(); this.snackBar.open(this.message, this.action ? this.actionButtonLabel : undefined, config); } openTemplate() { const config = this._createConfig(); this.snackBar.openFromTemplate(this.template, config); } private _createConfig() { const config = new MatSnackBarConfig(); config.verticalPosition = this.verticalPosition; config.horizontalPosition = this.horizontalPosition; config.duration = this.setAutoHide ? this.autoHide : 0; config.panelClass = this.addExtraClass ? ['demo-party'] : undefined; config.direction = this._dir.value; return config; } }
{ "end_byte": 2205, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/snack-bar/snack-bar-demo.ts" }
components/src/dev-app/snack-bar/BUILD.bazel_0_632
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "snack-bar", srcs = glob(["**/*.ts"]), assets = [ "snack-bar-demo.html", ":snack_bar_demo_scss", ], deps = [ "//src/cdk/bidi", "//src/material/button", "//src/material/checkbox", "//src/material/form-field", "//src/material/input", "//src/material/select", "//src/material/snack-bar", "@npm//@angular/forms", ], ) sass_binary( name = "snack_bar_demo_scss", src = "snack-bar-demo.scss", )
{ "end_byte": 632, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/snack-bar/BUILD.bazel" }
components/src/dev-app/paginator/paginator-demo.ts_0_1543
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { PaginatorConfigurableExample, PaginatorOverviewExample, } from '@angular/components-examples/material/paginator'; import {ChangeDetectionStrategy, Component} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {MatCardModule} from '@angular/material/card'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatInputModule} from '@angular/material/input'; import {MatPaginatorModule, PageEvent} from '@angular/material/paginator'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; @Component({ selector: 'paginator-demo', templateUrl: 'paginator-demo.html', styleUrl: 'paginator-demo.css', imports: [ FormsModule, MatCardModule, MatFormFieldModule, MatInputModule, MatSlideToggleModule, MatPaginatorModule, PaginatorOverviewExample, PaginatorConfigurableExample, ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class PaginatorDemo { length = 50; pageSize = 10; pageIndex = 0; pageSizeOptions = [5, 10, 25]; hidePageSize = false; showPageSizeOptions = true; showFirstLastButtons = true; disabled = false; pageEvent: PageEvent; handlePageEvent(e: PageEvent) { this.pageEvent = e; this.length = e.length; this.pageSize = e.pageSize; this.pageIndex = e.pageIndex; } }
{ "end_byte": 1543, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/paginator/paginator-demo.ts" }
components/src/dev-app/paginator/paginator-demo.html_0_185
<h3>Paginator overview</h3> <paginator-overview-example></paginator-overview-example> <h3>Configurable paginator</h3> <paginator-configurable-example></paginator-configurable-example>
{ "end_byte": 185, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/paginator/paginator-demo.html" }
components/src/dev-app/paginator/paginator-demo.scss_0_214
.demo-section { max-width: 500px; margin-bottom: 24px; background: #efefef !important; & > * { margin: 0 0 32px; } } .demo-options { display: flex; flex-direction: column; max-width: 300px; }
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/paginator/paginator-demo.scss" }
components/src/dev-app/paginator/BUILD.bazel_0_631
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "paginator", srcs = glob(["**/*.ts"]), assets = [ "paginator-demo.html", ":paginator_demo_scss", ], deps = [ "//src/components-examples/material/paginator", "//src/material/card", "//src/material/form-field", "//src/material/input", "//src/material/paginator", "//src/material/slide-toggle", "@npm//@angular/forms", ], ) sass_binary( name = "paginator_demo_scss", src = "paginator-demo.scss", )
{ "end_byte": 631, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/paginator/BUILD.bazel" }
components/src/dev-app/drag-drop/drag-drop-demo.ts_0_2793
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Component, ViewEncapsulation, ChangeDetectionStrategy, inject} from '@angular/core'; import {MatIconModule, MatIconRegistry} from '@angular/material/icon'; import {DomSanitizer} from '@angular/platform-browser'; import { CdkDragDrop, DragDropModule, moveItemInArray, transferArrayItem, Point, DragRef, } from '@angular/cdk/drag-drop'; import {FormsModule} from '@angular/forms'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatInputModule} from '@angular/material/input'; import {MatSelectModule} from '@angular/material/select'; import {MatCheckbox} from '@angular/material/checkbox'; @Component({ selector: 'drag-drop-demo', templateUrl: 'drag-drop-demo.html', styleUrl: 'drag-drop-demo.css', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [ DragDropModule, FormsModule, MatFormFieldModule, MatIconModule, MatInputModule, MatSelectModule, MatCheckbox, ], }) export class DragAndDropDemo { axisLock: 'x' | 'y'; dragStartDelay = 0; todo = ['Go out for Lunch', 'Make a cool app', 'Watch TV', 'Eat a healthy dinner', 'Go to sleep']; done = ['Get up', 'Have breakfast', 'Brush teeth', 'Check reddit']; mixedTodo = this.todo.slice(); mixedDone = this.done.slice(); mixedWrap = true; ages = ['Stone age', 'Bronze age', 'Iron age', 'Middle ages']; preferredAges = ['Modern period', 'Renaissance']; constructor() { const iconRegistry = inject(MatIconRegistry); const sanitizer = inject(DomSanitizer); iconRegistry.addSvgIconLiteral( 'dnd-move', sanitizer.bypassSecurityTrustHtml( ` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"> <path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5` + `-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z"/> <path d="M0 0h24v24H0z" fill="none"/> </svg> `, ), ); } drop(event: CdkDragDrop<string[]>) { if (event.previousContainer === event.container) { moveItemInArray(event.container.data, event.previousIndex, event.currentIndex); } else { transferArrayItem( event.previousContainer.data, event.container.data, event.previousIndex, event.currentIndex, ); } } constrainPosition({x, y}: Point, _dragRef: DragRef, _dimensions: DOMRect, pickup: Point): Point { // Just returning the original top left corner to not modify position x -= pickup.x; y -= pickup.y; return {x, y}; } }
{ "end_byte": 2793, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/drag-drop/drag-drop-demo.ts" }
components/src/dev-app/drag-drop/BUILD.bazel_0_567
load("//tools:defaults.bzl", "ng_module", "sass_binary") package(default_visibility = ["//visibility:public"]) ng_module( name = "drag-drop", srcs = glob(["**/*.ts"]), assets = [ "drag-drop-demo.html", ":drag-drop_demo_scss", ], deps = [ "//src/cdk/drag-drop", "//src/material/checkbox", "//src/material/form-field", "//src/material/icon", "//src/material/input", "//src/material/select", ], ) sass_binary( name = "drag-drop_demo_scss", src = "drag-drop-demo.scss", )
{ "end_byte": 567, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/drag-drop/BUILD.bazel" }
components/src/dev-app/drag-drop/drag-drop-demo.html_0_4466
<div cdkDropListGroup> <div class="demo-list"> <h2>To do</h2> <div cdkDropList (cdkDropListDropped)="drop($event)" [cdkDropListLockAxis]="axisLock" [cdkDropListData]="todo"> @for (item of todo; track item) { <div cdkDrag> {{item}} <mat-icon cdkDragHandle svgIcon="dnd-move"></mat-icon> </div> } </div> </div> <div class="demo-list"> <h2>Done</h2> <div cdkDropList (cdkDropListDropped)="drop($event)" [cdkDropListLockAxis]="axisLock" [cdkDropListData]="done"> @for (item of done; track item) { <div cdkDrag> {{item}} <mat-icon cdkDragHandle svgIcon="dnd-move"></mat-icon> </div> } </div> </div> </div> <div cdkDropListGroup> <div class="demo-list demo-list-horizontal"> <h2>Ages</h2> <div cdkDropList cdkDropListOrientation="horizontal" (cdkDropListDropped)="drop($event)" [cdkDropListLockAxis]="axisLock" [cdkDropListData]="ages"> @for (item of ages; track item) { <div cdkDrag> {{item}} <mat-icon cdkDragHandle svgIcon="dnd-move"></mat-icon> </div> } </div> </div> <div class="demo-list demo-list-horizontal" style="text-align: right"> <h2>Preferred Ages</h2> <div cdkDropList cdkDropListOrientation="horizontal" (cdkDropListDropped)="drop($event)" [cdkDropListLockAxis]="axisLock" [cdkDropListData]="preferredAges"> @for (item of preferredAges; track item) { <div cdkDrag> {{item}} <mat-icon cdkDragHandle svgIcon="dnd-move"></mat-icon> </div> } </div> </div> </div> <h2>Mixed orientation</h2> <p> <mat-checkbox [(ngModel)]="mixedWrap">Wrap list</mat-checkbox> </p> <div cdkDropListGroup> <div class="demo-list" [class.demo-list-wrapping]="mixedWrap" [class.demo-list-horizontal]="mixedWrap"> <div cdkDropList cdkDropListOrientation="mixed" (cdkDropListDropped)="drop($event)" [cdkDropListLockAxis]="axisLock" [cdkDropListData]="mixedTodo"> @for (item of mixedTodo; track item) { <div cdkDrag> {{item}} <mat-icon cdkDragHandle svgIcon="dnd-move"></mat-icon> </div> } </div> </div> <div class="demo-list" [class.demo-list-wrapping]="mixedWrap" [class.demo-list-horizontal]="mixedWrap"> <div cdkDropList cdkDropListOrientation="mixed" (cdkDropListDropped)="drop($event)" [cdkDropListLockAxis]="axisLock" [cdkDropListData]="mixedDone"> @for (item of mixedDone; track item) { <div cdkDrag> {{item}} <mat-icon cdkDragHandle svgIcon="dnd-move"></mat-icon> </div> } </div> </div> </div> <div class="demo-list"> <h2>Free dragging</h2> <div cdkDrag class="demo-free-draggable" [cdkDragLockAxis]="axisLock" [cdkDragStartDelay]="dragStartDelay" > Drag me around </div> </div> <div> <h2>Drag with box boundary</h2> <div class="demo-constrain-box" id="constrain-box-1"> <div cdkDrag class="demo-free-draggable" [cdkDragLockAxis]="axisLock" [cdkDragStartDelay]="dragStartDelay" cdkDragBoundary="#constrain-box-1" > Drag me around </div> </div> </div> <div> <h2>Drag with box boundary and custom constrain</h2> <div class="demo-constrain-box" id="constrain-box-2"> <div cdkDrag class="demo-free-draggable" [cdkDragLockAxis]="axisLock" [cdkDragStartDelay]="dragStartDelay" cdkDragBoundary="#constrain-box-2" [cdkDragConstrainPosition]="constrainPosition" > Drag me around </div> </div> </div> <div> <h2>Data</h2> <pre>{{todo.join(', ')}}</pre> <pre>{{done.join(', ')}}</pre> <pre>{{ages.join(', ')}}</pre> <pre>{{preferredAges.join(', ')}}</pre> </div> <div> <h2>Axis locking</h2> <mat-form-field> <mat-label>Lock position along axis</mat-label> <mat-select [(ngModel)]="axisLock"> <mat-option>None</mat-option> <mat-option value="x">X axis</mat-option> <mat-option value="y">Y axis</mat-option> </mat-select> </mat-form-field> </div> <div> <h2>Drag start delay</h2> <mat-form-field> <input matInput placeholder="Drag start delay" value="0" [(ngModel)]="dragStartDelay" /> </mat-form-field> </div>
{ "end_byte": 4466, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/drag-drop/drag-drop-demo.html" }
components/src/dev-app/drag-drop/drag-drop-demo.scss_0_1830
.demo-list { width: 500px; max-width: 100%; margin-bottom: 25px; display: inline-block; margin-right: 25px; vertical-align: top; [dir='rtl'] & { margin-right: 0; margin-left: 25px; } } .demo-list-horizontal { width: 1000px; margin-right: 0; margin-left: 0; } .demo-list-wrapping { width: 600px; margin-right: 25px; .cdk-drop-list { flex-wrap: wrap; min-width: 100px; } } .cdk-drop-list { border: solid 1px #ccc; min-height: 60px; display: block; .demo-list-horizontal & { padding: 12px; display: inline-flex; flex-direction: row; } } .cdk-drop-list-receiving { border-style: dashed; } .cdk-drag { padding: 20px 10px; border-bottom: solid 1px #ccc; display: flex; flex-direction: row; align-items: center; justify-content: space-between; box-sizing: border-box; .cdk-drop-list-dragging &:not(.cdk-drag-placeholder):not(.cdk-drag-preview) { transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); } .cdk-drop-list &:last-child { border: none; } .demo-list-horizontal & { white-space: nowrap; margin: 8px; &, &:last-child { border: solid 1px #ccc; } } } .cdk-drag-preview { box-sizing: border-box; opacity: 0.5; } .cdk-drag-animating { transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); } .cdk-drag-placeholder { opacity: 0; } .cdk-drag-handle { cursor: move; margin-left: 8px; [dir='rtl'] & { margin-left: 0; margin-right: 8px; } svg { fill: rgba(0, 0, 0, 0.5); } } pre { white-space: normal; } .demo-free-draggable { width: 200px; height: 200px; border: solid 1px #ccc; cursor: move; display: flex; justify-content: center; align-items: center; } .demo-constrain-box { width: 600px; height: 400px; border: 1px solid black; }
{ "end_byte": 1830, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/dev-app/drag-drop/drag-drop-demo.scss" }