_id
stringlengths 21
254
| text
stringlengths 1
93.7k
| metadata
dict |
---|---|---|
components/src/dev-app/menubar/mat-menubar-demo.scss_0_461 | .mat-menu {
display: flex;
flex-direction: column;
max-height: 808px;
min-height: 64px;
max-width: 280px;
min-width: 112px;
padding: 8px 0;
border-radius: 4px;
box-shadow: #0003 0 2px 4px -1px, #00000024 0 4px 5px 0, #0000001f 0 1px 10px 0;
cursor: pointer;
&[aria-orientation='horizontal'] {
flex-direction: row;
}
}
.mat-menu-item {
display: block;
padding: 16px;
-webkit-user-select: none;
-moz-user-select: none;
}
| {
"end_byte": 461,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/menubar/mat-menubar-demo.scss"
} |
components/src/dev-app/menubar/mat-menubar-demo.ts_0_1908 | /**
* @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 {CDK_MENU, CdkMenu, CdkMenuGroup, CdkMenuItem, CdkMenuModule} from '@angular/cdk/menu';
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
import {MatMenuBarModule} from '@angular/material-experimental/menubar';
// TODO: Remove the fake when mat-menu is re-built with CdkMenu directives
@Component({
selector: 'demo-menu',
exportAs: 'demoMenu',
template: '<ng-content></ng-content>',
host: {
'[tabindex]': 'isInline ? 0 : null',
'role': 'menu',
'class': 'cdk-menu mat-menu mat-menu-panel',
'[class.cdk-menu-inline]': 'isInline',
'[attr.aria-orientation]': 'orientation',
},
providers: [
{provide: CdkMenuGroup, useExisting: DemoMenu},
{provide: CDK_MENU, useExisting: DemoMenu},
],
styleUrl: 'mat-menubar-demo.css',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DemoMenu extends CdkMenu {}
// TODO: Remove the fake when mat-menu-item is re-built with CdkMenu directives
@Component({
selector: 'demo-menu-item',
exportAs: 'demoMenuItem',
host: {
'[tabindex]': '_tabindex',
'type': 'button',
'role': 'menuitem',
'class': 'cdk-menu-item mat-menu-item',
'[attr.aria-disabled]': 'disabled || null',
},
template: '<ng-content></ng-content>',
styleUrl: 'mat-menubar-demo.css',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DemoMenuItem extends CdkMenuItem {}
@Component({
templateUrl: 'mat-menubar-demo.html',
imports: [CdkMenuModule, MatMenuBarModule, DemoMenu, DemoMenuItem],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MatMenuBarDemo {}
| {
"end_byte": 1908,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/menubar/mat-menubar-demo.ts"
} |
components/src/dev-app/menubar/mat-menubar-demo.html_0_762 | <mat-menubar>
<mat-menubar-item [cdkMenuTriggerFor]="file">File</mat-menubar-item>
<mat-menubar-item [cdkMenuTriggerFor]="edit">Edit</mat-menubar-item>
<mat-menubar-item [cdkMenuTriggerFor]="view">View</mat-menubar-item>
</mat-menubar>
<ng-template #file>
<demo-menu>
<demo-menu-item>Share</demo-menu-item>
<demo-menu-item>Open</demo-menu-item>
<demo-menu-item>Make a Copy</demo-menu-item>
</demo-menu>
</ng-template>
<ng-template #edit>
<demo-menu>
<demo-menu-item>Undo</demo-menu-item>
<demo-menu-item>Redo</demo-menu-item>
</demo-menu>
</ng-template>
<ng-template #view>
<demo-menu>
<demo-menu-item>Show Ruler</demo-menu-item>
<demo-menu-item>Show Document Outline</demo-menu-item>
</demo-menu>
</ng-template>
| {
"end_byte": 762,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/menubar/mat-menubar-demo.html"
} |
components/src/dev-app/menubar/BUILD.bazel_0_447 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "menubar",
srcs = glob(["**/*.ts"]),
assets = [
"mat-menubar-demo.html",
":mat_menubar_demo_scss",
],
deps = [
"//src/cdk/menu",
"//src/material-experimental/menubar",
],
)
sass_binary(
name = "mat_menubar_demo_scss",
src = "mat-menubar-demo.scss",
)
| {
"end_byte": 447,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/menubar/BUILD.bazel"
} |
components/src/dev-app/chips/chips-demo.scss_0_387 | .demo-chips {
.mat-mdc-chip-set-stacked {
display: block;
max-width: 200px;
}
.mat-mdc-card {
padding: 0;
margin: 16px;
& .mat-toolbar {
margin: 0;
}
& .mat-card-content {
padding: 24px;
}
}
.mat-mdc-basic-chip {
margin: auto 10px;
}
mat-chip-grid input {
width: 150px;
}
}
.demo-has-chip-list {
width: 100%;
}
| {
"end_byte": 387,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/chips/chips-demo.scss"
} |
components/src/dev-app/chips/chips-demo.html_0_7263 | <div class="demo-chips">
<mat-card>
<mat-toolbar color="primary">Static Chips</mat-toolbar>
<mat-card-content>
<h4>Simple</h4>
<mat-chip-set>
<mat-chip>Chip 1</mat-chip>
<mat-chip>Chip 2</mat-chip>
<mat-chip disabled>Chip 3</mat-chip>
</mat-chip-set>
<h4>Unstyled</h4>
<mat-chip-set>
<mat-basic-chip>Basic Chip 1</mat-basic-chip>
<mat-basic-chip>Basic Chip 2</mat-basic-chip>
<mat-basic-chip>Basic Chip 3</mat-basic-chip>
</mat-chip-set>
<mat-chip-listbox>
<mat-basic-chip-option>Basic Chip Option 1</mat-basic-chip-option>
<mat-basic-chip-option>Basic Chip Option 2</mat-basic-chip-option>
<mat-basic-chip-option>Basic Chip Option 3</mat-basic-chip-option>
</mat-chip-listbox>
<mat-chip-grid #basicGrid>
<mat-basic-chip-row>Basic Chip Row 1</mat-basic-chip-row>
<mat-basic-chip-row>Basic Chip Row 2</mat-basic-chip-row>
<mat-basic-chip-row>Basic Chip Row 3</mat-basic-chip-row>
<input [matChipInputFor]="basicGrid" readonly>
</mat-chip-grid>
<h4>With avatar, icons, and color</h4>
<mat-chip-set>
<mat-chip disabled>
<mat-icon matChipAvatar>home</mat-icon>
Home
<button matChipRemove aria-label="Remove chip">
<mat-icon>close</mat-icon>
</button>
</mat-chip>
<mat-chip highlighted="true" color="accent">
<mat-chip-avatar>P</mat-chip-avatar>
Portel
<button matChipRemove aria-label="Remove chip">
<mat-icon>close</mat-icon>
</button>
</mat-chip>
<mat-chip>
<mat-chip-avatar>M</mat-chip-avatar>
Molly
</mat-chip>
<mat-chip>
Koby
<button matChipRemove aria-label="Remove chip">
<mat-icon>close</mat-icon>
</button>
</mat-chip>
<mat-chip>
Razzle
</mat-chip>
<mat-chip>
<img src="https://material.angular.io/assets/img/examples/shiba2.jpg" matChipAvatar>
Mal
</mat-chip>
<mat-chip highlighted="true" color="warn">
<img src="https://material.angular.io/assets/img/examples/shiba2.jpg" matChipAvatar>
Husi
<button matChipRemove>
<mat-icon>close</mat-icon>
</button>
</mat-chip>
<mat-chip>
Good
<mat-icon matChipTrailingIcon>star</mat-icon>
</mat-chip>
<mat-chip>
Bad
<mat-icon matChipTrailingIcon>star_border</mat-icon>
</mat-chip>
</mat-chip-set>
<h4>With Events</h4>
<mat-chip-set>
@if (visible) {
<mat-chip highlighted="true" color="warn"
(destroyed)="displayMessage('chip destroyed')" (removed)="toggleVisible()">
With Events
<button matChipRemove aria-label="Remove chip">
<mat-icon>close</mat-icon>
</button>
</mat-chip>
}
</mat-chip-set>
<div>{{message}}</div>
</mat-card-content>
</mat-card>
<mat-card>
<mat-toolbar color="primary">Selectable Chips</mat-toolbar>
<mat-card-content>
<button mat-button (click)="disabledListboxes = !disabledListboxes">
{{disabledListboxes ? "Enable" : "Disable"}}
</button>
<button mat-button (click)="listboxesWithAvatar = !listboxesWithAvatar">
{{listboxesWithAvatar ? "Hide Avatar" : "Show Avatar"}}
</button>
<h4>Single selection</h4>
<mat-chip-listbox multiple="false" [disabled]="disabledListboxes">
@for (shirtSize of shirtSizes; track shirtSize) {
<mat-chip-option [disabled]="shirtSize.disabled">
{{shirtSize.label}}
@if (listboxesWithAvatar) {
<mat-chip-avatar>{{shirtSize.avatar}}</mat-chip-avatar>
}
</mat-chip-option>
}
</mat-chip-listbox>
<h4>Multi selection</h4>
<mat-chip-listbox multiple="true" [disabled]="disabledListboxes">
@for (hint of restaurantHints; track hint) {
<mat-chip-option [selected]="hint.selected">
@if (listboxesWithAvatar) {
<mat-chip-avatar>{{hint.avatar}}</mat-chip-avatar>
}
{{hint.label}}
</mat-chip-option>
}
</mat-chip-listbox>
</mat-card-content>
</mat-card>
<mat-card>
<mat-toolbar color="primary">Input Chips</mat-toolbar>
<mat-card-content>
<p>
The <code><mat-chip-grid></code> component pairs with the <code>matChipInputFor</code> directive
to convert user input text into chips.
They can be used inside a <code><mat-form-field></code>.
</p>
<button mat-button (click)="disableInputs = !disableInputs">
{{disableInputs ? "Enable" : "Disable"}}
</button>
<button mat-button (click)="editable = !editable">
{{editable ? "Disable editing" : "Enable editing"}}
</button>
<h4>Input is last child of chip grid</h4>
<mat-form-field class="demo-has-chip-list">
<mat-label>New Contributor...</mat-label>
<mat-chip-grid #chipGrid1 [(ngModel)]="selectedPeople" required [disabled]="disableInputs">
@for (person of people; track person) {
<mat-chip-row
[editable]="editable"
(removed)="remove(person)"
(edited)="edit(person, $event)">
{{person.name}}
<button matChipRemove aria-label="Remove contributor">
<mat-icon>close</mat-icon>
</button>
</mat-chip-row>
}
<input [disabled]="disableInputs"
[matChipInputFor]="chipGrid1"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="addOnBlur"
(matChipInputTokenEnd)="add($event)" />
</mat-chip-grid>
</mat-form-field>
<h4>Input is next sibling child of chip grid</h4>
<mat-form-field>
<mat-label>New Contributor...</mat-label>
<mat-chip-grid #chipGrid2 [(ngModel)]="selectedPeople" required [disabled]="disableInputs">
@for (person of people; track person) {
<mat-chip-row (removed)="remove(person)">
{{person.name}}
<button matChipRemove aria-label="Remove contributor">
<mat-icon>close</mat-icon>
</button>
</mat-chip-row>
}
</mat-chip-grid>
<input [matChipInputFor]="chipGrid2"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="addOnBlur"
(matChipInputTokenEnd)="add($event)" />
</mat-form-field>
<p>
The example above has overridden the <code>[separatorKeys]</code> input to allow for
<code>ENTER</code>, <code>COMMA</code> and <code>SEMICOLON</code> keys.
</p>
<h4>Options</h4>
<p>
<mat-checkbox name="addOnBlur" [(ngModel)]="addOnBlur">Add on Blur</mat-checkbox>
</p>
</mat-card-content>
</mat-card> | {
"end_byte": 7263,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/chips/chips-demo.html"
} |
components/src/dev-app/chips/chips-demo.html_7267_9990 | <mat-card>
<mat-toolbar color="primary">Miscellaneous</mat-toolbar>
<mat-card-content>
<h4>Stacked</h4>
<p>
You can also stack the chips if you want them on top of each other.
</p>
<mat-chip-set class="mat-mdc-chip-set-stacked">
@for (aColor of availableColors; track aColor) {
<mat-chip highlighted="true" [color]="aColor.color">{{aColor.name}}</mat-chip>
}
</mat-chip-set>
<h4>NgModel with multi selection</h4>
<mat-chip-listbox [multiple]="true" [(ngModel)]="selectedColors">
@for (aColor of availableColors; track aColor) {
<mat-chip-option [color]="aColor.color" [value]="aColor.name">{{aColor.name}}</mat-chip-option>
}
</mat-chip-listbox>
The selected colors are
@for (color of selectedColors; track color; let isLast = $last) {
<span>{{color}}{{isLast ? '' : ', '}}</span>
}
<h4>NgModel with single selection</h4>
<mat-chip-listbox [(ngModel)]="selectedColor">
@for (aColor of availableColors; track aColor) {
<mat-chip-option [color]="aColor.color" [value]="aColor.name">{{aColor.name}}</mat-chip-option>
}
</mat-chip-listbox>
The selected color is {{selectedColor}}.
<h4>Single selection without checkmark selection indicator.</h4>
<mat-chip-listbox [(ngModel)]="selectedColor" [hideSingleSelectionIndicator]="true">
@for (aColor of availableColors; track aColor) {
<mat-chip-option [color]="aColor.color" [value]="aColor.name">{{aColor.name}}</mat-chip-option>
}
</mat-chip-listbox>
<h4>Single selection with decorative icons.</h4>
<mat-chip-listbox [(ngModel)]="selectedColor" [hideSingleSelectionIndicator]="true">
@for (aColor of availableColors; track aColor) {
<mat-chip-option [color]="aColor.color"
[value]="aColor.name">
<mat-icon matChipAvatar>home</mat-icon>
{{aColor.name}}
<mat-icon matChipTrailingIcon>star</mat-icon>
</mat-chip-option>
}
</mat-chip-listbox>
The selected color is {{selectedColor}}.
<h4>Single selection with stacked appearance.</h4>
<mat-chip-listbox [(ngModel)]="selectedColor" class="mat-mdc-chip-set-stacked">
@for (aColor of availableColors; track aColor) {
<mat-chip-option [color]="aColor.color"
[value]="aColor.name">
{{aColor.name}}
<mat-icon matChipTrailingIcon>star</mat-icon>
</mat-chip-option>
}
</mat-chip-listbox>
The selected color is {{selectedColor}}.
</mat-card-content>
</mat-card>
</div> | {
"end_byte": 9990,
"start_byte": 7267,
"url": "https://github.com/angular/components/blob/main/src/dev-app/chips/chips-demo.html"
} |
components/src/dev-app/chips/BUILD.bazel_0_612 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "chips",
srcs = glob(["**/*.ts"]),
assets = [
"chips-demo.html",
":chips_demo_scss",
],
deps = [
"//src/material/button",
"//src/material/card",
"//src/material/checkbox",
"//src/material/chips",
"//src/material/core",
"//src/material/form-field",
"//src/material/icon",
"//src/material/toolbar",
],
)
sass_binary(
name = "chips_demo_scss",
src = "chips-demo.scss",
)
| {
"end_byte": 612,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/chips/BUILD.bazel"
} |
components/src/dev-app/chips/chips-demo.ts_0_3637 | /**
* @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 {LiveAnnouncer} from '@angular/cdk/a11y';
import {COMMA, ENTER} from '@angular/cdk/keycodes';
import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatCardModule} from '@angular/material/card';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatChipEditedEvent, MatChipInputEvent, MatChipsModule} from '@angular/material/chips';
import {ThemePalette} from '@angular/material/core';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatIconModule} from '@angular/material/icon';
import {MatToolbarModule} from '@angular/material/toolbar';
export interface Person {
name: string;
}
export interface DemoColor {
name: string;
color: ThemePalette;
}
@Component({
selector: 'chips-demo',
templateUrl: 'chips-demo.html',
styleUrl: 'chips-demo.css',
imports: [
FormsModule,
MatButtonModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
MatFormFieldModule,
MatIconModule,
MatToolbarModule,
ReactiveFormsModule,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ChipsDemo {
visible = true;
selectable = true;
removable = true;
addOnBlur = true;
disabledListboxes = false;
listboxesWithAvatar = false;
disableInputs = false;
editable = false;
message = '';
shirtSizes = [
{label: 'Extra Small', avatar: 'XS', disabled: false},
{label: 'Small', avatar: 'S', disabled: false},
{label: 'Medium', avatar: 'M', disabled: true},
{label: 'Large', avatar: 'L', disabled: false},
];
restaurantHints = [
{label: 'Open Now', avatar: 'O', selected: true},
{label: 'Takes Reservations', avatar: 'R', selected: false},
{label: 'Pet Friendly', avatar: 'P', selected: true},
{label: 'Good for Brunch', avatar: 'B', selected: false},
];
// Enter, comma, semi-colon
separatorKeysCodes = [ENTER, COMMA, 186];
selectedPeople = null;
people: Person[] = [
{name: 'Kara'},
{name: 'Jeremy'},
{name: 'Topher'},
{name: 'Elad'},
{name: 'Kristiyan'},
{name: 'Paul'},
];
availableColors: DemoColor[] = [
{name: 'none', color: undefined},
{name: 'Primary', color: 'primary'},
{name: 'Accent', color: 'accent'},
{name: 'Warn', color: 'warn'},
];
announcer = inject(LiveAnnouncer);
displayMessage(message: string): void {
this.message = message;
}
add(event: MatChipInputEvent): void {
const value = (event.value || '').trim();
// Add our person
if (value) {
this.people.push({name: value});
}
// Clear the input value
event.chipInput!.clear();
}
remove(person: Person): void {
const index = this.people.indexOf(person);
if (index >= 0) {
this.people.splice(index, 1);
this.announcer.announce(`Removed ${person.name}`);
}
}
edit(person: Person, event: MatChipEditedEvent): void {
if (!event.value.trim().length) {
this.remove(person);
return;
}
const index = this.people.indexOf(person);
const newPeople = this.people.slice();
newPeople[index] = {...newPeople[index], name: event.value};
this.people = newPeople;
}
toggleVisible(): void {
this.visible = false;
}
selectedColors: string[] = ['Primary', 'Warn'];
selectedColor = 'Accent';
}
| {
"end_byte": 3637,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/chips/chips-demo.ts"
} |
components/src/dev-app/cdk-experimental-combobox/cdk-combobox-demo.html_0_367 | Toggle Combobox!
<br>
<button cdkCombobox #trigger="cdkCombobox" class="example-combobox" [cdkComboboxTriggerFor]="panel" [openActions]="'toggle'">
No Value
</button>
<ng-template #panel>
<div cdkComboboxPopup [firstFocus]="input">
<input #input>
<button (click)="trigger.updateAndClose(input.value)">Apply</button>
</div>
</ng-template>
| {
"end_byte": 367,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-experimental-combobox/cdk-combobox-demo.html"
} |
components/src/dev-app/cdk-experimental-combobox/BUILD.bazel_0_300 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "cdk-experimental-combobox",
srcs = glob(["**/*.ts"]),
assets = [
"cdk-combobox-demo.html",
],
deps = [
"//src/cdk-experimental/combobox",
],
)
| {
"end_byte": 300,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-experimental-combobox/BUILD.bazel"
} |
components/src/dev-app/cdk-experimental-combobox/cdk-combobox-demo.ts_0_513 | /**
* @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 {CdkComboboxModule} from '@angular/cdk-experimental/combobox';
import {ChangeDetectionStrategy, Component} from '@angular/core';
@Component({
templateUrl: 'cdk-combobox-demo.html',
imports: [CdkComboboxModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CdkComboboxDemo {}
| {
"end_byte": 513,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-experimental-combobox/cdk-combobox-demo.ts"
} |
components/src/dev-app/input/input-demo.ts_0_4444 | /**
* @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 {AsyncPipe} from '@angular/common';
import {FormControl, Validators, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {
FloatLabelType,
MatFormFieldAppearance,
MatFormFieldModule,
} from '@angular/material/form-field';
import {ErrorStateMatcher, ThemePalette} from '@angular/material/core';
import {
FormFieldCustomControlExample,
MyTelInput,
} from '@angular/components-examples/material/form-field';
import {MatInputModule} from '@angular/material/input';
import {MatAutocompleteModule} from '@angular/material/autocomplete';
import {MatButtonModule} from '@angular/material/button';
import {MatButtonToggleModule} from '@angular/material/button-toggle';
import {MatCardModule} from '@angular/material/card';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatIconModule} from '@angular/material/icon';
import {MatTabsModule} from '@angular/material/tabs';
import {MatToolbarModule} from '@angular/material/toolbar';
import {MatTooltipModule} from '@angular/material/tooltip';
import {BehaviorSubject} from 'rxjs';
let max = 5;
const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
@Component({
selector: 'input-demo',
templateUrl: 'input-demo.html',
styleUrl: 'input-demo.css',
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
AsyncPipe,
FormsModule,
MatAutocompleteModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
MatTabsModule,
MatToolbarModule,
FormFieldCustomControlExample,
MyTelInput,
ReactiveFormsModule,
MatTooltipModule,
],
})
export class InputDemo {
color: ThemePalette = 'primary';
floatingLabel: FloatLabelType = 'auto';
requiredField: boolean;
disableTextarea: boolean;
hideRequiredMarker: boolean;
ctrlDisabled = false;
textareaNgModelValue: string;
textareaAutosizeEnabled = false;
appearance: MatFormFieldAppearance = 'fill';
prefixSuffixAppearance: MatFormFieldAppearance = 'fill';
placeholderTestControl = new FormControl('', Validators.required);
options: string[] = ['One', 'Two', 'Three'];
showSecondPrefix = false;
showPrefix = true;
showHidden = false;
hiddenLabel = 'Label';
hiddenAppearance: MatFormFieldAppearance = 'outline';
name: string;
errorMessageExample1: string;
errorMessageExample2: string;
errorMessageExample3: string;
errorMessageExample4: string;
dividerColorExample1: string;
dividerColorExample2: string;
dividerColorExample3: string;
items: {value: number}[] = [{value: 10}, {value: 20}, {value: 30}, {value: 40}, {value: 50}];
rows = 8;
formControl = new FormControl('hello', Validators.required);
emailFormControl = new FormControl('', [Validators.required, Validators.pattern(EMAIL_REGEX)]);
delayedFormControl = new FormControl('');
model = 'hello';
isAutofilled = false;
customAutofillStyle = true;
legacyAppearance: string;
standardAppearance: string;
fillAppearance: string;
outlineAppearance: string;
appearances: MatFormFieldAppearance[] = ['fill', 'outline'];
hasLabel$ = new BehaviorSubject(true);
constructor() {
setTimeout(() => {
this.delayedFormControl.setValue('hello');
this.hasLabel$.next(false);
}, 100);
}
addABunch(n: number) {
for (let x = 0; x < n; x++) {
this.items.push({value: ++max});
}
}
customErrorStateMatcher: ErrorStateMatcher = {
isErrorState: (control: FormControl | null) => {
if (control) {
const hasInteraction = control.dirty || control.touched;
const isInvalid = control.invalid;
return !!(hasInteraction && isInvalid);
}
return false;
},
};
togglePlaceholderTestValue() {
this.placeholderTestControl.setValue(this.placeholderTestControl.value === '' ? 'Value' : '');
}
togglePlaceholderTestTouched() {
this.placeholderTestControl.touched
? this.placeholderTestControl.markAsUntouched()
: this.placeholderTestControl.markAsTouched();
}
parseNumber(value: string): number {
return Number(value);
}
}
| {
"end_byte": 4444,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/input/input-demo.ts"
} |
components/src/dev-app/input/BUILD.bazel_0_849 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "input",
srcs = glob(["**/*.ts"]),
assets = [
":input_demo_scss",
"input-demo.html",
],
deps = [
"//src/components-examples/material/form-field",
"//src/material/autocomplete",
"//src/material/button",
"//src/material/button-toggle",
"//src/material/card",
"//src/material/checkbox",
"//src/material/form-field",
"//src/material/icon",
"//src/material/input",
"//src/material/tabs",
"//src/material/toolbar",
"//src/material/tooltip",
"@npm//@angular/forms",
],
)
sass_binary(
name = "input_demo_scss",
src = "input-demo.scss",
deps = ["//src/cdk:sass_lib"],
)
| {
"end_byte": 849,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/input/BUILD.bazel"
} |
components/src/dev-app/input/input-demo.scss_0_581 | @use '@angular/cdk';
.demo-basic {
padding: 0;
}
.demo-basic .mat-card-content {
padding: 16px;
}
.demo-horizontal-spacing {
margin: 0 12px;
}
.demo-full-width {
width: 100%;
}
.demo-block {
display: block;
}
.demo-card {
margin: 16px;
mat-card-content {
font-size: 16px;
}
}
.demo-text-align-end {
text-align: end;
}
.demo-textarea {
resize: none;
border: none;
overflow: auto;
padding: 0;
background: lightblue;
}
.demo-custom-autofill-style {
@include cdk.text-field-autofill-color(transparent, red);
}
.demo-rows {
width: 30px;
}
| {
"end_byte": 581,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/input/input-demo.scss"
} |
components/src/dev-app/input/input-demo.html_0_6484 | <mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Basic</mat-toolbar>
<mat-card-content>
<form>
<mat-form-field class="demo-full-width">
<mat-label>Company (disabled)</mat-label>
<input matNativeControl disabled value="Google">
</mat-form-field>
<table style="width: 100%" cellspacing="0"><tr>
<td>
<mat-form-field style="width: 100%">
<input matInput placeholder="First name">
</mat-form-field>
</td>
<td>
<mat-form-field style="width: 100%">
<mat-label>Long last name that will be truncated</mat-label>
<input matInput>
</mat-form-field>
</td>
</tr></table>
<p>
<mat-form-field class="demo-full-width">
<mat-label>Address</mat-label>
<textarea matInput>1600 Amphitheatre Pkway</textarea>
</mat-form-field>
<mat-form-field class="demo-full-width">
<mat-label>Address 2</mat-label>
<textarea matNativeControl></textarea>
</mat-form-field>
</p>
<table style="width: 100%" cellspacing="0"><tr>
<td>
<mat-form-field class="demo-full-width">
<mat-label>City</mat-label>
<input matInput value="Mountain View">
</mat-form-field>
</td>
<td>
<mat-form-field class="demo-full-width">
<mat-label>State</mat-label>
<input matInput maxLength="2" value="CA">
</mat-form-field>
</td>
<td>
<mat-form-field class="demo-full-width">
<mat-label>Postal code</mat-label>
<input matInput #postalCode maxLength="5" value="94043" pattern="[0-9]{5}">
<mat-hint align="end">
<mat-icon>mode_edit</mat-icon>
<span aria-live="polite">{{postalCode.value.length}} / 5</span>
</mat-hint>
</mat-form-field>
</td>
</tr></table>
</form>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-number-input-tooltip">
<mat-toolbar color="primary">Number Input + Tooltip</mat-toolbar>
<mat-card-content>
<form>
<mat-form-field>
<mat-label>Pump Flow</mat-label>
<input matNativeControl value="10" type="number"><!-- -->
<span matSuffix matTooltip="Milliliter per Minute">ml/min</span>
</mat-form-field>
</form>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Error messages</mat-toolbar>
<mat-card-content>
<h4>Regular</h4>
<p>
<mat-form-field>
<mat-label>Example</mat-label>
<input matInput [(ngModel)]="errorMessageExample1" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Email</mat-label>
<input matInput [formControl]="emailFormControl">
@if (emailFormControl.hasError('required')) {
<mat-error>This field is required</mat-error>
}
@if (emailFormControl.hasError('pattern')) {
<mat-error>Please enter a valid email address</mat-error>
}
</mat-form-field>
</p>
<h4>With hint</h4>
<mat-form-field>
<mat-label>Example</mat-label>
<input matInput [(ngModel)]="errorMessageExample2" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
<form novalidate>
<h4>Inside a form</h4>
<mat-form-field>
<mat-label>Example</mat-label>
<input matInput name="example" [(ngModel)]="errorMessageExample3" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<button color="primary" mat-raised-button>Submit</button>
</form>
<h4>With a custom error function</h4>
<mat-form-field>
<mat-label>Example</mat-label>
<input matInput
[(ngModel)]="errorMessageExample4"
[errorStateMatcher]="customErrorStateMatcher"
required>
<mat-error>This field is required</mat-error>
</mat-form-field>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Prefix + Suffix</mat-toolbar>
<mat-card-content>
<h4>Text</h4>
<mat-form-field [appearance]="prefixSuffixAppearance" class="demo-text-align-end">
<mat-label>Amount</mat-label>
<input matInput>
@if (showPrefix) {
<span matTextPrefix>$</span>
}
<span matTextSuffix>.00</span>
</mat-form-field>
<h4>Text (always outline)</h4>
<mat-form-field appearance="outline" class="demo-text-align-end">
<mat-label>Amount</mat-label>
<input matInput>
<span matTextPrefix>$</span>
<span matTextSuffix>.00</span>
</mat-form-field>
<h4>Icons</h4>
<mat-form-field [appearance]="prefixSuffixAppearance">
<mat-label>Amount</mat-label>
<input matInput>
@if (showPrefix) {
<mat-icon matIconPrefix>calendar_today</mat-icon>
}
<mat-icon matIconSuffix>mode_edit</mat-icon>
</mat-form-field>
<h4>Icon buttons</h4>
<mat-form-field [appearance]="prefixSuffixAppearance">
<mat-label>Amount</mat-label>
<input matInput>
@if (showPrefix) {
<button mat-icon-button matIconPrefix>
<mat-icon>calendar_today</mat-icon>
</button>
}
<button mat-icon-button matIconSuffix>
<mat-icon>mode_edit</mat-icon>
</button>
</mat-form-field>
<h4>Text & Icons</h4>
<mat-form-field [appearance]="prefixSuffixAppearance">
<mat-label>Amount</mat-label>
<input matInput>
<span matTextPrefix>$</span>
<span matTextSuffix>.00</span>
@if (showPrefix) {
<button mat-icon-button matIconPrefix>
<mat-icon>calendar_today</mat-icon>
</button>
}
<button mat-icon-button matIconSuffix>
<mat-icon>mode_edit</mat-icon>
</button>
</mat-form-field>
<p>
<mat-button-toggle-group [(ngModel)]="prefixSuffixAppearance">
<mat-button-toggle value="fill">Fill</mat-button-toggle>
<mat-button-toggle value="outline">Outline</mat-button-toggle>
</mat-button-toggle-group>
</p>
<p>
<button (click)="showPrefix = !showPrefix">Toggle prefix</button>
</p>
</mat-card-content>
</mat-card> | {
"end_byte": 6484,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/input/input-demo.html"
} |
components/src/dev-app/input/input-demo.html_6486_9262 | <mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Divider Colors</mat-toolbar>
<mat-card-content>
<h4>Input</h4>
<mat-form-field color="primary" >
<mat-label>Default color</mat-label>
<input matInput value="example">
</mat-form-field>
<mat-form-field color="accent">
<mat-label>Accent color</mat-label>
<input matInput value="example">
</mat-form-field>
<mat-form-field color="warn">
<mat-label>Warn color</mat-label>
<input matInput value="example">
</mat-form-field>
<h4>Textarea</h4>
<mat-form-field color="primary">
<mat-label>Default color</mat-label>
<textarea matInput>example</textarea>
</mat-form-field>
<mat-form-field color="accent">
<mat-label>Accent color</mat-label>
<textarea matInput>example</textarea>
</mat-form-field>
<mat-form-field color="warn">
<mat-label>Warn color</mat-label>
<textarea matInput>example</textarea>
</mat-form-field>
<h4>With error</h4>
<mat-form-field color="primary" >
<mat-label>Default color</mat-label>
<input matInput [(ngModel)]="dividerColorExample1" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<mat-form-field color="accent">
<mat-label>Accent color</mat-label>
<input matInput [(ngModel)]="dividerColorExample2" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<mat-form-field color="warn">
<mat-label>Warn color</mat-label>
<input matInput [(ngModel)]="dividerColorExample3" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Hints</mat-toolbar>
<mat-card-content>
<h4>Input</h4>
<p>
<mat-form-field class="demo-full-width">
<mat-label>Character count (100 max)</mat-label>
<input matInput
#characterCountInputHintExample
maxLength="100"
value="Hello world. How are you?">
<mat-hint align="end" aria-live="polite">
{{characterCountInputHintExample.value.length}} / 100
</mat-hint>
</mat-form-field>
</p>
<h4>Textarea</h4>
<p>
<mat-form-field class="demo-full-width">
<mat-label>Character count (100 max)</mat-label>
<textarea matInput
#characterCountTextareaHintExample
maxLength="100">Hello world. How are you?</textarea>
<mat-hint align="end" aria-live="polite">
{{characterCountTextareaHintExample.value.length}} / 100
</mat-hint>
</mat-form-field>
</p>
</mat-card-content>
</mat-card> | {
"end_byte": 9262,
"start_byte": 6486,
"url": "https://github.com/angular/components/blob/main/src/dev-app/input/input-demo.html"
} |
components/src/dev-app/input/input-demo.html_9264_16478 | <mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">
<span>
Hello
<mat-form-field color="accent">
<mat-label>First name</mat-label>
<input matInput [(ngModel)]="name" type="text">
</mat-form-field>,
how are you?
</span>
</mat-toolbar>
<mat-card-content>
<p>
<mat-form-field>
<mat-label>Disabled field</mat-label>
<input matInput disabled value="Value">
</mat-form-field>
<mat-form-field>
<mat-label>Label</mat-label>
<input matInput disabled required>
</mat-form-field>
<mat-form-field>
<mat-label>Required field</mat-label>
<input matInput required>
</mat-form-field>
</p>
<p>
<mat-form-field style="width: 100%">
<mat-label>100% width label</mat-label>
<input matInput>
</mat-form-field>
</p>
<p>
<mat-form-field style="width: 100%">
<mat-label>Character count (100 max)</mat-label>
<input matInput #input maxLength="100">
<mat-hint align="end" aria-live="polite">{{input.value.length}} / 100</mat-hint>
</mat-form-field>
</p>
<p>
<mat-form-field hintLabel="Hint label" style="width: 100%">
<mat-label>Show hint label</mat-label>
<input matInput>
</mat-form-field>
</p>
<p>
<mat-form-field>
<input matInput>
<mat-label>
I <mat-icon>favorite</mat-icon><strong>bold</strong> label
</mat-label>
<mat-hint>
I also <mat-icon>home</mat-icon> <em>italic</em> hint labels
</mat-hint>
</mat-form-field>
</p>
<p>
<mat-form-field hintLabel="Hint label" style="width: 100%">
<mat-label>Show hint label with character count</mat-label>
<input matInput #hintLabelWithCharCount>
<mat-hint align="end" aria-live="polite">{{hintLabelWithCharCount.value.length}}</mat-hint>
</mat-form-field>
</p>
<p>
<mat-form-field style="margin-bottom: 4em">
<mat-label>Enter text to count</mat-label>
<textarea matInput #longHint></textarea>
<mat-hint>Enter
some text to count how many characters are in it. The character count is shown on
the right.
</mat-hint>
<mat-hint align="end" style="white-space: nowrap" aria-live="polite">
Length: {{longHint.value.length}}
</mat-hint>
</mat-form-field>
</p>
<p>
<mat-checkbox [(ngModel)]="color">Check to change the color:</mat-checkbox>
<mat-form-field [color]="color ? 'primary' : 'accent'">
<input matInput [placeholder]="color ? 'Primary color' : 'Accent color'">
</mat-form-field>
</p>
<p>
<mat-checkbox [(ngModel)]="requiredField"> Check to make required:</mat-checkbox>
<mat-form-field>
<mat-label>{{requiredField ? 'Required field' : 'Not required field'}}</mat-label>
<input matInput [required]="requiredField">
</mat-form-field>
</p>
<p>
<mat-checkbox [(ngModel)]="hideRequiredMarker">Check to hide the required marker:</mat-checkbox>
<mat-form-field [hideRequiredMarker]="hideRequiredMarker" style="width: 300px">
<mat-label>
{{hideRequiredMarker ? 'Required Without Marker' : 'Required With Marker'}}
</mat-label>
<input matInput required>
</mat-form-field>
</p>
<p>
<mat-button-toggle-group [(ngModel)]="floatingLabel">
<mat-button-toggle value="auto">Auto Float</mat-button-toggle>
<mat-button-toggle value="always">Always Float</mat-button-toggle>
</mat-button-toggle-group>
</p>
<p>
<mat-form-field [floatLabel]="floatingLabel">
<mat-label>Label</mat-label>
<input matInput>
</mat-form-field>
</p>
<p>
<mat-form-field [floatLabel]="floatingLabel">
<mat-label>What is your favorite color?</mat-label>
<input matInput type="color" value="#00ff00">
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Prefixed</mat-label>
<input matInput value="example">
<span matTextPrefix>Example: </span>
</mat-form-field>
<mat-form-field class="demo-text-align-end">
<mat-label>Suffixed</mat-label>
<input matInput value="123">
<span matTextSuffix>.00 €</span>
</mat-form-field>
<br/>
Both:
<mat-form-field class="demo-text-align-end">
<mat-label>Email address</mat-label>
<input matInput #email="matInput" value="angular-core">
<span matIconPrefix>
<mat-icon [class.primary]="email.focused">email</mat-icon>
</span>
<span matTextSuffix [class.primary]="email.focused"> @gmail.com</span>
</mat-form-field>
</p>
<p>
Empty: <mat-form-field><input matInput></mat-form-field>
<label>Label: <mat-form-field><input matInput></mat-form-field></label>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Dynamic Subscript Sizing</mat-toolbar>
<mat-card-content>
<p>
One validation
<mat-form-field appearance="fill" [color]="color" subscriptSizing="dynamic">
<mat-label>Fill appearance</mat-label>
<input matInput [(ngModel)]="fillAppearance" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
</p>
<p>
One very long validation that wraps
<mat-form-field appearance="fill" [color]="color" subscriptSizing="dynamic"
style="width: 212px">
<mat-label>Fill appearance</mat-label>
<input matInput [(ngModel)]="fillAppearance" required>
<mat-error>This field is extremely, very much, absolutely positively required so do not forget it!</mat-error>
</mat-form-field>
</p>
<p>
One hint and one validation
<mat-form-field appearance="fill" [color]="color" subscriptSizing="dynamic">
<mat-label>Fill appearance</mat-label>
<input matInput [(ngModel)]="fillAppearance" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
</p>
<p>
Multiple errors
<mat-form-field appearance="fill" [color]="color" subscriptSizing="dynamic">
<mat-label>Fill appearance</mat-label>
<input matInput [(ngModel)]="fillAppearance" required>
<mat-error>AAA</mat-error>
<mat-error>BBB</mat-error>
<mat-error>CCC</mat-error>
</mat-form-field>
</p>
<p>
Multiple hints
<mat-form-field appearance="fill" [color]="color" subscriptSizing="dynamic">
<mat-label>Fill appearance</mat-label>
<input matInput>
<mat-hint>aaa</mat-hint>
<mat-hint align="end">bbb</mat-hint>
</mat-form-field>
</p>
<p>
No hints or errors
<mat-form-field appearance="fill" [color]="color" subscriptSizing="dynamic">
<mat-label>Fill appearance</mat-label>
<input matInput>
</mat-form-field>
</p>
</mat-card-content>
</mat-card>
| {
"end_byte": 16478,
"start_byte": 9264,
"url": "https://github.com/angular/components/blob/main/src/dev-app/input/input-demo.html"
} |
components/src/dev-app/input/input-demo.html_16480_24053 | at-card class="demo-card demo-basic">
<mat-toolbar color="primary">Number Inputs</mat-toolbar>
<mat-card-content>
<table width="100%">
<thead>
<td>Table</td>
<td colspan="3">
<button (click)="addABunch(5)">Add 5</button>
<button (click)="addABunch(10)">Add 10</button>
<button (click)="addABunch(100)">Add 100</button>
<button (click)="addABunch(1000)">Add 1000</button>
</td>
</thead>
@for (item of items; track item; let i = $index) {
<tr>
<td>{{i+1}}</td>
<td>
<mat-form-field>
<mat-label>Value</mat-label>
<input matInput
type="number"
[(ngModel)]="items[i].value">
</mat-form-field>
</td>
<td>
<input type="number" [(ngModel)]="items[i].value">
</td>
<td>{{item.value}}</td>
</tr>
}
</table>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Forms</mat-toolbar>
<mat-card-content>
<mat-form-field>
<mat-label>Reactive</mat-label>
<input matInput [formControl]="formControl">
</mat-form-field>
<mat-form-field>
<mat-label>Template</mat-label>
<input matInput [(ngModel)]="model" required [disabled]="ctrlDisabled">
</mat-form-field>
<button mat-raised-button color="primary"
(click)="formControl.enabled ? formControl.disable() : formControl.enable()">
DISABLE REACTIVE CTRL
</button>
<button mat-raised-button color="primary" (click)="ctrlDisabled = !ctrlDisabled">
DISABLE TD CTRL
</button>
<div>
<mat-form-field>
<mat-label>Delayed value</mat-label>
<input matInput [formControl]="delayedFormControl">
</mat-form-field>
</div>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Floating labels</mat-toolbar>
<mat-card-content>
<div>
<mat-form-field>
<input matInput [formControl]="placeholderTestControl">
</mat-form-field>
<mat-form-field>
<input matInput [formControl]="placeholderTestControl" placeholder="Only placeholder">
</mat-form-field>
<mat-form-field>
<mat-label>Only label</mat-label>
<input matInput [formControl]="placeholderTestControl">
</mat-form-field>
<mat-form-field>
<mat-label>Label and placeholder</mat-label>
<input matInput [formControl]="placeholderTestControl" placeholder="This is the placeholder">
</mat-form-field>
<mat-form-field floatLabel="always">
<mat-label>Always float</mat-label>
<input matInput [formControl]="placeholderTestControl" placeholder="This is the placeholder">
</mat-form-field>
<mat-form-field>
<mat-label>Label w/ placeholder</mat-label>
<input matInput [formControl]="placeholderTestControl" placeholder="Placeholder">
</mat-form-field>
</div>
<button
mat-raised-button
color="primary"
(click)="togglePlaceholderTestValue()">Toggle value</button>
<button
mat-raised-button
color="primary"
(click)="togglePlaceholderTestTouched()">Toggle touched</button>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Textarea Autosize</mat-toolbar>
<mat-card-content>
<h3>Regular <textarea></h3>
<textarea class="demo-textarea" cdkTextareaAutosize cdkAutosizeMaxRows="10"></textarea>
<h3>Regular <textarea> with maxRows and minRows</h3>
<div>
<label>minRows<input type="number" #minRows class="demo-rows" (input)="1+1"></label>
<label>maxRows<input type="number" #maxRows class="demo-rows" (input)="1+1"></label>
</div>
<textarea class="demo-textarea"
cdkTextareaAutosize
[cdkAutosizeMinRows]="parseNumber(minRows.value)"
[cdkAutosizeMaxRows]="parseNumber(maxRows.value)"></textarea>
<button type="button" (click)="minRows.value = (parseNumber(minRows.value) - 1) + ''">Decrement minRows</button>
<h3><textarea> with mat-form-field</h3>
<div>
<mat-form-field>
<mat-label>Autosized textarea</mat-label>
<textarea matInput cdkTextareaAutosize cdkAutosizeMaxRows="10"></textarea>
</mat-form-field>
</div>
<h3><textarea> with ngModel</h3>
<div>
<label>Input with same ngModel <input [(ngModel)]="textareaNgModelValue"></label>
</div>
<label>
Plain textarea with auto size
<textarea cdkTextareaAutosize [(ngModel)]="textareaNgModelValue"></textarea>
</label>
<h3><textarea> with bindable autosize </h3>
<mat-checkbox [(ngModel)]="textareaAutosizeEnabled" name="autosizeEnabledCheckbox">
Autosize enabled
</mat-checkbox>
<textarea [cdkTextareaAutosize]="textareaAutosizeEnabled"></textarea>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Appearance</mat-toolbar>
<mat-card-content>
<mat-form-field appearance="fill" [color]="color">
<mat-label>Fill appearance</mat-label>
<input matInput [(ngModel)]="fillAppearance" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
<mat-form-field appearance="outline" [color]="color">
<mat-label>Outline appearance</mat-label>
<input matInput [(ngModel)]="outlineAppearance" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
<table style="width: 100%" cellspacing="0"><tr>
<td>
<mat-form-field appearance="fill" [color]="color" style="width: 100%">
<mat-label>Fill appearance</mat-label>
<input matInput [(ngModel)]="fillAppearance" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
</td>
<td>
<mat-form-field appearance="outline" [color]="color" style="width: 100%">
<mat-label>Outline appearance</mat-label>
<input matInput [(ngModel)]="outlineAppearance" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
</td>
</tr></table>
<mat-button-toggle-group [(ngModel)]="color">
<mat-button-toggle value="primary">Primary</mat-button-toggle>
<mat-button-toggle value="accent">Accent</mat-button-toggle>
<mat-button-toggle value="warn">Warn</mat-button-toggle>
</mat-button-toggle-group>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Autofill</mat-toolbar>
<mat-card-content>
<form novalidate>
<mat-checkbox [(ngModel)]="customAutofillStyle" name="custom">
Use custom autofill style
</mat-checkbox>
<mat-form-field>
<mat-label>Autofill monitored</mat-label>
<input matInput (cdkAutofill)="isAutofilled = $event.isAutofilled" name="autofill"
[class.demo-custom-autofill-style]="customAutofillStyle">
</mat-form-field>
<button color="primary" mat-raised-button>Submit</button>
<span> is autofilled? {{isAutofilled ? 'yes' : 'no'}}</span>
</form>
</mat-card-content>
</mat-card>
| {
"end_byte": 24053,
"start_byte": 16480,
"url": "https://github.com/angular/components/blob/main/src/dev-app/input/input-demo.html"
} |
components/src/dev-app/input/input-demo.html_24055_31592 | at-card class="demo-card demo-basic">
<mat-toolbar color="primary">Disabled interactive inputs</mat-toolbar>
<mat-card-content>
@for (appearance of appearances; track $index) {
<div>
<mat-form-field [appearance]="appearance">
<mat-label>Label</mat-label>
<input
matNativeControl
disabled
disabledInteractive
value="Value"
matTooltip="I can trigger a tooltip!">
</mat-form-field>
<mat-form-field [appearance]="appearance">
<mat-label>Label</mat-label>
<input
matNativeControl
disabled
disabledInteractive
matTooltip="I can trigger a tooltip!">
</mat-form-field>
<mat-form-field [appearance]="appearance">
<mat-label>Label</mat-label>
<input
matNativeControl
disabled
disabledInteractive
placeholder="Placeholder"
matTooltip="I can trigger a tooltip!">
</mat-form-field>
<mat-form-field [appearance]="appearance">
<input
matNativeControl
disabled
disabledInteractive
matTooltip="I can trigger a tooltip!"
placeholder="Placeholder">
</mat-form-field>
</div>
}
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Textarea form-fields</mat-toolbar>
<mat-card-content>
<mat-form-field appearance="fill" class="demo-horizontal-spacing">
<mat-label>Label</mat-label>
<textarea matInput [disabled]="disableTextarea"></textarea>
</mat-form-field>
<mat-form-field appearance="outline" class="demo-horizontal-spacing">
<mat-label>Label</mat-label>
<textarea matInput [disabled]="disableTextarea"></textarea>
</mat-form-field>
<p>
<mat-checkbox [(ngModel)]="disableTextarea">Disable textarea form-fields</mat-checkbox>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Appearance toggle</mat-toolbar>
<mat-card-content>
<mat-form-field [appearance]="appearance" class="demo-horizontal-spacing">
<mat-label>Label</mat-label>
<input matInput value="Initial">
</mat-form-field>
<p>
<mat-button-toggle-group [(ngModel)]="appearance">
<mat-button-toggle value="fill">Fill</mat-button-toggle>
<mat-button-toggle value="outline">Outline</mat-button-toggle>
</mat-button-toggle-group>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Autocomplete</mat-toolbar>
<mat-card-content>
<p>
<mat-form-field>
<mat-label>Pick Number</mat-label>
<input type="text" aria-label="Number" matInput
[matAutocomplete]="autoComplete1">
<mat-autocomplete #autoComplete1="matAutocomplete">
@for (option of options; track option) {
<mat-option [value]="option">{{option}}</mat-option>
}
</mat-autocomplete>
</mat-form-field>
</p>
<p>
<mat-form-field appearance="outline">
<mat-label>Pick Number</mat-label>
<input type="text" aria-label="Number" matInput
[matAutocomplete]="autoComplete2">
<mat-autocomplete #autoComplete2="matAutocomplete">
@for (option of options; track option) {
<mat-option [value]="option">{{option}}</mat-option>
}
</mat-autocomplete>
</mat-form-field>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Outline form field in a tab</mat-toolbar>
<mat-card-content>
<mat-tab-group>
<mat-tab label="Tab 1">
<mat-form-field appearance="outline">
<mat-label>Tab 1 input</mat-label>
<input matInput value="test">
</mat-form-field>
<mat-form-field appearance="outline" class="demo-text-align-end">
<mat-label>Amount</mat-label>
<input matInput>
<span matTextPrefix>$ </span>
<span matTextSuffix>.00</span>
</mat-form-field>
</mat-tab>
<mat-tab label="Tab 2">
<mat-form-field appearance="outline">
<mat-label>Tab 2 input</mat-label>
<input matInput value="test">
</mat-form-field>
<mat-form-field appearance="outline" class="demo-text-align-end">
<mat-label>Amount</mat-label>
<input matInput>
<span matTextPrefix>$ </span>
@if (showSecondPrefix) {
<span matTextPrefix>! </span>
}
<span matTextSuffix>.00</span>
</mat-form-field>
</mat-tab>
</mat-tab-group>
<button (click)="showSecondPrefix = !showSecondPrefix">Toggle second prefix.</button>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Baseline</mat-toolbar>
<mat-card-content>
<span style="display: inline-block; margin-top: 20px">Shifted text</span>
<mat-form-field>
<mat-label>Label</mat-label>
<input matInput>
</mat-form-field>
<p>
Textarea alignment
</p>
<mat-form-field appearance="outline">
<mat-label>Textarea</mat-label>
<textarea matInput rows="1"></textarea>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Examples</mat-toolbar>
<mat-card-content>
<h4>Custom control</h4>
<form-field-custom-control-example></form-field-custom-control-example>
<p>
<mat-form-field appearance="outline">
<mat-label>Phone number</mat-label>
<example-tel-input required></example-tel-input>
<mat-icon matIconSuffix>phone</mat-icon>
<mat-hint>Include area code</mat-hint>
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Label</mat-label>
<select matNativeControl>
<option>First</option>
<option>Second</option>
</select>
</mat-form-field>
</p>
<p>
<mat-form-field appearance="outline">
<mat-label>Label</mat-label>
<select matNativeControl>
<option>First</option>
<option>Second</option>
</select>
</mat-form-field>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Without label</mat-toolbar>
<mat-card-content>
<h4>Label removed</h4>
<p>
<mat-form-field appearance="outline">
@if (hasLabel$ | async){
<mat-label>My input</mat-label>
}
<input matInput type="text" />
</mat-form-field>
</p>
<p>
<mat-form-field>
@if (hasLabel$ | async){
<mat-label>My input</mat-label>
}
<input matInput type="text" />
</mat-form-field>
</p>
<h4>No defined label</h4>
<p>
<mat-form-field appearance="outline">
<input matInput type="text"/>
</mat-form-field>
</p>
<p>
<mat-form-field>
<input matInput type="text"/>
</mat-form-field>
</p>
</mat-card-content>
</mat-card>
| {
"end_byte": 31592,
"start_byte": 24055,
"url": "https://github.com/angular/components/blob/main/src/dev-app/input/input-demo.html"
} |
components/src/dev-app/input/input-demo.html_31595_32203 | at-card class="demo-card demo-basic">
<mat-card-content>
<button (click)="showHidden = !showHidden">Show/hide hidden form-field</button>
<button (click)="hiddenLabel = hiddenLabel + '!!'">Add !!</button>
<button (click)="hiddenAppearance = hiddenAppearance === 'fill' ? 'outline' : 'fill'">
Toggle appearance
</button>
<p [style.display]="showHidden ? 'block' : 'none'">
<mat-form-field [appearance]="hiddenAppearance">
<mat-label>{{hiddenLabel}}</mat-label>
<input matInput value="value">
</mat-form-field>
</p>
</mat-card-content>
</mat-card>
| {
"end_byte": 32203,
"start_byte": 31595,
"url": "https://github.com/angular/components/blob/main/src/dev-app/input/input-demo.html"
} |
components/src/dev-app/cdk-menu/cdk-menu-demo.css_0_683 | .example-menu {
display: flex;
flex-direction: column;
}
.example-menu .cdk-menu-group {
display: flex;
flex-direction: column;
}
.example-menu-container + .example-menu-container {
/* add some buffer for the opened menu */
margin-top: 140px;
}
.example-menu-inline > button {
display: block;
}
.example-context {
/* delineate where the context is */
border: solid 2px black;
padding: 6px;
}
demo-custom-position {
display: block;
margin-top: 20px;
}
.example-menu-container .cdk-menu-item:focus {
position: relative;
z-index: 1;
outline: 2px solid;
}
.cdk-menu-item[aria-checked='true'] {
box-shadow: inset 0 0 0 100px rgba(0, 0, 255, 0.5);
}
| {
"end_byte": 683,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-menu/cdk-menu-demo.css"
} |
components/src/dev-app/cdk-menu/cdk-menu-demo.ts_0_1305 | /**
* @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 {CdkMenuModule} from '@angular/cdk/menu';
import {ConnectedPosition} from '@angular/cdk/overlay';
import {
CdkMenuContextExample,
CdkMenuInlineExample,
CdkMenuMenubarExample,
CdkMenuNestedContextExample,
CdkMenuStandaloneMenuExample,
CdkMenuStandaloneStatefulMenuExample,
} from '@angular/components-examples/cdk/menu';
import {ChangeDetectionStrategy, Component} from '@angular/core';
@Component({
templateUrl: 'cdk-menu-demo.html',
styleUrl: 'cdk-menu-demo.css',
imports: [
CdkMenuModule,
CdkMenuStandaloneMenuExample,
CdkMenuStandaloneStatefulMenuExample,
CdkMenuMenubarExample,
CdkMenuInlineExample,
CdkMenuContextExample,
CdkMenuNestedContextExample,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CdkMenuDemo {
customPosition = [
{originX: 'center', originY: 'center', overlayX: 'center', overlayY: 'center'},
] as ConnectedPosition[];
sizes = ['Small', 'Normal', 'Large'];
colors = ['Red', 'Green', 'Blue'];
selectedSize: string | undefined = 'Normal';
selectedColor: string | undefined = 'Red';
}
| {
"end_byte": 1305,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-menu/cdk-menu-demo.ts"
} |
components/src/dev-app/cdk-menu/cdk-menu-demo.html_0_6518 | <div class="example-menu-container">
<h3>Examples</h3>
<div class="example-menu-container">
<h4>Inline Menu</h4>
<cdk-menu-inline-example></cdk-menu-inline-example>
</div>
<div class="example-menu-container">
<h4>Standalone Menu</h4>
<cdk-menu-standalone-menu-example></cdk-menu-standalone-menu-example>
</div>
<div class="example-menu-container">
<h4>Standalone Stateful Menu</h4>
<cdk-menu-standalone-stateful-menu-example></cdk-menu-standalone-stateful-menu-example>
</div>
<div class="example-menu-container">
<h4>Menu Bar</h4>
<cdk-menu-menubar-example></cdk-menu-menubar-example>
</div>
<div class="example-menu-container">
<h4>Context Menu</h4>
<cdk-menu-context-example></cdk-menu-context-example>
</div>
<div class="example-menu-container">
<h4>Nested Context Menu</h4>
<cdk-menu-nested-context-example></cdk-menu-nested-context-example>
</div>
</div>
<div class="example-menu-container">
<h3>MenuBar Example</h3>
<div cdkTargetMenuAim cdkMenuBar>
<button id="file_button" cdkMenuItem [cdkMenuTriggerFor]="file">File</button>
<button id="edit_button" cdkMenuItem [cdkMenuTriggerFor]="edit">Edit</button>
</div>
<ng-template #file>
<div cdkMenu cdkTargetMenuAim class="example-menu" id="file_menu">
<button id="share_button" cdkMenuItem [cdkMenuTriggerFor]="share">Share</button>
<button id="open_button" cdkMenuItem>Open</button>
<button id="rename_button" cdkMenuItem>Rename</button>
<button id="print_button" cdkMenuItem>Print</button>
</div>
</ng-template>
<ng-template #edit>
<div cdkMenu class="example-menu" id="edit_menu">
<button id="undo_button" cdkMenuItem>Undo</button>
<button id="redo_button" cdkMenuItem>Redo</button>
<button id="cut_button" cdkMenuItem>Cut</button>
<button id="copy_button" cdkMenuItem>Copy</button>
<button id="paste_button" cdkMenuItem>Paste</button>
</div>
</ng-template>
<ng-template #share>
<div cdkMenu class="example-menu" id="share_menu">
<button id="gvc_button" cdkMenuItem>GVC</button>
<button id="gmail_button" cdkMenuItem>Gmail</button>
<button id="twitter_button" cdkMenuItem>Twitter</button>
</div>
</ng-template>
</div>
<div class="example-menu-container">
<h3>Inline Menu Example</h3>
<div cdkMenu class="example-menu" class="example-menu-inline">
<button cdkMenuItem [cdkMenuTriggerFor]="file">Inbox</button>
<button cdkMenuItem>Starred</button>
<button cdkMenuItem>Snoozed</button>
<button cdkMenuItem>Important</button>
<button cdkMenuItem>Chats</button>
<button cdkMenuItem>Sent</button>
</div>
</div>
<div class="example-menu-container">
<h3>Standalone Menu Example</h3>
<p><button [cdkMenuTriggerFor]="someMenu">Standalone Menu</button></p>
</div>
<div class="example-menu-container">
<h3>Custom Menu Position Example</h3>
<p>The menu and context menu below should open centered on the trigger</p>
<p><button [cdkMenuTriggerFor]="someMenu" [cdkMenuPosition]="customPosition">Some Menu</button></p>
<div class="example-context" [cdkContextMenuTriggerFor]="outer" [cdkContextMenuPosition]="customPosition">
<h4>Custom Context Menu Position (Centered on Cursor)</h4>
Lucas ipsum dolor sit amet maul jade jawa ben wookiee binks lando jinn baba tatooine. Jade biggs
padmé sebulba cade dagobah. Baba lars mothma yoda. Bothan calrissian c-3p0 maul fisto lando
obi-wan. Skywalker solo darth bothan droid obi-wan ahsoka. Maul solo obi-wan calrissian antilles
yavin chewbacca lando. Mustafar ponda kit jango. C-3p0 skywalker baba grievous moff. Hutt ben
darth solo skywalker bothan skywalker maul organa. Grievous cade antilles utapau skywalker
grievous antilles chewbacca.
</div>
<ng-template #someMenu>
<div cdkMenu class="example-menu">
<button cdkMenuItem>Some Option 1</button>
<button cdkMenuItem [cdkMenuTriggerFor]="someSubMenu">Some Option 2 ></button>
<button cdkMenuItem>Some Option 3</button>
<button cdkMenuItem>Some Option 4</button>
</div>
</ng-template>
<ng-template #someSubMenu>
<div cdkMenu class="example-menu">
<button cdkMenuItem>Some Option 1</button>
<button cdkMenuItem>Some Option 2</button>
<button cdkMenuItem>Some Option 3</button>
<button cdkMenuItem>Some Option 4</button>
</div>
</ng-template>
<ng-template #outer>
<div cdkMenu class="example-menu" id="outer_menu">
<button cdkMenuItem>Undo</button>
<button cdkMenuItem>Redo</button>
</div>
</ng-template>
<ng-template #inner>
<div cdkMenu class="example-menu" id="inner_menu">
<button cdkMenuItem>Cut</button>
<button cdkMenuItem>Copy</button>
<button cdkMenuItem>Paste</button>
</div>
</ng-template>
</div>
<div class="example-menu-container">
<h3>Radio items</h3>
<button [cdkMenuTriggerFor]="sizeMenu">Size menu (items directly in menu)</button>
<button [cdkMenuTriggerFor]="colorMenu">Color menu (items in menu group)</button>
<button [cdkMenuTriggerFor]="sizeAndColorMenu">Size & Color menu (items in directly in menu & in menu group)</button>
<ng-template #sizeMenu>
<div class="example-menu" cdkMenu>
@for (size of sizes; track size) {
<button
cdkMenuItemRadio
[cdkMenuItemChecked]="selectedSize === size"
(cdkMenuItemTriggered)="selectedSize = size">{{size}}</button>
}
</div>
</ng-template>
<ng-template #colorMenu>
<div class="example-menu" cdkMenu>
<div cdkMenuGroup>
@for (color of colors; track color) {
<button
cdkMenuItemRadio
[cdkMenuItemChecked]="selectedColor === color"
(cdkMenuItemTriggered)="selectedColor = color">{{color}}</button>
}
</div>
</div>
</ng-template>
<ng-template #sizeAndColorMenu>
<div class="example-menu" cdkMenu>
@for (size of sizes; track size) {
<button
cdkMenuItemRadio
[cdkMenuItemChecked]="selectedSize === size"
(cdkMenuItemTriggered)="selectedSize = size">{{size}}</button>
}
<hr />
<div cdkMenuGroup>
@for (color of colors; track color) {
<button
cdkMenuItemRadio
[cdkMenuItemChecked]="selectedColor === color"
(cdkMenuItemTriggered)="selectedColor = color">{{color}}</button>
}
</div>
</div>
</ng-template>
</div>
| {
"end_byte": 6518,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-menu/cdk-menu-demo.html"
} |
components/src/dev-app/cdk-menu/BUILD.bazel_0_337 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "cdk-menu",
srcs = glob(["**/*.ts"]),
assets = [
"cdk-menu-demo.html",
"cdk-menu-demo.css",
],
deps = [
"//src/cdk/menu",
"//src/components-examples/cdk/menu",
],
)
| {
"end_byte": 337,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-menu/BUILD.bazel"
} |
components/src/dev-app/example/example.ts_0_2003 | /**
* @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,
Injector,
Input,
OnInit,
ViewContainerRef,
inject,
} from '@angular/core';
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
import {EXAMPLE_COMPONENTS} from '@angular/components-examples';
import {loadExample} from '@angular/components-examples/private';
@Component({
selector: 'material-example',
template: `
@if (showLabel) {
<div class="label">
<span class="title"> {{title}} </span>
<span class="id"> <{{id}}> </span>
</div>
}
@if (!id) {
<div>
Could not find example {{id}}
</div>
}
`,
styles: `
.label {
display: flex;
justify-content: space-between;
align-items: flex-end;
margin: 16px 0;
}
.title {
font-size: 20px;
font-weight: 500;
}
.id {
font-size: 13px;
font-family: monospace;
color: #666;
white-space: pre;
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class Example implements OnInit {
private _injector = inject(Injector);
private _viewContainerRef = inject(ViewContainerRef);
private _changeDetectorRef = inject(ChangeDetectorRef);
/** ID of the material example to display. */
@Input() id: string;
@Input()
get showLabel(): boolean {
return this._showLabel;
}
set showLabel(v: BooleanInput) {
this._showLabel = coerceBooleanProperty(v);
}
_showLabel: boolean;
title: string;
async ngOnInit() {
this.title = EXAMPLE_COMPONENTS[this.id].title;
const example = await loadExample(this.id, this._injector);
this._viewContainerRef.createComponent(example.component, {injector: example.injector});
this._changeDetectorRef.markForCheck();
}
}
| {
"end_byte": 2003,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/example/example.ts"
} |
components/src/dev-app/example/BUILD.bazel_0_331 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "example",
srcs = glob(["**/*.ts"]),
deps = [
"//src/cdk/coercion",
"//src/components-examples",
"//src/components-examples/private",
"//src/material/expansion",
],
)
| {
"end_byte": 331,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/example/BUILD.bazel"
} |
components/src/dev-app/example/example-list.ts_0_2195 | /**
* @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 {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
import {EXAMPLE_COMPONENTS} from '@angular/components-examples';
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {MatExpansionModule} from '@angular/material/expansion';
import {Example} from './example';
/** Displays a set of components-examples in a mat-accordion. */
@Component({
selector: 'material-example-list',
imports: [MatExpansionModule, Example],
template: `
<mat-accordion multi>
@for (id of ids; track id) {
<mat-expansion-panel [expanded]="expandAll">
<mat-expansion-panel-header>
<div class="header">
<div class="title">{{_getTitle(id)}}</div>
<div class="id"> <{{id}}> </div>
</div>
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
<material-example [id]="id"></material-example>
</ng-template>
</mat-expansion-panel>
}
</mat-accordion>
`,
styles: `
mat-expansion-panel {
box-shadow: none !important;
border-radius: 0 !important;
background: transparent;
border-top: 1px solid #CCC;
}
.header {
display: flex;
justify-content: space-between;
width: 100%;
padding-right: 24px;
align-items: center;
}
.id {
font-family: monospace;
color: #666;
font-size: 12px;
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ExampleList {
/** Type of examples being displayed. */
@Input() type: string;
/** IDs of the examples to display. */
@Input() ids: string[];
@Input()
get expandAll(): boolean {
return this._expandAll;
}
set expandAll(v: BooleanInput) {
this._expandAll = coerceBooleanProperty(v);
}
_expandAll: boolean;
exampleComponents = EXAMPLE_COMPONENTS;
protected _getTitle(id: string) {
return this.exampleComponents[id]?.title;
}
}
| {
"end_byte": 2195,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/example/example-list.ts"
} |
components/src/dev-app/layout/layout-demo.ts_0_597 | /**
* @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 {BreakpointObserverOverviewExample} from '@angular/components-examples/cdk/layout';
import {ChangeDetectionStrategy, Component} from '@angular/core';
@Component({
selector: 'layout-demo',
templateUrl: 'layout-demo.html',
styleUrl: 'layout-demo.css',
imports: [BreakpointObserverOverviewExample],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LayoutDemo {}
| {
"end_byte": 597,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/layout/layout-demo.ts"
} |
components/src/dev-app/layout/BUILD.bazel_0_429 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "layout",
srcs = glob(["**/*.ts"]),
assets = [
"layout-demo.html",
":layout_demo_scss",
],
deps = [
"//src/cdk/layout",
"//src/components-examples/cdk/layout",
],
)
sass_binary(
name = "layout_demo_scss",
src = "layout-demo.scss",
)
| {
"end_byte": 429,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/layout/BUILD.bazel"
} |
components/src/dev-app/layout/layout-demo.html_0_139 | <h2>Respond to viewport changes with BreakpointObserver</h2>
<breakpoint-observer-overview-example></breakpoint-observer-overview-example>
| {
"end_byte": 139,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/layout/layout-demo.html"
} |
components/src/dev-app/cdk-dialog/dialog-demo.scss_0_249 | .demo-container {
button, label {
margin-right: 8px;
[dir='rtl'] & {
margin-left: 8px;
margin-right: 0;
}
}
}
.demo-field {
display: flex;
justify-content: space-between;
max-width: 300px;
margin-bottom: 8px;
}
| {
"end_byte": 249,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-dialog/dialog-demo.scss"
} |
components/src/dev-app/cdk-dialog/dialog-demo.html_0_2110 | <div class="demo-container">
<h2>Dialog config</h2>
<div class="demo-field">
<label for="width">Width</label>
<input id="width" [(ngModel)]="config.width">
</div>
<div class="demo-field">
<label for="height">Height</label>
<input id="height" [(ngModel)]="config.height">
</div>
<div class="demo-field">
<label for="min-width">Min width</label>
<input id="min-width" [(ngModel)]="config.minWidth">
</div>
<div class="demo-field">
<label for="min-height">Min height</label>
<input id="min-height" [(ngModel)]="config.minHeight">
</div>
<div class="demo-field">
<label for="max-width">Max width</label>
<input id="max-width" [(ngModel)]="config.maxWidth">
</div>
<div class="demo-field">
<label for="max-height">Max height</label>
<input id="max-height" [(ngModel)]="config.maxHeight">
</div>
<div class="demo-field">
<label for="backdrop-class">Backdrop class</label>
<input id="backdrop-class" [(ngModel)]="config.backdropClass">
</div>
<div class="demo-field">
<label for="has-backdrop">Has backdrop</label>
<input id="has-backdrop" [(ngModel)]="config.hasBackdrop" type="checkbox">
</div>
<div class="demo-field">
<label for="message">Dialog message</label>
<input id="message" [(ngModel)]="config.data.message">
</div>
<div class="demo-field">
<label for="disable-close">Disable close</label>
<input id="disable-close" [(ngModel)]="config.disableClose" type="checkbox">
</div>
<p>Last result: {{result}}</p>
<button (click)="openJazz()">Open dialog</button>
<button (click)="openTemplate()">Open dialog with template content</button>
</div>
<ng-template let-data let-dialogRef="dialogRef">
I'm a template dialog. I've been opened {{numTemplateOpens}} times!
<p>It's Jazz!</p>
<label for="how-much">How much?</label>
<input id="how-much" #howMuch>
<p> {{ data.message }} </p>
<button type="button" (click)="dialogRef.close(howMuch.value)">Close dialog</button>
<button (click)="dialogRef.updateSize('500px', '500px');">Change dimensions</button>
</ng-template>
| {
"end_byte": 2110,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-dialog/dialog-demo.html"
} |
components/src/dev-app/cdk-dialog/BUILD.bazel_0_417 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "cdk-dialog",
srcs = glob(["**/*.ts"]),
assets = [
"dialog-demo.html",
":dialog_demo_scss",
],
deps = [
"//src/cdk/dialog",
"@npm//@angular/forms",
],
)
sass_binary(
name = "dialog_demo_scss",
src = "dialog-demo.scss",
)
| {
"end_byte": 417,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-dialog/BUILD.bazel"
} |
components/src/dev-app/cdk-dialog/dialog-demo.ts_0_3453 | /**
* @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 {DIALOG_DATA, Dialog, DialogConfig, DialogModule, DialogRef} from '@angular/cdk/dialog';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
TemplateRef,
ViewChild,
ViewEncapsulation,
inject,
} from '@angular/core';
import {FormsModule} from '@angular/forms';
const defaultDialogConfig = new DialogConfig();
@Component({
selector: 'dialog-demo',
templateUrl: 'dialog-demo.html',
styleUrl: 'dialog-demo.css',
encapsulation: ViewEncapsulation.None,
imports: [DialogModule, FormsModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DialogDemo {
dialog = inject(Dialog);
dialogRef: DialogRef<string> | null;
result: string;
actionsAlignment: 'start' | 'center' | 'end';
config = {
disableClose: defaultDialogConfig.disableClose,
panelClass: 'demo-cdk-dialog',
hasBackdrop: defaultDialogConfig.hasBackdrop,
backdropClass: defaultDialogConfig.backdropClass,
width: defaultDialogConfig.width,
height: defaultDialogConfig.height,
minWidth: defaultDialogConfig.minWidth,
minHeight: defaultDialogConfig.maxHeight,
maxWidth: defaultDialogConfig.maxWidth,
maxHeight: defaultDialogConfig.maxHeight,
data: {
message: 'Jazzy jazz jazz',
},
};
numTemplateOpens = 0;
@ViewChild(TemplateRef) template: TemplateRef<any>;
readonly cdr = inject(ChangeDetectorRef);
openJazz() {
this.dialogRef = this.dialog.open<string>(JazzDialog, this.config);
this.dialogRef.closed.subscribe(result => {
this.result = result!;
this.dialogRef = null;
this.cdr.markForCheck();
});
}
openTemplate() {
this.numTemplateOpens++;
this.dialogRef = this.dialog.open(this.template, this.config);
this.dialogRef.closed.subscribe(result => {
this.result = result!;
this.dialogRef = null;
this.cdr.markForCheck();
});
}
}
@Component({
selector: 'demo-jazz-dialog',
template: `
<div>
<p>It's Jazz!</p>
<label for="how-much">How much?</label>
<input id="how-much" #howMuch>
<p>{{ data.message }}</p>
<button type="button" (click)="dialogRef.close(howMuch.value)">Close dialog</button>
<button (click)="togglePosition()">Change dimensions</button>
<button (click)="temporarilyHide()">Hide for 2 seconds</button>
</div>
`,
styles: `
:host {
background: white;
padding: 20px;
border-radius: 8px;
display: block;
width: 100%;
height: 100%;
min-width: inherit;
min-height: inherit;
}
:host-context(.hidden-dialog) {
opacity: 0;
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class JazzDialog {
dialogRef = inject<DialogRef<string>>(DialogRef);
data = inject(DIALOG_DATA);
private _dimensionToggle = false;
togglePosition(): void {
this._dimensionToggle = !this._dimensionToggle;
if (this._dimensionToggle) {
this.dialogRef.updateSize('500px', '500px');
} else {
this.dialogRef.updateSize().updatePosition();
}
}
temporarilyHide(): void {
this.dialogRef.addPanelClass('hidden-dialog');
setTimeout(() => {
this.dialogRef.removePanelClass('hidden-dialog');
}, 2000);
}
}
| {
"end_byte": 3453,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-dialog/dialog-demo.ts"
} |
components/src/dev-app/progress-bar/progress-bar-demo.ts_0_1560 | /**
* @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 {MatButtonToggleModule} from '@angular/material/button-toggle';
import {ThemePalette} from '@angular/material/core';
import {MatProgressBarModule} from '@angular/material/progress-bar';
@Component({
selector: 'progress-bar-demo',
templateUrl: 'progress-bar-demo.html',
styleUrl: 'progress-bar-demo.css',
imports: [FormsModule, MatProgressBarModule, MatButtonModule, MatButtonToggleModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ProgressBarDemo {
color: ThemePalette = 'primary';
determinateProgressValue: number = 30;
determinateAnimationEndValue: number;
bufferAnimationEndValue: number;
bufferProgressValue: number = 30;
bufferBufferValue: number = 40;
stepDeterminateProgressVal(val: number) {
this.determinateProgressValue = this._clampValue(val + this.determinateProgressValue);
}
stepBufferProgressVal(val: number) {
this.bufferProgressValue = this._clampValue(val + this.bufferProgressValue);
}
stepBufferBufferVal(val: number) {
this.bufferBufferValue = this._clampValue(val + this.bufferBufferValue);
}
private _clampValue(value: number) {
return Math.max(0, Math.min(100, value));
}
}
| {
"end_byte": 1560,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/progress-bar/progress-bar-demo.ts"
} |
components/src/dev-app/progress-bar/BUILD.bazel_0_527 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "progress-bar",
srcs = glob(["**/*.ts"]),
assets = [
"progress-bar-demo.html",
":progress_bar_demo_scss",
],
deps = [
"//src/material/button",
"//src/material/button-toggle",
"//src/material/progress-bar",
"@npm//@angular/forms",
],
)
sass_binary(
name = "progress_bar_demo_scss",
src = "progress-bar-demo.scss",
)
| {
"end_byte": 527,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/progress-bar/BUILD.bazel"
} |
components/src/dev-app/progress-bar/progress-bar-demo.html_0_2107 | <mat-button-toggle-group class="demo-progress-bar-controls" [(ngModel)]="color">
<mat-button-toggle value="primary">Primary Color</mat-button-toggle>
<mat-button-toggle value="accent">Accent Color</mat-button-toggle>
<mat-button-toggle value="warn">Warn Color</mat-button-toggle>
</mat-button-toggle-group>
<h1>Determinate</h1>
<div class="demo-progress-bar-controls">
<span>Value: {{determinateProgressValue}}</span>
<br/>
<span>Last animation complete value: {{determinateAnimationEndValue}}</span>
<button mat-raised-button (click)="stepDeterminateProgressVal(10)">Increase</button>
<button mat-raised-button (click)="stepDeterminateProgressVal(-10)">Decrease</button>
</div>
<div class="demo-progress-bar-container">
<mat-progress-bar mode="determinate" [value]="determinateProgressValue" [color]="color"
(animationEnd)="determinateAnimationEndValue = $event.value">
</mat-progress-bar>
</div>
<h1>Buffer</h1>
<div class="demo-progress-bar-controls">
<span>Value: {{bufferProgressValue}}</span>
<br/>
<span>Last animation complete value: {{bufferAnimationEndValue}}</span>
<button mat-raised-button (click)="stepBufferProgressVal(10)">Increase</button>
<button mat-raised-button (click)="stepBufferProgressVal(-10)">Decrease</button>
<span class="demo-progress-bar-spacer"></span>
<span>Buffer Value: {{bufferBufferValue}}</span>
<button mat-raised-button (click)="stepBufferBufferVal(10)">Increase</button>
<button mat-raised-button (click)="stepBufferBufferVal(-10)">Decrease</button>
</div>
<div class="demo-progress-bar-container">
<mat-progress-bar [value]="bufferProgressValue" [bufferValue]="bufferBufferValue" mode="buffer"
[color]="color" (animationEnd)="bufferAnimationEndValue = $event.value">
</mat-progress-bar>
</div>
<h1>Indeterminate</h1>
<div class="demo-progress-bar-container">
<mat-progress-bar mode="indeterminate" [color]="color"></mat-progress-bar>
</div>
<h1>Query</h1>
<div class="demo-progress-bar-container">
<mat-progress-bar mode="query" [color]="color"></mat-progress-bar>
</div>
| {
"end_byte": 2107,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/progress-bar/progress-bar-demo.html"
} |
components/src/dev-app/progress-bar/progress-bar-demo.scss_0_216 | .demo-progress-bar-container {
width: 100%;
mat-progress-bar {
margin: 20px 0;
}
}
.demo-progress-bar-spacer {
display: inline-block;
width: 50px;
}
.demo-progress-bar-controls {
margin: 10px 0;
}
| {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/progress-bar/progress-bar-demo.scss"
} |
components/src/dev-app/slide-toggle/slide-toggle-demo.ts_0_852 | /**
* @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 {MatSlideToggleModule} from '@angular/material/slide-toggle';
@Component({
selector: 'slide-toggle-demo',
templateUrl: 'slide-toggle-demo.html',
styleUrl: 'slide-toggle-demo.css',
imports: [FormsModule, MatButtonModule, MatSlideToggleModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SlideToggleDemo {
firstToggle = false;
formToggle = false;
onFormSubmit() {
alert(`You submitted the form. Value: ${this.formToggle}.`);
}
}
| {
"end_byte": 852,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/slide-toggle/slide-toggle-demo.ts"
} |
components/src/dev-app/slide-toggle/BUILD.bazel_0_487 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "slide-toggle",
srcs = glob(["**/*.ts"]),
assets = [
"slide-toggle-demo.html",
":slide_toggle_demo_scss",
],
deps = [
"//src/material/button",
"//src/material/slide-toggle",
"@npm//@angular/forms",
],
)
sass_binary(
name = "slide_toggle_demo_scss",
src = "slide-toggle-demo.scss",
)
| {
"end_byte": 487,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/slide-toggle/BUILD.bazel"
} |
components/src/dev-app/slide-toggle/slide-toggle-demo.scss_0_138 | .demo-slide-toggle {
display: flex;
flex-direction: column;
align-items: flex-start;
mat-slide-toggle {
margin: 6px 0;
}
}
| {
"end_byte": 138,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/slide-toggle/slide-toggle-demo.scss"
} |
components/src/dev-app/slide-toggle/slide-toggle-demo.html_0_1332 | <div class="demo-slide-toggle">
<mat-slide-toggle color="primary" [(ngModel)]="firstToggle">Default Slide Toggle</mat-slide-toggle>
<mat-slide-toggle [(ngModel)]="firstToggle" disabled>Disabled Slide Toggle</mat-slide-toggle>
<mat-slide-toggle [disabled]="firstToggle">Disable Bound</mat-slide-toggle>
<mat-slide-toggle disabled disabledInteractive [(ngModel)]="firstToggle">Disabled Interactive Toggle</mat-slide-toggle>
<mat-slide-toggle hideIcon [(ngModel)]="firstToggle">No icon</mat-slide-toggle>
<p>With label before the slide toggle.</p>
<mat-slide-toggle labelPosition="before" color="primary" [(ngModel)]="firstToggle">Default Slide Toggle</mat-slide-toggle>
<mat-slide-toggle labelPosition="before" [(ngModel)]="firstToggle" disabled>Disabled Slide Toggle</mat-slide-toggle>
<mat-slide-toggle labelPosition="before" [disabled]="firstToggle">Disable Bound</mat-slide-toggle>
<mat-slide-toggle labelPosition="before" hideIcon [(ngModel)]="firstToggle">No icon</mat-slide-toggle>
<p>Example where the slide toggle is required inside of a form.</p>
<form #form="ngForm" (ngSubmit)="onFormSubmit()">
<mat-slide-toggle name="slideToggle" [(ngModel)]="formToggle">Slide Toggle</mat-slide-toggle>
<p>
<button mat-raised-button type="submit">Submit Form</button>
</p>
</form>
</div>
| {
"end_byte": 1332,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/slide-toggle/slide-toggle-demo.html"
} |
components/src/dev-app/datepicker/custom-header.html_0_590 | <div class="demo-calendar-header">
<button mat-icon-button (click)="previousClicked('year')">
<mat-icon>keyboard_double_arrow_left</mat-icon>
</button>
<button mat-icon-button (click)="previousClicked('month')">
<mat-icon>keyboard_arrow_left</mat-icon>
</button>
<span class="demo-calendar-header-label">{{periodLabel}}</span>
<button mat-icon-button (click)="nextClicked('month')">
<mat-icon>keyboard_arrow_right</mat-icon>
</button>
<button mat-icon-button (click)="nextClicked('year')">
<mat-icon>keyboard_double_arrow_right</mat-icon>
</button>
</div>
| {
"end_byte": 590,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/datepicker/custom-header.html"
} |
components/src/dev-app/datepicker/datepicker-demo.html_0_7062 | <h2>Options</h2>
<p>
<mat-checkbox [(ngModel)]="touch">Use touch UI</mat-checkbox>
<mat-checkbox [(ngModel)]="filterOdd">Filter odd years, months and dates</mat-checkbox>
<mat-checkbox [(ngModel)]="yearView">Start in year view</mat-checkbox>
<mat-checkbox [(ngModel)]="datepickerDisabled">Disable datepicker</mat-checkbox>
<mat-checkbox [(ngModel)]="inputDisabled">Disable input</mat-checkbox>
<mat-checkbox [(ngModel)]="showActions">Show action buttons</mat-checkbox>
<mat-form-field>
<mat-select [(ngModel)]="color" placeholder="Color">
<mat-option value="primary">Primary</mat-option>
<mat-option value="accent">Accent</mat-option>
<mat-option value="warn">Warn</mat-option>
</mat-select>
</mat-form-field>
</p>
<p>
<mat-form-field [color]="color">
<mat-label>Min date</mat-label>
<input matInput [matDatepicker]="minDatePicker" [(ngModel)]="minDate"
[disabled]="inputDisabled" [max]="maxDate">
<mat-datepicker-toggle matSuffix [for]="minDatePicker"></mat-datepicker-toggle>
<mat-datepicker #minDatePicker [touchUi]="touch" [disabled]="datepickerDisabled">
@if (showActions) {
<mat-datepicker-actions>
<button mat-button matDatepickerCancel>Cancel</button>
<button mat-raised-button color="primary" matDatepickerApply>Apply</button>
</mat-datepicker-actions>
}
</mat-datepicker>
</mat-form-field>
<mat-form-field [color]="color">
<mat-label>Max date</mat-label>
<input matInput [matDatepicker]="maxDatePicker" [(ngModel)]="maxDate"
[disabled]="inputDisabled" [min]="minDate">
<mat-datepicker-toggle matSuffix [for]="maxDatePicker"></mat-datepicker-toggle>
<mat-datepicker #maxDatePicker [touchUi]="touch" [disabled]="datepickerDisabled">
@if (showActions) {
<mat-datepicker-actions>
<button mat-button matDatepickerCancel>Cancel</button>
<button mat-raised-button color="primary" matDatepickerApply>Apply</button>
</mat-datepicker-actions>
}
</mat-datepicker>
</mat-form-field>
</p>
<p>
<mat-form-field [color]="color">
<mat-label>Start at date</mat-label>
<input matInput [matDatepicker]="startAtPicker" [(ngModel)]="startAt"
[disabled]="inputDisabled">
<mat-datepicker-toggle matSuffix [for]="startAtPicker"></mat-datepicker-toggle>
<mat-datepicker #startAtPicker [touchUi]="touch" [disabled]="datepickerDisabled">
@if (showActions) {
<mat-datepicker-actions>
<button mat-button matDatepickerCancel>Cancel</button>
<button mat-raised-button color="primary" matDatepickerApply>Apply</button>
</mat-datepicker-actions>
}
</mat-datepicker>
</mat-form-field>
</p>
<h2>Result</h2>
<p>
<mat-datepicker-toggle [for]="resultPicker"></mat-datepicker-toggle>
<mat-form-field>
<mat-label>Pick a date</mat-label>
<input matInput
#resultPickerModel="ngModel"
[matDatepicker]="resultPicker"
[(ngModel)]="date"
[min]="minDate"
[max]="maxDate"
[matDatepickerFilter]="filterOdd ? dateFilter : undefined!"
[disabled]="inputDisabled"
(dateInput)="onDateInput($event)"
(dateChange)="onDateChange($event)">
<mat-datepicker
#resultPicker
[touchUi]="touch"
[disabled]="datepickerDisabled"
[startAt]="startAt"
[startView]="yearView ? 'year' : 'month'"
[color]="color">
@if (showActions) {
<mat-datepicker-actions>
<button mat-button matDatepickerCancel>Cancel</button>
<button mat-raised-button color="primary" matDatepickerApply>Apply</button>
</mat-datepicker-actions>
}
</mat-datepicker>
@if (resultPickerModel.hasError('matDatepickerParse')) {
<mat-error>
"{{resultPickerModel.getError('matDatepickerParse').text}}" is not a valid date!
</mat-error>
}
@if (resultPickerModel.hasError('matDatepickerMin')) {
<mat-error>Too early!</mat-error>
}
@if (resultPickerModel.hasError('matDatepickerMax')) {
<mat-error>Too late!</mat-error>
}
@if (resultPickerModel.hasError('matDatepickerFilter')) {
<mat-error>Date unavailable!</mat-error>
}
</mat-form-field>
</p>
<p>Last input: {{lastDateInput}}</p>
<p>Last change: {{lastDateChange}}</p>
<br>
<p>
<input #resultPickerModel2
[matDatepicker]="resultPicker2"
[(ngModel)]="date"
[min]="minDate"
[max]="maxDate"
[disabled]="inputDisabled"
[matDatepickerFilter]="filterOdd ? dateFilter : undefined!"
placeholder="Pick a date">
<mat-datepicker-toggle [for]="resultPicker2"></mat-datepicker-toggle>
<mat-datepicker
#resultPicker2
[touchUi]="touch"
[disabled]="datepickerDisabled"
[startAt]="startAt"
[startView]="yearView ? 'year' : 'month'">
@if (showActions) {
<mat-datepicker-actions>
<button mat-button matDatepickerCancel>Cancel</button>
<button mat-raised-button color="primary" matDatepickerApply>Apply</button>
</mat-datepicker-actions>
}
</mat-datepicker>
</p>
<h2>Input disabled datepicker</h2>
<p>
<mat-datepicker-toggle [for]="datePicker1"></mat-datepicker-toggle>
<mat-form-field>
<mat-label>Input disabled</mat-label>
<input matInput [matDatepicker]="datePicker1" [(ngModel)]="date" [min]="minDate" [max]="maxDate"
[matDatepickerFilter]="filterOdd ? dateFilter : undefined!" disabled>
<mat-datepicker #datePicker1 [touchUi]="touch" [startAt]="startAt"
[startView]="yearView ? 'year' : 'month'"></mat-datepicker>
</mat-form-field>
</p>
<h2>Input disabled via FormControl</h2>
<p>
<mat-datepicker-toggle [for]="datePicker2"></mat-datepicker-toggle>
<mat-form-field>
<mat-label>FormControl disabled</mat-label>
<input matInput [matDatepicker]="datePicker2" [formControl]="dateCtrl" [min]="minDate"
[max]="maxDate" [matDatepickerFilter]="filterOdd ? dateFilter : undefined!">
<mat-datepicker #datePicker2 [touchUi]="touch" [startAt]="startAt"
[startView]="yearView ? 'year' : 'month'"></mat-datepicker>
</mat-form-field>
<button mat-button (click)="dateCtrl.disabled ? dateCtrl.enable() : dateCtrl.disable()">
{{dateCtrl.disabled ? 'Enable' : 'Disable'}} FormControl
</button>
</p>
<h2>Input disabled, datepicker popup enabled</h2>
<p>
<mat-datepicker-toggle [for]="datePicker3"></mat-datepicker-toggle>
<mat-form-field>
<mat-label>Input disabled, datepicker enabled</mat-label>
<input matInput disabled [matDatepicker]="datePicker3" [(ngModel)]="date" [min]="minDate"
[max]="maxDate" [matDatepickerFilter]="filterOdd ? dateFilter : undefined!">
<mat-datepicker #datePicker3 [touchUi]="touch" [disabled]="false" [startAt]="startAt"
[startView]="yearView ? 'year' : 'month'"></mat-datepicker>
</mat-form-field>
</p>
<h2>Datepicker with value property binding</h2> | {
"end_byte": 7062,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/datepicker/datepicker-demo.html"
} |
components/src/dev-app/datepicker/datepicker-demo.html_7063_14037 | <p>
<mat-datepicker-toggle [for]="datePicker4"></mat-datepicker-toggle>
<mat-form-field>
<mat-label>Value binding</mat-label>
<!-- TODO Angular sets the inputs for both directives on the input element here.
e.g. [value] is set for MatInput and MatDatepicker.
MatInput#value expects a string whereas MatDatepicker#value expects a Date.
This breaks strict template type checking. What should we do here?
-->
<input matInput [matDatepicker]="datePicker4" [value]="date" [min]="minDate"
[max]="maxDate" [matDatepickerFilter]="filterOdd ? dateFilter : undefined!">
<mat-datepicker #datePicker4 [touchUi]="touch" [startAt]="startAt"
[startView]="yearView ? 'year' : 'month'"></mat-datepicker>
</mat-form-field>
</p>
<h2>Datepicker with custom header</h2>
<p>
<mat-form-field>
<mat-label>Custom calendar header</mat-label>
<input matInput [matDatepicker]="customHeaderPicker">
<mat-datepicker-toggle matSuffix [for]="customHeaderPicker"></mat-datepicker-toggle>
<mat-datepicker #customHeaderPicker [calendarHeaderComponent]="customHeader"></mat-datepicker>
</mat-form-field>
</p>
<h2>Datepicker with custom header extending the default header</h2>
<p>
<mat-form-field>
<mat-label>Custom calendar header extending default</mat-label>
<input matInput [matDatepicker]="customHeaderNgContentPicker">
<mat-datepicker-toggle matSuffix [for]="customHeaderNgContentPicker"></mat-datepicker-toggle>
<mat-datepicker #customHeaderNgContentPicker [calendarHeaderComponent]="customHeaderNgContent"></mat-datepicker>
</mat-form-field>
</p>
<h2>Range picker</h2>
<div class="demo-range-group">
<mat-form-field>
<mat-label>Enter a date range</mat-label>
<mat-date-range-input
[formGroup]="range1"
[rangePicker]="range1Picker"
[min]="minDate"
[max]="maxDate"
[disabled]="inputDisabled"
[comparisonStart]="comparisonStart"
[comparisonEnd]="comparisonEnd"
[dateFilter]="filterOdd ? dateFilter : undefined!">
<input matStartDate formControlName="start" placeholder="Start date"/>
<input matEndDate formControlName="end" placeholder="End date"/>
</mat-date-range-input>
<mat-datepicker-toggle [for]="range1Picker" matSuffix></mat-datepicker-toggle>
<mat-date-range-picker
[touchUi]="touch"
[disabled]="datepickerDisabled"
[color]="color"
#range1Picker>
@if (showActions) {
<mat-date-range-picker-actions>
<button mat-button matDateRangePickerCancel>Cancel</button>
<button mat-raised-button color="primary" matDateRangePickerApply>Apply</button>
</mat-date-range-picker-actions>
}
</mat-date-range-picker>
</mat-form-field>
<div>{{range1.value | json}}</div>
</div>
<div class="demo-range-group">
<mat-form-field appearance="fill">
<mat-label>Enter a date range</mat-label>
<mat-date-range-input
[formGroup]="range2"
[rangePicker]="range2Picker"
[min]="minDate"
[max]="maxDate"
[disabled]="inputDisabled"
[comparisonStart]="comparisonStart"
[comparisonEnd]="comparisonEnd"
[dateFilter]="filterOdd ? dateFilter : undefined!">
<input matStartDate formControlName="start" placeholder="Start date"/>
<input matEndDate formControlName="end" placeholder="End date"/>
</mat-date-range-input>
<mat-datepicker-toggle [for]="range2Picker" matSuffix></mat-datepicker-toggle>
<mat-date-range-picker
[touchUi]="touch"
[disabled]="datepickerDisabled"
panelClass="demo-custom-range"
#range2Picker>
@if (showActions) {
<mat-date-range-picker-actions>
<button mat-button matDateRangePickerCancel>Cancel</button>
<button mat-raised-button color="primary" matDateRangePickerApply>Apply</button>
</mat-date-range-picker-actions>
}
</mat-date-range-picker>
</mat-form-field>
<div>{{range2.value | json}}</div>
</div>
<div class="demo-range-group">
<mat-form-field appearance="outline">
<mat-label>Enter a date range</mat-label>
<mat-date-range-input
[formGroup]="range3"
[rangePicker]="range3Picker"
[min]="minDate"
[max]="maxDate"
[disabled]="inputDisabled"
[comparisonStart]="comparisonStart"
[comparisonEnd]="comparisonEnd"
[dateFilter]="filterOdd ? dateFilter : undefined!">
<input matStartDate formControlName="start" placeholder="Start date"/>
<input matEndDate formControlName="end" placeholder="End date"/>
</mat-date-range-input>
<mat-datepicker-toggle [for]="range3Picker" matSuffix></mat-datepicker-toggle>
<mat-date-range-picker
[touchUi]="touch"
[disabled]="datepickerDisabled"
#range3Picker>
@if (showActions) {
<mat-date-range-picker-actions>
<button mat-button matDateRangePickerCancel>Cancel</button>
<button mat-raised-button color="primary" matDateRangePickerApply>Apply</button>
</mat-date-range-picker-actions>
}
</mat-date-range-picker>
</mat-form-field>
<div>{{range3.value | json}}</div>
</div>
<h2>Range picker with custom selection strategy</h2>
<div class="demo-range-group">
<mat-form-field>
<mat-label>Enter a date range</mat-label>
<mat-date-range-input [rangePicker]="range4Picker">
<input matStartDate placeholder="Start date"/>
<input matEndDate placeholder="End date"/>
</mat-date-range-input>
<mat-datepicker-toggle [for]="range4Picker" matSuffix></mat-datepicker-toggle>
<mat-date-range-picker customRangeStrategy #range4Picker>
@if (showActions) {
<mat-date-range-picker-actions>
<button mat-button matDateRangePickerCancel>Cancel</button>
<button mat-raised-button color="primary" matDateRangePickerApply>Apply</button>
</mat-date-range-picker-actions>
}
</mat-date-range-picker>
</mat-form-field>
</div>
<h2>With custom icon</h2>
<p>
<mat-form-field appearance="fill">
<mat-label>Custom icon</mat-label>
<input matInput [matDatepicker]="ci1">
<mat-datepicker-toggle matSuffix [for]="ci1">
<mat-icon matDatepickerToggleIcon>add</mat-icon>
</mat-datepicker-toggle>
<mat-datepicker #ci1></mat-datepicker>
</mat-form-field>
<br>
<mat-form-field appearance="outline">
<mat-label>Custom icon</mat-label>
<input matInput [matDatepicker]="ci2">
<mat-datepicker-toggle matSuffix [for]="ci2">
<mat-icon matDatepickerToggleIcon>add</mat-icon>
</mat-datepicker-toggle>
<mat-datepicker #ci2></mat-datepicker>
</mat-form-field>
<br>
<mat-form-field>
<mat-label>Custom icon</mat-label>
<input matInput [matDatepicker]="ci3">
<mat-datepicker #ci3></mat-datepicker>
</mat-form-field>
<mat-datepicker-toggle matSuffix [for]="ci3">
<mat-icon matDatepickerToggleIcon>add</mat-icon>
</mat-datepicker-toggle>
</p> | {
"end_byte": 14037,
"start_byte": 7063,
"url": "https://github.com/angular/components/blob/main/src/dev-app/datepicker/datepicker-demo.html"
} |
components/src/dev-app/datepicker/datepicker-demo.scss_0_218 | @use '@angular/material' as mat;
mat-calendar {
width: 300px;
}
.demo-range-group {
margin-bottom: 30px;
}
.demo-custom-range {
@include mat.datepicker-date-range-colors(
hotpink, teal, yellow, purple);
}
| {
"end_byte": 218,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/datepicker/datepicker-demo.scss"
} |
components/src/dev-app/datepicker/custom-header.scss_0_186 | .demo-calendar-header {
display: flex;
align-items: center;
padding: 0.5em;
}
.demo-calendar-header-label {
flex: 1;
height: 1em;
font-weight: bold;
text-align: center;
}
| {
"end_byte": 186,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/datepicker/custom-header.scss"
} |
components/src/dev-app/datepicker/datepicker-demo.ts_0_7081 | /**
* @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,
Directive,
Injectable,
OnDestroy,
ViewChild,
ViewEncapsulation,
inject,
} from '@angular/core';
import {JsonPipe} from '@angular/common';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {DateAdapter, MAT_DATE_FORMATS, ThemePalette} from '@angular/material/core';
import {
DateRange,
MAT_DATE_RANGE_SELECTION_STRATEGY,
MatCalendar,
MatCalendarHeader,
MatDateRangeSelectionStrategy,
MatDatepickerInputEvent,
MatDatepickerModule,
} from '@angular/material/datepicker';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatIconModule} from '@angular/material/icon';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {Subject} from 'rxjs';
import {takeUntil} from 'rxjs/operators';
/** Range selection strategy that preserves the current range. */
@Injectable()
export class PreserveRangeStrategy<D> implements MatDateRangeSelectionStrategy<D> {
private _dateAdapter = inject<DateAdapter<D>>(DateAdapter<D>);
selectionFinished(date: D, currentRange: DateRange<D>) {
let {start, end} = currentRange;
if (start && end) {
return this._getRangeRelativeToDate(date, start, end);
}
if (start == null) {
start = date;
} else if (end == null) {
end = date;
}
return new DateRange<D>(start, end);
}
createPreview(activeDate: D | null, currentRange: DateRange<D>): DateRange<D> {
if (activeDate) {
if (currentRange.start && currentRange.end) {
return this._getRangeRelativeToDate(activeDate, currentRange.start, currentRange.end);
} else if (currentRange.start && !currentRange.end) {
return new DateRange(currentRange.start, activeDate);
}
}
return new DateRange<D>(null, null);
}
private _getRangeRelativeToDate(date: D | null, start: D, end: D): DateRange<D> {
let rangeStart: D | null = null;
let rangeEnd: D | null = null;
if (date) {
const delta = Math.round(Math.abs(this._dateAdapter.compareDate(start, end)) / 2);
rangeStart = this._dateAdapter.addCalendarDays(date, -delta);
rangeEnd = this._dateAdapter.addCalendarDays(date, delta);
}
return new DateRange(rangeStart, rangeEnd);
}
}
@Directive({
selector: '[customRangeStrategy]',
providers: [
{
provide: MAT_DATE_RANGE_SELECTION_STRATEGY,
useClass: PreserveRangeStrategy,
},
],
})
export class CustomRangeStrategy {}
// Custom header component for datepicker
@Component({
selector: 'custom-header',
templateUrl: 'custom-header.html',
styleUrl: 'custom-header.css',
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [MatIconModule, MatButtonModule],
})
export class CustomHeader<D> implements OnDestroy {
private _calendar = inject<MatCalendar<D>>(MatCalendar);
private _dateAdapter = inject<DateAdapter<D>>(DateAdapter);
private _dateFormats = inject(MAT_DATE_FORMATS);
private readonly _destroyed = new Subject<void>();
constructor() {
const _calendar = this._calendar;
const cdr = inject(ChangeDetectorRef);
_calendar.stateChanges.pipe(takeUntil(this._destroyed)).subscribe(() => cdr.markForCheck());
}
ngOnDestroy() {
this._destroyed.next();
this._destroyed.complete();
}
get periodLabel() {
return this._dateAdapter
.format(this._calendar.activeDate, this._dateFormats.display.monthYearLabel)
.toLocaleUpperCase();
}
previousClicked(mode: 'month' | 'year') {
this._calendar.activeDate =
mode === 'month'
? this._dateAdapter.addCalendarMonths(this._calendar.activeDate, -1)
: this._dateAdapter.addCalendarYears(this._calendar.activeDate, -1);
}
nextClicked(mode: 'month' | 'year') {
this._calendar.activeDate =
mode === 'month'
? this._dateAdapter.addCalendarMonths(this._calendar.activeDate, 1)
: this._dateAdapter.addCalendarYears(this._calendar.activeDate, 1);
}
}
@Component({
selector: 'custom-header-ng-content',
template: `
<mat-calendar-header #header>
<button mat-button type="button" (click)="todayClicked()">TODAY</button>
</mat-calendar-header>
`,
imports: [MatDatepickerModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomHeaderNgContent<D> {
private _dateAdapter = inject<DateAdapter<D>>(DateAdapter);
@ViewChild(MatCalendarHeader)
header: MatCalendarHeader<D>;
todayClicked() {
let calendar = this.header.calendar;
calendar.activeDate = this._dateAdapter.today();
calendar.currentView = 'month';
}
}
@Component({
selector: 'datepicker-demo',
templateUrl: 'datepicker-demo.html',
styleUrl: 'datepicker-demo.css',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
JsonPipe,
FormsModule,
MatButtonModule,
MatCheckboxModule,
MatDatepickerModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
MatSelectModule,
ReactiveFormsModule,
CustomRangeStrategy,
],
})
export class DatepickerDemo {
touch: boolean;
filterOdd: boolean;
yearView: boolean;
inputDisabled: boolean;
datepickerDisabled: boolean;
minDate: Date;
maxDate: Date;
startAt: Date;
date: any;
lastDateInput: Date | null;
lastDateChange: Date | null;
color: ThemePalette;
showActions = false;
dateCtrl = new FormControl<Date | null>(null);
range1 = new FormGroup({
start: new FormControl<Date | null>(null),
end: new FormControl<Date | null>(null),
});
range2 = new FormGroup({
start: new FormControl<Date | null>(null),
end: new FormControl<Date | null>(null),
});
range3 = new FormGroup({
start: new FormControl<Date | null>(null),
end: new FormControl<Date | null>(null),
});
comparisonStart: Date;
comparisonEnd: Date;
constructor() {
const today = new Date();
const year = today.getFullYear();
const month = today.getMonth();
this.comparisonStart = new Date(year, month, 9);
this.comparisonEnd = new Date(year, month, 13);
}
dateFilter: (date: Date | null) => boolean = (date: Date | null) => {
if (date === null) {
return true;
}
return !(date.getFullYear() % 2) && Boolean(date.getMonth() % 2) && !(date.getDate() % 2);
};
onDateInput = (e: MatDatepickerInputEvent<Date, Date | null>) => (this.lastDateInput = e.value);
onDateChange = (e: MatDatepickerInputEvent<Date, Date | null>) => (this.lastDateChange = e.value);
// pass custom header component type as input
customHeader = CustomHeader;
customHeaderNgContent = CustomHeaderNgContent;
}
| {
"end_byte": 7081,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/datepicker/datepicker-demo.ts"
} |
components/src/dev-app/datepicker/BUILD.bazel_0_839 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "datepicker",
srcs = glob(["**/*.ts"]),
assets = [
"datepicker-demo.html",
"custom-header.html",
":datepicker_demo_scss",
":custom_header_scss",
],
deps = [
"//src/material/button",
"//src/material/checkbox",
"//src/material/core",
"//src/material/datepicker",
"//src/material/form-field",
"//src/material/icon",
"//src/material/input",
"//src/material/select",
],
)
sass_binary(
name = "datepicker_demo_scss",
src = "datepicker-demo.scss",
deps = [
"//src/material:sass_lib",
],
)
sass_binary(
name = "custom_header_scss",
src = "custom-header.scss",
)
| {
"end_byte": 839,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/datepicker/BUILD.bazel"
} |
components/src/dev-app/platform/platform-demo.ts_0_596 | /**
* @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 {Platform, getSupportedInputTypes} from '@angular/cdk/platform';
@Component({
selector: 'platform-demo',
templateUrl: 'platform-demo.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PlatformDemo {
platform = inject(Platform);
supportedInputTypes = getSupportedInputTypes();
}
| {
"end_byte": 596,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/platform/platform-demo.ts"
} |
components/src/dev-app/platform/platform-demo.html_0_416 | <p>Is Android: {{platform.ANDROID}}</p>
<p>Is iOS: {{platform.IOS}}</p>
<p>Is Firefox: {{platform.FIREFOX}}</p>
<p>Is Blink: {{platform.BLINK}}</p>
<p>Is Webkit: {{platform.WEBKIT}}</p>
<p>Is Trident: {{platform.TRIDENT}}</p>
<p>Is Edge: {{platform.EDGE}}</p>
<p>Is Safari: {{platform.SAFARI}}</p>
<p>
Supported input types:
@for (type of supportedInputTypes; track type) {
<span>{{type}}, </span>
}
</p>
| {
"end_byte": 416,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/platform/platform-demo.html"
} |
components/src/dev-app/platform/BUILD.bazel_0_251 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "platform",
srcs = glob(["**/*.ts"]),
assets = ["platform-demo.html"],
deps = [
"//src/cdk/platform",
],
)
| {
"end_byte": 251,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/platform/BUILD.bazel"
} |
components/src/dev-app/virtual-scroll/virtual-scroll-demo.scss_0_874 | .demo-viewport {
height: 500px;
width: 500px;
border: 1px solid black;
.cdk-virtual-scroll-content-wrapper {
display: flex;
flex-direction: column;
}
}
.demo-horizontal {
.cdk-virtual-scroll-content-wrapper {
flex-direction: row;
}
.demo-item {
-webkit-writing-mode: vertical-lr;
writing-mode: vertical-lr;
}
}
.demo-state-item {
height: 60px;
display: flex;
flex-direction: column;
justify-content: center;
}
.demo-state {
font-size: 20px;
font-weight: 500;
}
.demo-capital {
font-size: 14px;
}
.demo-dt {
height: 30px;
font-weight: bold;
}
.demo-dd {
height: 30px;
}
.demo-li,
.demo-td {
height: 50px;
}
.demo-td {
border: 1px solid gray;
}
.demo-resize-example {
display: flex;
width: 500px;
height: 500px;
}
cdk-virtual-scroll-window-scrolling-example {
display: block;
width: 500px;
}
| {
"end_byte": 874,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/virtual-scroll/virtual-scroll-demo.scss"
} |
components/src/dev-app/virtual-scroll/virtual-scroll-demo.html_0_6744 | <h2>Autosize</h2>
<h3>Uniform size</h3>
<cdk-virtual-scroll-viewport class="demo-viewport" autosize>
<div *cdkVirtualFor="let size of fixedSizeData; let i = index" class="demo-item"
[style.height.px]="size">
Item #{{i}} - ({{size}}px)
</div>
</cdk-virtual-scroll-viewport>
<h3>Increasing size</h3>
<cdk-virtual-scroll-viewport class="demo-viewport" autosize>
<div *cdkVirtualFor="let size of increasingSizeData; let i = index" class="demo-item"
[style.height.px]="size">
Item #{{i}} - ({{size}}px)
</div>
</cdk-virtual-scroll-viewport>
<h3>Decreasing size</h3>
<cdk-virtual-scroll-viewport class="demo-viewport" autosize>
<div *cdkVirtualFor="let size of decreasingSizeData; let i = index" class="demo-item"
[style.height.px]="size">
Item #{{i}} - ({{size}}px)
</div>
</cdk-virtual-scroll-viewport>
<h3>Random size</h3>
<cdk-virtual-scroll-viewport class="demo-viewport" autosize>
<div *cdkVirtualFor="let size of randomData; let i = index" class="demo-item"
[style.height.px]="size">
Item #{{i}} - ({{size}}px)
</div>
</cdk-virtual-scroll-viewport>
<h2>Fixed size</h2>
<mat-form-field>
<mat-label>Behavior</mat-label>
<mat-select [(ngModel)]="scrollToBehavior">
<mat-option value="auto">Auto</mat-option>
<mat-option value="instant">Instant</mat-option>
<mat-option value="smooth">Smooth</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field>
<mat-label>Offset</mat-label>
<input matInput type="number" [(ngModel)]="scrollToOffset">
</mat-form-field>
<button mat-button (click)="viewport1.scrollToOffset(scrollToOffset, scrollToBehavior);
viewport2.scrollToOffset(scrollToOffset, scrollToBehavior)">
Go to offset
</button>
<mat-form-field>
<mat-label>Index</mat-label>
<input matInput type="number" [(ngModel)]="scrollToIndex">
</mat-form-field>
<button mat-button (click)="viewport1.scrollToIndex(scrollToIndex, scrollToBehavior);
viewport2.scrollToIndex(scrollToIndex, scrollToBehavior)">
Go to index
</button>
<p>
Currently scrolled to item: {{scrolledIndex.get(viewport1) || 0}}
</p>
<cdk-virtual-scroll-viewport class="demo-viewport" [itemSize]="50" #viewport1
(scrolledIndexChange)="scrolled(viewport1, $event)">
<div *cdkVirtualFor="let size of fixedSizeData; let i = index" class="demo-item"
[style.height.px]="size">
Item #{{i}} - ({{size}}px)
</div>
</cdk-virtual-scroll-viewport>
<p>
Currently scrolled to item: {{scrolledIndex.get(viewport2) || 0}}
</p>
<cdk-virtual-scroll-viewport class="demo-viewport demo-horizontal" [itemSize]="50" #viewport2
(scrolledIndexChange)="scrolled(viewport2, $event)"
orientation="horizontal">
<div *cdkVirtualFor="let size of fixedSizeData; let i = index" class="demo-item"
[style.width.px]="size">
Item #{{i}} - ({{size}}px)
</div>
</cdk-virtual-scroll-viewport>
<h2>Observable data</h2>
<button (click)="emitData()">Add item</button>
<cdk-virtual-scroll-viewport class="demo-viewport" [itemSize]="50">
<div *cdkVirtualFor="let size of observableData | async; let i = index" class="demo-item"
[style.height.px]="size">
Item #{{i}} - ({{size}}px)
</div>
</cdk-virtual-scroll-viewport>
<h2>No trackBy</h2>
<button (click)="sortBy('name')">Sort by state name</button>
<button (click)="sortBy('capital')">Sort by state capital</button>
<cdk-virtual-scroll-viewport class="demo-viewport" [itemSize]="60">
<div *cdkVirtualFor="let state of statesObservable | async"
class="demo-state-item">
<div class="demo-state">{{state.name}}</div>
<div class="demo-capital">{{state.capital}}</div>
</div>
</cdk-virtual-scroll-viewport>
<h2>trackBy index</h2>
<button (click)="sortBy('name')">Sort by state name</button>
<button (click)="sortBy('capital')">Sort by state capital</button>
<cdk-virtual-scroll-viewport class="demo-viewport" [itemSize]="60">
<div *cdkVirtualFor="let state of statesObservable | async; trackBy: indexTrackFn"
class="demo-state-item">
<div class="demo-state">{{state.name}}</div>
<div class="demo-capital">{{state.capital}}</div>
</div>
</cdk-virtual-scroll-viewport>
<h2>trackBy state name</h2>
<button (click)="sortBy('name')">Sort by state name</button>
<button (click)="sortBy('capital')">Sort by state capital</button>
<cdk-virtual-scroll-viewport class="demo-viewport" [itemSize]="60">
<div *cdkVirtualFor="let state of statesObservable | async; trackBy: nameTrackFn"
class="demo-state-item">
<div class="demo-state">{{state.name}}</div>
<div class="demo-capital">{{state.capital}}</div>
</div>
</cdk-virtual-scroll-viewport>
<h2>Use with <code><ol></code></h2>
<cdk-virtual-scroll-viewport class="demo-viewport" autosize #viewport3>
<ol class="demo-ol" [start]="viewport3.getRenderedRange().start + 1">
<li *cdkVirtualFor="let state of statesObservable | async" class="demo-li">
{{state.name}} - {{state.capital}}
</li>
</ol>
</cdk-virtual-scroll-viewport>
<h2>Use with <code><ul></code></h2>
<cdk-virtual-scroll-viewport class="demo-viewport" autosize>
<ul class="demo-ul">
<li *cdkVirtualFor="let state of statesObservable | async" class="demo-li">
{{state.name}} - {{state.capital}}
</li>
</ul>
</cdk-virtual-scroll-viewport>
<h2>Use with <code><dl></code></h2>
<cdk-virtual-scroll-viewport class="demo-viewport" autosize>
<dl class="demo-dl">
<ng-container *cdkVirtualFor="let state of statesObservable | async">
<dt class="demo-dt">{{state.name}}</dt>
<dd class="demo-dd">{{state.capital}}</dd>
</ng-container>
</dl>
</cdk-virtual-scroll-viewport>
<h2>Use with <code><table></code></h2>
<cdk-virtual-scroll-viewport class="demo-viewport" autosize>
<table class="demo-ol">
<tr *cdkVirtualFor="let state of statesObservable | async" class="demo-tr">
<td class="demo-td">{{state.name}}</td>
<td class="demo-td">{{state.capital}}</td>
</tr>
</table>
</cdk-virtual-scroll-viewport>
<h2>Append only</h2>
<cdk-virtual-scroll-viewport class="demo-viewport" appendOnly [itemSize]="50">
<div *cdkVirtualFor="let size of fixedSizeData; let i = index" class="demo-item"
[style.height.px]="size">
Item #{{i}} - ({{size}}px)
</div>
</cdk-virtual-scroll-viewport>
<h2>Virtual scroller with scrolling parent</h2>
<cdk-virtual-scroll-parent-scrolling-example class="demo-resize-example">
</cdk-virtual-scroll-parent-scrolling-example>
<h2>Virtual scroller with scrolling window</h2>
<cdk-virtual-scroll-window-scrolling-example [shouldRun]="true">
</cdk-virtual-scroll-window-scrolling-example>
| {
"end_byte": 6744,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/virtual-scroll/virtual-scroll-demo.html"
} |
components/src/dev-app/virtual-scroll/BUILD.bazel_0_686 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "virtual-scroll",
srcs = glob(["**/*.ts"]),
assets = [
"virtual-scroll-demo.html",
":virtual_scroll_demo_scss",
],
deps = [
"//src/cdk-experimental/scrolling",
"//src/cdk/scrolling",
"//src/components-examples/cdk/scrolling",
"//src/material/button",
"//src/material/form-field",
"//src/material/input",
"//src/material/select",
"@npm//@angular/forms",
],
)
sass_binary(
name = "virtual_scroll_demo_scss",
src = "virtual-scroll-demo.scss",
)
| {
"end_byte": 686,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/virtual-scroll/BUILD.bazel"
} |
components/src/dev-app/virtual-scroll/virtual-scroll-demo.ts_0_5320 | /**
* @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, OnDestroy, ViewEncapsulation} from '@angular/core';
import {AsyncPipe} from '@angular/common';
import {CdkVirtualScrollViewport, ScrollingModule} from '@angular/cdk/scrolling';
import {ScrollingModule as ExperimentalScrollingModule} from '@angular/cdk-experimental/scrolling';
import {FormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {BehaviorSubject} from 'rxjs';
import {
CdkVirtualScrollParentScrollingExample,
CdkVirtualScrollWindowScrollingExample,
} from '@angular/components-examples/cdk/scrolling';
type State = {
name: string;
capital: string;
};
@Component({
selector: 'virtual-scroll-demo',
templateUrl: 'virtual-scroll-demo.html',
styleUrl: 'virtual-scroll-demo.css',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
AsyncPipe,
ExperimentalScrollingModule,
FormsModule,
MatButtonModule,
MatFormFieldModule,
MatInputModule,
MatSelectModule,
ScrollingModule,
CdkVirtualScrollParentScrollingExample,
CdkVirtualScrollWindowScrollingExample,
],
})
export class VirtualScrollDemo implements OnDestroy {
scrollToOffset = 0;
scrollToIndex = 0;
scrollToBehavior: ScrollBehavior = 'auto';
scrolledIndex = new Map<CdkVirtualScrollViewport, number>();
fixedSizeData = Array(10000).fill(50);
increasingSizeData = Array(10000)
.fill(0)
.map((_, i) => (1 + Math.floor(i / 1000)) * 20);
decreasingSizeData = Array(10000)
.fill(0)
.map((_, i) => (1 + Math.floor((10000 - i) / 1000)) * 20);
randomData = Array(10000)
.fill(0)
.map(() => Math.round(Math.random() * 100));
readonly observableData = new BehaviorSubject<number[]>([]);
states = [
{name: 'Alabama', capital: 'Montgomery'},
{name: 'Alaska', capital: 'Juneau'},
{name: 'Arizona', capital: 'Phoenix'},
{name: 'Arkansas', capital: 'Little Rock'},
{name: 'California', capital: 'Sacramento'},
{name: 'Colorado', capital: 'Denver'},
{name: 'Connecticut', capital: 'Hartford'},
{name: 'Delaware', capital: 'Dover'},
{name: 'Florida', capital: 'Tallahassee'},
{name: 'Georgia', capital: 'Atlanta'},
{name: 'Hawaii', capital: 'Honolulu'},
{name: 'Idaho', capital: 'Boise'},
{name: 'Illinois', capital: 'Springfield'},
{name: 'Indiana', capital: 'Indianapolis'},
{name: 'Iowa', capital: 'Des Moines'},
{name: 'Kansas', capital: 'Topeka'},
{name: 'Kentucky', capital: 'Frankfort'},
{name: 'Louisiana', capital: 'Baton Rouge'},
{name: 'Maine', capital: 'Augusta'},
{name: 'Maryland', capital: 'Annapolis'},
{name: 'Massachusetts', capital: 'Boston'},
{name: 'Michigan', capital: 'Lansing'},
{name: 'Minnesota', capital: 'St. Paul'},
{name: 'Mississippi', capital: 'Jackson'},
{name: 'Missouri', capital: 'Jefferson City'},
{name: 'Montana', capital: 'Helena'},
{name: 'Nebraska', capital: 'Lincoln'},
{name: 'Nevada', capital: 'Carson City'},
{name: 'New Hampshire', capital: 'Concord'},
{name: 'New Jersey', capital: 'Trenton'},
{name: 'New Mexico', capital: 'Santa Fe'},
{name: 'New York', capital: 'Albany'},
{name: 'North Carolina', capital: 'Raleigh'},
{name: 'North Dakota', capital: 'Bismarck'},
{name: 'Ohio', capital: 'Columbus'},
{name: 'Oklahoma', capital: 'Oklahoma City'},
{name: 'Oregon', capital: 'Salem'},
{name: 'Pennsylvania', capital: 'Harrisburg'},
{name: 'Rhode Island', capital: 'Providence'},
{name: 'South Carolina', capital: 'Columbia'},
{name: 'South Dakota', capital: 'Pierre'},
{name: 'Tennessee', capital: 'Nashville'},
{name: 'Texas', capital: 'Austin'},
{name: 'Utah', capital: 'Salt Lake City'},
{name: 'Vermont', capital: 'Montpelier'},
{name: 'Virginia', capital: 'Richmond'},
{name: 'Washington', capital: 'Olympia'},
{name: 'West Virginia', capital: 'Charleston'},
{name: 'Wisconsin', capital: 'Madison'},
{name: 'Wyoming', capital: 'Cheyenne'},
];
statesObservable = new BehaviorSubject(this.states);
indexTrackFn = (index: number) => index;
nameTrackFn = (_: number, item: State) => item.name;
constructor() {
this.emitData();
}
ngOnDestroy() {
this.scrolledIndex.clear();
}
emitData() {
let data = this.observableData.value.concat([50]);
this.observableData.next(data);
}
sortBy(prop: 'name' | 'capital') {
this.statesObservable.next(
this.states
.map(s => ({...s}))
.sort((a, b) => {
const aProp = a[prop],
bProp = b[prop];
if (aProp < bProp) {
return -1;
} else if (aProp > bProp) {
return 1;
}
return 0;
}),
);
}
scrolled(viewport: CdkVirtualScrollViewport, index: number) {
this.scrolledIndex.set(viewport, index);
}
}
| {
"end_byte": 5320,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/virtual-scroll/virtual-scroll-demo.ts"
} |
components/src/dev-app/toolbar/toolbar-demo.html_0_2300 | <div class="demo-toolbar">
<p>
<toolbar-simple-example></toolbar-simple-example>
</p>
<p>
<toolbar-overview-example></toolbar-overview-example>
</p>
<p>
<mat-toolbar>
<button mat-icon-button>
<mat-icon>menu</mat-icon>
</button>
<span>Default Toolbar</span>
<span class="demo-fill-remaining"></span>
<button mat-button color="accent">Text</button>
<button mat-button>Text</button>
<button mat-icon-button>
<mat-icon>code</mat-icon>
</button>
<button mat-icon-button color="warn">
<mat-icon>code</mat-icon>
</button>
</mat-toolbar>
</p>
<p>
<mat-toolbar color="primary">
<button mat-icon-button>
<mat-icon>menu</mat-icon>
</button>
<span>Primary Toolbar</span>
<span class="demo-fill-remaining"></span>
<button mat-raised-button>Text</button>
<button mat-raised-button color="accent">Accent</button>
<button mat-stroked-button>Stroked</button>
</mat-toolbar>
</p>
<p>
<mat-toolbar color="accent">
<button mat-icon-button>
<mat-icon>menu</mat-icon>
</button>
<span>Accent Toolbar</span>
<span class="demo-fill-remaining"></span>
<button mat-button>Text</button>
<button mat-flat-button>Flat</button>
<button mat-mini-fab>
<mat-icon>done</mat-icon>
</button>
<button mat-mini-fab color="primary">
<mat-icon>done</mat-icon>
</button>
</mat-toolbar>
</p>
<p>
<mat-toolbar>
<mat-toolbar-row>First Row</mat-toolbar-row>
<mat-toolbar-row>Second Row</mat-toolbar-row>
</mat-toolbar>
</p>
<p>
<mat-toolbar color="primary">
<mat-toolbar-row>
<span>First Row</span>
</mat-toolbar-row>
<mat-toolbar-row>
<span>Second Row</span>
<span class="demo-fill-remaining"></span>
<mat-icon class="demo-toolbar-icon">verified_user</mat-icon>
</mat-toolbar-row>
<mat-toolbar-row>
<span>Third Row</span>
<span class="demo-fill-remaining"></span>
<mat-icon class="demo-toolbar-icon">favorite</mat-icon>
<mat-icon class="demo-toolbar-icon">delete</mat-icon>
</mat-toolbar-row>
</mat-toolbar>
</p>
</div>
| {
"end_byte": 2300,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/toolbar/toolbar-demo.html"
} |
components/src/dev-app/toolbar/toolbar-demo.scss_0_168 | .demo-toolbar {
padding: 6px;
.demo-toolbar-icon {
padding: 0 14px;
}
.demo-fill-remaining {
flex: 1 1 auto;
}
button {
margin: 0 4px;
}
}
| {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/toolbar/toolbar-demo.scss"
} |
components/src/dev-app/toolbar/toolbar-demo.ts_0_976 | /**
* @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 {ToolbarOverviewExample} from '@angular/components-examples/material/toolbar';
import {ToolbarSimpleExample} from '@angular/components-examples/material/toolbar/toolbar-simple/toolbar-simple-example';
import {ChangeDetectionStrategy, Component} from '@angular/core';
import {MatButtonModule} from '@angular/material/button';
import {MatIconModule} from '@angular/material/icon';
import {MatToolbarModule} from '@angular/material/toolbar';
@Component({
selector: 'toolbar-demo',
templateUrl: 'toolbar-demo.html',
styleUrl: 'toolbar-demo.css',
imports: [
MatButtonModule,
MatIconModule,
MatToolbarModule,
ToolbarOverviewExample,
ToolbarSimpleExample,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ToolbarDemo {}
| {
"end_byte": 976,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/toolbar/toolbar-demo.ts"
} |
components/src/dev-app/toolbar/BUILD.bazel_0_510 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "toolbar",
srcs = glob(["**/*.ts"]),
assets = [
"toolbar-demo.html",
":toolbar_demo_scss",
],
deps = [
"//src/components-examples/material/toolbar",
"//src/material/button",
"//src/material/icon",
"//src/material/toolbar",
],
)
sass_binary(
name = "toolbar_demo_scss",
src = "toolbar-demo.scss",
)
| {
"end_byte": 510,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/toolbar/BUILD.bazel"
} |
components/src/dev-app/checkbox/checkbox-demo.scss_0_36 | .demo-checkbox {
margin: 8px 0;
}
| {
"end_byte": 36,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/checkbox/checkbox-demo.scss"
} |
components/src/dev-app/checkbox/checkbox-demo.ts_0_3915 | /**
* @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 {ANIMATION_MODULE_TYPE, ChangeDetectionStrategy, Component, Directive} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MAT_CHECKBOX_DEFAULT_OPTIONS, MatCheckboxModule} from '@angular/material/checkbox';
import {MatPseudoCheckboxModule, ThemePalette} from '@angular/material/core';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatTooltip} from '@angular/material/tooltip';
export interface Task {
name: string;
completed: boolean;
subtasks?: Task[];
}
@Directive({
selector: '[clickActionNoop]',
providers: [{provide: MAT_CHECKBOX_DEFAULT_OPTIONS, useValue: {clickAction: 'noop'}}],
})
export class ClickActionNoop {}
@Directive({
selector: '[clickActionCheck]',
providers: [{provide: MAT_CHECKBOX_DEFAULT_OPTIONS, useValue: {clickAction: 'check'}}],
})
export class ClickActionCheck {}
@Directive({
selector: '[animationsNoop]',
providers: [{provide: ANIMATION_MODULE_TYPE, useValue: 'NoopAnimations'}],
})
export class AnimationsNoop {}
@Component({
selector: 'mat-checkbox-demo-nested-checklist',
styles: `
li {
margin-bottom: 4px;
}
`,
templateUrl: 'nested-checklist.html',
imports: [MatCheckboxModule, FormsModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MatCheckboxDemoNestedChecklist {
tasks: Task[] = [
{
name: 'Reminders',
completed: false,
subtasks: [
{name: 'Cook Dinner', completed: false},
{name: 'Read the Material Design Spec', completed: false},
{name: 'Upgrade Application to Angular', completed: false},
],
},
{
name: 'Groceries',
completed: false,
subtasks: [
{name: 'Organic Eggs', completed: false},
{name: 'Protein Powder', completed: false},
{name: 'Almond Meal Flour', completed: false},
],
},
];
allComplete(task: Task): boolean {
const subtasks = task.subtasks;
return task.completed || (subtasks != null && subtasks.every(t => t.completed));
}
someComplete(tasks: Task[] | undefined | null): boolean {
if (tasks == null) {
return false;
}
const numComplete = tasks.filter(t => t.completed).length;
return numComplete > 0 && numComplete < tasks.length;
}
setAllCompleted(tasks: Task[] | undefined | null, completed: boolean): void {
if (tasks == null) {
return;
}
tasks.forEach(t => (t.completed = completed));
}
}
@Component({
selector: 'checkbox-demo',
templateUrl: 'checkbox-demo.html',
styleUrl: 'checkbox-demo.css',
imports: [
FormsModule,
MatCheckboxModule,
MatInputModule,
MatSelectModule,
MatPseudoCheckboxModule,
ReactiveFormsModule,
MatCheckboxDemoNestedChecklist,
ClickActionNoop,
ClickActionCheck,
AnimationsNoop,
MatTooltip,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CheckboxDemo {
isIndeterminate = false;
isChecked = false;
isDisabled = false;
isDisabledInteractive = false;
labelPosition: 'before' | 'after' = 'after';
useAlternativeColor = false;
demoRequired = false;
demoLabelAfter = false;
demoChecked = false;
demoDisabled = false;
demoIndeterminate = false;
demoLabel: string;
demoLabelledBy: string;
demoId: string;
demoName: string;
demoValue: string;
demoColor: ThemePalette = 'primary';
demoDisableRipple = false;
demoHideLabel = false;
printResult() {
if (this.isIndeterminate) {
return 'Maybe!';
}
return this.isChecked ? 'Yes!' : 'No!';
}
checkboxColor() {
return this.useAlternativeColor ? 'primary' : 'accent';
}
}
| {
"end_byte": 3915,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/checkbox/checkbox-demo.ts"
} |
components/src/dev-app/checkbox/checkbox-demo.html_0_3212 | <h1> Themed Checkboxes </h1>
<div>
<mat-checkbox>Default</mat-checkbox>
</div>
<div>
<mat-checkbox color="primary">Primary</mat-checkbox>
</div>
<div>
<mat-checkbox color="accent">Accent</mat-checkbox>
</div>
<div>
<mat-checkbox color="warn">Warn</mat-checkbox>
</div>
<h1>mat-checkbox: Basic Example</h1>
<form>
<mat-checkbox [(ngModel)]="isChecked"
name="cb"
value="basic_checkbox"
[color]="checkboxColor()"
(change)="isIndeterminate = false"
[indeterminate]="isIndeterminate"
[disabled]="isDisabled"
[disabledInteractive]="isDisabledInteractive"
[labelPosition]="labelPosition"
[matTooltip]="isDisabled ? 'Tooltip that only shows up when disabled' : null">
Do you want to <em>foobar</em> the <em>bazquux</em>?
</mat-checkbox> - <strong>{{printResult()}}</strong>
</form>
<div class="demo-checkbox">
<input id="indeterminate-toggle" type="checkbox" [(ngModel)]="isIndeterminate">
<label for="indeterminate-toggle">Toggle Indeterminate</label>
<input id="disabled-toggle" type="checkbox" [(ngModel)]="isDisabled">
<label for="disabled-toggle">Toggle Disabled</label>
<input id="disabled-interactive-toggle" type="checkbox" [(ngModel)]="isDisabledInteractive">
<label for="disabled-interactive-toggle">Toggle Disabled Interactive</label>
<input id="color-toggle" type="checkbox" [(ngModel)]="useAlternativeColor">
<label for="color-toggle">Toggle Color</label>
</div>
<div>
<p>Label position:</p>
<div>
<input #after type="radio"
value="after"
id="align-after"
name="labelPosition"
(click)="labelPosition = 'after'"
checked>
<label for="align-after">After</label>
</div>
<div>
<input #before type="radio"
value="before"
id="align-before"
name="labelPosition"
(click)="labelPosition = 'before'">
<label for="align-before">Before</label>
</div>
</div>
<h1>Pseudo checkboxes</h1>
<div>
<h2>Full appearance</h2>
<mat-pseudo-checkbox></mat-pseudo-checkbox>
<mat-pseudo-checkbox [disabled]="true"></mat-pseudo-checkbox>
<mat-pseudo-checkbox state="checked"></mat-pseudo-checkbox>
<mat-pseudo-checkbox state="checked" [disabled]="true"></mat-pseudo-checkbox>
<mat-pseudo-checkbox state="indeterminate"></mat-pseudo-checkbox>
<mat-pseudo-checkbox state="indeterminate" [disabled]="true"></mat-pseudo-checkbox>
<div>
<div>
<h2>Minimal appearance</h2>
<mat-pseudo-checkbox appearance="minimal"></mat-pseudo-checkbox>
<mat-pseudo-checkbox appearance="minimal" [disabled]="true"></mat-pseudo-checkbox>
<mat-pseudo-checkbox appearance="minimal" state="checked"></mat-pseudo-checkbox>
<mat-pseudo-checkbox appearance="minimal" state="checked" [disabled]="true"></mat-pseudo-checkbox>
<mat-pseudo-checkbox appearance="minimal" state="indeterminate"></mat-pseudo-checkbox>
<mat-pseudo-checkbox appearance="minimal" state="indeterminate" [disabled]="true">
</mat-pseudo-checkbox>
<div>
<h1>Nested Checklist</h1>
<mat-checkbox-demo-nested-checklist></mat-checkbox-demo-nested-checklist> | {
"end_byte": 3212,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/checkbox/checkbox-demo.html"
} |
components/src/dev-app/checkbox/checkbox-demo.html_3214_10386 | <div style="padding: 10px; border: 1px solid black">
<h4>Configuration</h4>
<mat-checkbox [(ngModel)]="demoRequired">required?</mat-checkbox><br>
<mat-checkbox [(ngModel)]="demoLabelAfter">label after?</mat-checkbox><br>
<mat-checkbox [(ngModel)]="demoChecked">checked?</mat-checkbox><br>
<mat-checkbox [(ngModel)]="demoDisabled">disabled?</mat-checkbox><br>
<mat-checkbox [(ngModel)]="demoIndeterminate">indeterminate?</mat-checkbox><br>
<mat-checkbox [(ngModel)]="demoDisableRipple">disable ripple?</mat-checkbox><br>
<mat-checkbox [(ngModel)]="demoHideLabel">hide label?</mat-checkbox><br>
<mat-form-field>
<mat-label>aria-label</mat-label>
<input matInput [(ngModel)]="demoLabel">
</mat-form-field><br>
<mat-form-field>
<mat-label>aria-labelledby</mat-label>
<mat-select [(ngModel)]="demoLabelledBy">
<mat-option>None</mat-option>
<mat-option value="mylabel">My Label</mat-option>
</mat-select>
</mat-form-field><label id="mylabel">My Label</label><br>
<mat-form-field>
<mat-label>id</mat-label>
<input matInput [(ngModel)]="demoId">
</mat-form-field><br>
<mat-form-field>
<mat-label>name</mat-label>
<input matInput [(ngModel)]="demoName">
</mat-form-field><br>
<mat-form-field>
<mat-label>value</mat-label>
<input matInput [(ngModel)]="demoValue">
</mat-form-field><br>
<mat-form-field>
<mat-label>color</mat-label>
<mat-select [(ngModel)]="demoColor">
<mat-option value="primary">primary</mat-option>
<mat-option value="accent">accent</mat-option>
<mat-option value="warn">warn</mat-option>
</mat-select>
</mat-form-field>
<br><br>
<h4>Result</h4>
<div>
<h5>Click action: check-indeterminate</h5>
<mat-checkbox
[required]="demoRequired"
[labelPosition]="demoLabelAfter ? 'after' : 'before'"
[aria-label]="demoLabel"
[aria-labelledby]="demoLabelledBy"
[color]="demoColor"
[disableRipple]="demoDisableRipple"
[id]="demoId"
[name]="demoName"
[value]="demoValue"
[checked]="demoChecked"
[disabled]="demoDisabled"
[indeterminate]="demoIndeterminate"
(change)="demoChecked = $event.checked"
(indeterminateChange)="demoIndeterminate = $event">
@if (!demoHideLabel) {
Checkbox w/ [checked] & (change)
}
</mat-checkbox>
<mat-checkbox
[required]="demoRequired"
[labelPosition]="demoLabelAfter ? 'after' : 'before'"
[aria-label]="demoLabel"
[aria-labelledby]="demoLabelledBy"
[color]="demoColor"
[disableRipple]="demoDisableRipple"
[id]="demoId"
[name]="demoName"
[value]="demoValue"
[disabled]="demoDisabled"
[indeterminate]="demoIndeterminate"
[(ngModel)]="demoChecked"
(indeterminateChange)="demoIndeterminate = $event">
@if (!demoHideLabel) {
Checkbox w/ [(ngModel)]
}
</mat-checkbox>
</div>
<div clickActionCheck>
<h5>Click action: check</h5>
<mat-checkbox
[required]="demoRequired"
[labelPosition]="demoLabelAfter ? 'after' : 'before'"
[aria-label]="demoLabel"
[aria-labelledby]="demoLabelledBy"
[color]="demoColor"
[disableRipple]="demoDisableRipple"
[id]="demoId"
[name]="demoName"
[value]="demoValue"
[checked]="demoChecked"
[disabled]="demoDisabled"
[indeterminate]="demoIndeterminate"
(change)="demoChecked = $event.checked"
(indeterminateChange)="demoIndeterminate = $event">
@if (!demoHideLabel) {
Checkbox w/ [checked] & (change)
}
</mat-checkbox>
<mat-checkbox
[required]="demoRequired"
[labelPosition]="demoLabelAfter ? 'after' : 'before'"
[aria-label]="demoLabel"
[aria-labelledby]="demoLabelledBy"
[color]="demoColor"
[disableRipple]="demoDisableRipple"
[id]="demoId"
[name]="demoName"
[value]="demoValue"
[disabled]="demoDisabled"
[indeterminate]="demoIndeterminate"
[(ngModel)]="demoChecked"
(indeterminateChange)="demoIndeterminate = $event">
@if (!demoHideLabel) {
Checkbox w/ [(ngModel)]
}
</mat-checkbox>
</div>
<div clickActionNoop>
<h5>Click action: noop</h5>
<mat-checkbox
[required]="demoRequired"
[labelPosition]="demoLabelAfter ? 'after' : 'before'"
[aria-label]="demoLabel"
[aria-labelledby]="demoLabelledBy"
[color]="demoColor"
[disableRipple]="demoDisableRipple"
[id]="demoId"
[name]="demoName"
[value]="demoValue"
[checked]="demoChecked"
[disabled]="demoDisabled"
[indeterminate]="demoIndeterminate"
(change)="demoChecked = $event.checked"
(indeterminateChange)="demoIndeterminate = $event">
@if (!demoHideLabel) {
Checkbox w/ [checked] & (change)
}
</mat-checkbox>
<mat-checkbox
[required]="demoRequired"
[labelPosition]="demoLabelAfter ? 'after' : 'before'"
[aria-label]="demoLabel"
[aria-labelledby]="demoLabelledBy"
[color]="demoColor"
[disableRipple]="demoDisableRipple"
[id]="demoId"
[name]="demoName"
[value]="demoValue"
[disabled]="demoDisabled"
[indeterminate]="demoIndeterminate"
[(ngModel)]="demoChecked"
(indeterminateChange)="demoIndeterminate = $event">
@if (!demoHideLabel) {
Checkbox w/ [(ngModel)]
}
</mat-checkbox>
</div>
<div animationsNoop>
<h5>No animations</h5>
<mat-checkbox
[required]="demoRequired"
[labelPosition]="demoLabelAfter ? 'after' : 'before'"
[aria-label]="demoLabel"
[aria-labelledby]="demoLabelledBy"
[color]="demoColor"
[disableRipple]="demoDisableRipple"
[id]="demoId"
[name]="demoName"
[value]="demoValue"
[checked]="demoChecked"
[disabled]="demoDisabled"
[indeterminate]="demoIndeterminate"
(change)="demoChecked = $event.checked"
(indeterminateChange)="demoIndeterminate = $event">
@if (!demoHideLabel) {
Checkbox w/ [checked] & (change)
}
</mat-checkbox>
<mat-checkbox
[required]="demoRequired"
[labelPosition]="demoLabelAfter ? 'after' : 'before'"
[aria-label]="demoLabel"
[aria-labelledby]="demoLabelledBy"
[color]="demoColor"
[disableRipple]="demoDisableRipple"
[id]="demoId"
[name]="demoName"
[value]="demoValue"
[disabled]="demoDisabled"
[indeterminate]="demoIndeterminate"
[(ngModel)]="demoChecked"
(indeterminateChange)="demoIndeterminate = $event">
@if (!demoHideLabel) {
Checkbox w/ [(ngModel)]
}
</mat-checkbox>
</div>
</div>
<p>
<mat-checkbox class="demo-traffic-light-checkbox">
This checkbox has special styling when using the experimental token based theme
</mat-checkbox>
</p> | {
"end_byte": 10386,
"start_byte": 3214,
"url": "https://github.com/angular/components/blob/main/src/dev-app/checkbox/checkbox-demo.html"
} |
components/src/dev-app/checkbox/nested-checklist.html_0_594 | <h2>Tasks</h2>
<ul>
@for (task of tasks; track task) {
<li>
<mat-checkbox
[(ngModel)]="task.completed"
[checked]="allComplete(task)"
[indeterminate]="someComplete(task.subtasks)"
(change)="setAllCompleted(task.subtasks, $event.checked)">
<h3>{{task.name}}</h3>
</mat-checkbox>
<ul>
@for (subtask of task.subtasks; track subtask) {
<li>
<mat-checkbox [(ngModel)]="subtask.completed">
{{subtask.name}}
</mat-checkbox>
</li>
}
</ul>
</li>
}
</ul>
| {
"end_byte": 594,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/checkbox/nested-checklist.html"
} |
components/src/dev-app/checkbox/BUILD.bazel_0_630 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "checkbox",
srcs = glob(["**/*.ts"]),
assets = [
"checkbox-demo.html",
"nested-checklist.html",
":checkbox_demo_scss",
],
deps = [
"//src/material/checkbox",
"//src/material/core",
"//src/material/form-field",
"//src/material/input",
"//src/material/select",
"//src/material/tooltip",
"@npm//@angular/forms",
],
)
sass_binary(
name = "checkbox_demo_scss",
src = "checkbox-demo.scss",
)
| {
"end_byte": 630,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/checkbox/BUILD.bazel"
} |
components/src/dev-app/baseline/baseline-demo.scss_0_155 | .demo-basic {
padding: 0;
}
.demo-basic .mat-mdc-card-content {
padding: 16px;
}
.demo-full-width {
width: 100%;
}
.demo-card {
margin: 16px;
}
| {
"end_byte": 155,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/baseline/baseline-demo.scss"
} |
components/src/dev-app/baseline/baseline-demo.html_0_2250 | <mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Basic Forms</mat-toolbar>
<mat-card-content>
Text Before |
<mat-checkbox>Checkbox Label</mat-checkbox>
| Text 1 |
<mat-radio-button value="option_1">Radio 1</mat-radio-button>
| Text 2 |
<mat-radio-button value="option_2">Radio 2</mat-radio-button>
| Text 3 |
<mat-radio-button value="option_3">Radio 3</mat-radio-button>
| Text 4 |
<mat-form-field>
<mat-label>Input</mat-label>
<input matInput value="Text Input">
</mat-form-field>
| Text 5 |
<mat-form-field>
<mat-label>This label is really really really long</mat-label>
<mat-select>
<mat-option value="option">Option</mat-option>
<mat-option value="long">This option is really really really long</mat-option>
</mat-select>
</mat-form-field>
| Text 6 |
<mat-form-field>
<mat-label>Input</mat-label>
<textarea matInput cdkTextareaAutosize>Textarea Line 2</textarea>
</mat-form-field>
| Text After
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Headers</mat-toolbar>
<mat-card-content>
<h1>
Text Before |
<mat-checkbox>Checkbox Label</mat-checkbox>
| Text 1 |
<mat-radio-button value="option_1">Radio 1</mat-radio-button>
| Text 2 |
<mat-radio-button value="option_2">Radio 2</mat-radio-button>
| Text 3 |
<mat-radio-button value="option_3">Radio 3</mat-radio-button>
| Text 4 |
<mat-form-field>
<mat-label>Input</mat-label>
<input matInput value="Text Input">
</mat-form-field>
| Text 5 |
<mat-form-field>
<mat-label>This label is really really really long</mat-label>
<mat-select>
<mat-option value="option">Option</mat-option>
<mat-option value="long">This option is really really really long</mat-option>
</mat-select>
</mat-form-field>
| Text 6 |
<mat-form-field>
<mat-label>Input</mat-label>
<textarea matInput cdkTextareaAutosize>Textarea Line 2</textarea>
</mat-form-field>
| Text After
</h1>
</mat-card-content>
</mat-card>
| {
"end_byte": 2250,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/baseline/baseline-demo.html"
} |
components/src/dev-app/baseline/baseline-demo.ts_0_1061 | /**
* @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 {MatCardModule} from '@angular/material/card';
import {MatCheckboxModule} from '@angular/material/checkbox';
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 {MatToolbarModule} from '@angular/material/toolbar';
@Component({
selector: 'baseline-demo',
templateUrl: 'baseline-demo.html',
styleUrl: 'baseline-demo.css',
imports: [
MatCardModule,
MatCheckboxModule,
MatFormFieldModule,
MatInputModule,
MatRadioModule,
MatSelectModule,
MatToolbarModule,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BaselineDemo {
name: string;
}
| {
"end_byte": 1061,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/baseline/baseline-demo.ts"
} |
components/src/dev-app/baseline/BUILD.bazel_0_597 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "baseline",
srcs = glob(["**/*.ts"]),
assets = [
"baseline-demo.html",
":baseline_demo_scss",
],
deps = [
"//src/material/card",
"//src/material/checkbox",
"//src/material/form-field",
"//src/material/input",
"//src/material/radio",
"//src/material/select",
"//src/material/toolbar",
],
)
sass_binary(
name = "baseline_demo_scss",
src = "baseline-demo.scss",
)
| {
"end_byte": 597,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/baseline/BUILD.bazel"
} |
components/src/dev-app/slider/slider-demo.scss_0_900 | .demo-data-table {
font-family: arial, sans-serif;
border-collapse: collapse;
margin: 24px;
}
.demo-value-cell,
.demo-control-cell,
.demo-table-header {
border: 1px solid #aaa;
text-align: left;
padding: 8px;
}
@media (max-width: 600px) {
.demo-data-table {
font-size: 12px;
margin: 24px 0;
}
.demo-table-header {
text-align: center;
}
.demo-control-cell {
max-width: 130px;
.demo-slider-control {
width: calc(100% - 8px);
}
}
}
.demo-value-cell {
width: 130px;
}
.mat-mdc-slider {
width: calc(100% - 48px);
margin: 0 24px;
}
.demo-native-slider {
margin: 0;
padding: 16px;
width: calc(100% - 16px);
}
.mat-mdc-tab-group {
border: 1px solid;
border-radius: 5px;
min-width: 300px;
margin-top: 30px;
}
.demo-dialog-trigger-container {
padding: 25px 0;
text-align: center;
}
.demo-dialog-content {
overflow: visible;
}
| {
"end_byte": 900,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/slider/slider-demo.scss"
} |
components/src/dev-app/slider/slider-demo.html_0_5472 | <mat-checkbox [color]="colorModel" [(ngModel)]="discrete">Discrete</mat-checkbox>
<br>
<mat-checkbox [color]="colorModel" [(ngModel)]="showTickMarks">Show tick marks</mat-checkbox>
<br>
<mat-button-toggle-group [(ngModel)]="colorModel" aria-label="Slider color options">
<mat-button-toggle value="primary">Primary</mat-button-toggle>
<mat-button-toggle value="accent">Accent</mat-button-toggle>
<mat-button-toggle value="warn">Warn</mat-button-toggle>
</mat-button-toggle-group>
<mat-tab-group [color]="colorModel">
<mat-tab label="Reactive form controls">
<table class="demo-data-table">
<tr>
<th class="demo-table-header">Inputs</th>
<th class="demo-table-header">Controls</th>
<th class="demo-table-header">Native Slider</th>
<th class="demo-table-header">Single Slider</th>
<th class="demo-table-header">Double Slider</th>
</tr>
<tr>
<th class="demo-table-header">Value</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="number" (input)="updateControlValue($event.target)" /></td>
<td class="demo-value-cell">{{nativeSlider1.value}}</td>
<td class="demo-value-cell">{{ngThumb1.value}}</td>
<td class="demo-value-cell">{{ngStartThumb1.value}} : {{ngEndThumb1.value}}</td>
</tr>
<tr>
<th class="demo-table-header">Disabled</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="checkbox" (input)="updateControlDisabledState($event.target)" /></td>
<td class="demo-value-cell">{{nativeSlider1.disabled}}</td>
<td class="demo-value-cell">{{ngThumb1.disabled}}</td>
<td class="demo-value-cell">{{ngStartThumb1.disabled}} : {{ngEndThumb1.disabled}}</td>
</tr>
</table>
<input class="demo-native-slider" type="range" [formControl]="control" #nativeSlider1 />
<mat-slider [discrete]="discrete" [showTickMarks]="showTickMarks" [color]="colorModel">
<input matSliderThumb [formControl]="control" #ngThumb1 />
</mat-slider>
<mat-slider [discrete]="discrete" [showTickMarks]="showTickMarks" [color]="colorModel">
<input matSliderStartThumb [formControl]="control" #ngStartThumb1 />
<input matSliderEndThumb #ngEndThumb1 />
</mat-slider>
</mat-tab>
<mat-tab label="Template-driven form controls">
<table class="demo-data-table">
<tr>
<th class="demo-table-header">Inputs</th>
<th class="demo-table-header">Controls</th>
<th class="demo-table-header">Native Slider</th>
<th class="demo-table-header">Slider</th>
<th class="demo-table-header">Range Slider</th>
</tr>
<tr>
<th class="demo-table-header">Value</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="number" [(ngModel)]="valueModel" /></td>
<td class="demo-value-cell">{{nativeSlider2.value}}</td>
<td class="demo-value-cell">{{ngThumb2.value}}</td>
<td class="demo-value-cell">{{ngStartThumb2.value}} : {{ngEndThumb2.value}}</td>
</tr>
<tr>
<th class="demo-table-header">Min</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="number" [(ngModel)]="minModel" /></td>
<td class="demo-value-cell">{{nativeSlider2.min}}</td>
<td class="demo-value-cell">{{ngThumb2.min}}</td>
<td class="demo-value-cell">{{ngStartThumb2.min}} : {{ngEndThumb2.min}}</td>
</tr>
<tr>
<th class="demo-table-header">Max</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="number" [(ngModel)]="maxModel" /></td>
<td class="demo-value-cell">{{nativeSlider2.max}}</td>
<td class="demo-value-cell">{{ngThumb2.max}}</td>
<td class="demo-value-cell">{{ngStartThumb2.max}} : {{ngEndThumb2.max}}</td>
</tr>
<tr>
<th class="demo-table-header">Step</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="number" [(ngModel)]="stepModel" /></td>
<td class="demo-value-cell">{{nativeSlider2.step}}</td>
<td class="demo-value-cell">{{ngThumb2.step}}</td>
<td class="demo-value-cell">{{ngStartThumb2.step}} : {{ngEndThumb2.step}}</td>
</tr>
<tr>
<th class="demo-table-header">Disabled</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="checkbox" [(ngModel)]="disabledModel" /></td>
<td class="demo-value-cell">{{nativeSlider2.disabled}}</td>
<td class="demo-value-cell">{{ngThumb2.disabled}}</td>
<td class="demo-value-cell">{{ngStartThumb2.disabled}} : {{ngEndThumb2.disabled}}</td>
</tr>
</table>
<input class="demo-native-slider" type="range" #nativeSlider2 [(ngModel)]="valueModel" [min]="minModel" [max]="maxModel" [step]="stepModel" [disabled]="disabledModel" />
<mat-slider [discrete]="discrete" [showTickMarks]="showTickMarks" [color]="colorModel" [min]="minModel" [max]="maxModel" [step]="stepModel" [disabled]="disabledModel">
<input matSliderThumb #ngThumb2 [(ngModel)]="valueModel" />
</mat-slider>
<mat-slider [discrete]="discrete" [showTickMarks]="showTickMarks" [color]="colorModel" [min]="minModel" [max]="maxModel" [step]="stepModel" [disabled]="disabledModel">
<input matSliderStartThumb #ngStartThumb2 [(ngModel)]="valueModel" />
<input matSliderEndThumb #ngEndThumb2 />
</mat-slider>
</mat-tab> | {
"end_byte": 5472,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/slider/slider-demo.html"
} |
components/src/dev-app/slider/slider-demo.html_5476_10023 | <mat-tab label="One-way property bindings">
<table class="demo-data-table">
<tr>
<th class="demo-table-header">Inputs</th>
<th class="demo-table-header">Controls</th>
<th class="demo-table-header">Native Slider</th>
<th class="demo-table-header">Slider</th>
<th class="demo-table-header">Range Slider</th>
</tr>
<tr>
<th class="demo-table-header">Value</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="number" (input)="updateValue($event.target)" [value]="value" /></td>
<td class="demo-value-cell">{{nativeSlider3.value}}</td>
<td class="demo-value-cell">{{ngThumb3.value}}</td>
<td class="demo-value-cell">{{ngStartThumb3.value}} : {{ngEndThumb3.value}}</td>
</tr>
<tr>
<th class="demo-table-header">Min</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="number" (input)="updateMin($event.target)" [value]="min" /></td>
<td class="demo-value-cell">{{nativeSlider3.min}}</td>
<td class="demo-value-cell">{{ngThumb3.min}}</td>
<td class="demo-value-cell">{{ngStartThumb3.min}} : {{ngEndThumb3.min}}</td>
</tr>
<tr>
<th class="demo-table-header">Max</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="number" (input)="updateMax($event.target)" [value]="max" /></td>
<td class="demo-value-cell">{{nativeSlider3.max}}</td>
<td class="demo-value-cell">{{ngThumb3.max}}</td>
<td class="demo-value-cell">{{ngStartThumb3.max}} : {{ngEndThumb3.max}}</td>
</tr>
<tr>
<th class="demo-table-header">Step</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="number" (input)="updateStep($event.target)" [value]="step" /></td>
<td class="demo-value-cell">{{nativeSlider3.step}}</td>
<td class="demo-value-cell">{{ngThumb3.step}}</td>
<td class="demo-value-cell">{{ngStartThumb3.step}} : {{ngEndThumb3.step}}</td>
</tr>
<tr>
<th class="demo-table-header">Disabled</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="checkbox" (input)="updateDisabledState($event.target)" [value]="disabled" /></td>
<td class="demo-value-cell">{{nativeSlider3.disabled}}</td>
<td class="demo-value-cell">{{ngThumb3.disabled}}</td>
<td class="demo-value-cell">{{ngStartThumb3.disabled}} : {{ngEndThumb3.disabled}}</td>
</tr>
</table>
<input class="demo-native-slider" type="range" #nativeSlider3 [value]="value" [min]="min" [max]="max" [step]="step" [disabled]="disabled" />
<mat-slider [discrete]="discrete" [showTickMarks]="showTickMarks" [color]="colorModel" [min]="min" [max]="max" [step]="step" [disabled]="disabled">
<input matSliderThumb #ngThumb3 [value]="value" />
</mat-slider>
<mat-slider [discrete]="discrete" [showTickMarks]="showTickMarks" [color]="colorModel" [min]="min" [max]="max" [step]="step" [disabled]="disabled">
<input matSliderStartThumb #ngStartThumb3 [value]="value" />
<input matSliderEndThumb #ngEndThumb3 />
</mat-slider>
</mat-tab>
<mat-tab label="Two-way property bindings">
<table class="demo-data-table">
<tr>
<th class="demo-table-header">Inputs</th>
<th class="demo-table-header">Controls</th>
<th class="demo-table-header">Slider</th>
<th class="demo-table-header">Range Slider</th>
</tr>
<tr>
<th class="demo-table-header">Value</th>
<td class="demo-control-cell"><input class="demo-slider-control" type="number" [(ngModel)]="twoWayValue" /></td>
<td class="demo-value-cell">{{ngThumb4.value}}</td>
<td class="demo-value-cell">{{ngStartThumb4.value}} : {{ngEndThumb4.value}}</td>
</tr>
</table>
<mat-slider [discrete]="discrete" [showTickMarks]="showTickMarks" [color]="colorModel">
<input matSliderThumb #ngThumb4 [(value)]="twoWayValue" />
</mat-slider>
<mat-slider [discrete]="discrete" [showTickMarks]="showTickMarks" [color]="colorModel">
<input matSliderStartThumb #ngStartThumb4 [(value)]="twoWayValue" />
<input matSliderEndThumb #ngEndThumb4 />
</mat-slider>
</mat-tab>
<mat-tab label="Slider in a dialog">
<div class="demo-dialog-trigger-container">
<button mat-raised-button [color]="colorModel" (click)="openDialog()">Open dialog</button>
</div>
</mat-tab>
</mat-tab-group> | {
"end_byte": 10023,
"start_byte": 5476,
"url": "https://github.com/angular/components/blob/main/src/dev-app/slider/slider-demo.html"
} |
components/src/dev-app/slider/slider-demo.ts_0_3626 | /**
* @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 {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatButtonToggleModule} from '@angular/material/button-toggle';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {ThemePalette} from '@angular/material/core';
import {
MAT_DIALOG_DATA,
MatDialog,
MatDialogContent,
MatDialogTitle,
} from '@angular/material/dialog';
import {MatSliderModule} from '@angular/material/slider';
import {MatTabsModule} from '@angular/material/tabs';
@Component({
selector: 'slider-demo',
templateUrl: 'slider-demo.html',
imports: [
FormsModule,
MatButtonModule,
MatButtonToggleModule,
MatCheckboxModule,
MatSliderModule,
MatTabsModule,
ReactiveFormsModule,
],
styleUrl: 'slider-demo.css',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SliderDemo {
dialog = inject(MatDialog);
discrete = true;
showTickMarks = true;
colorModel: ThemePalette = 'primary';
min = '0';
max = '100';
step = '0';
value = '0';
disabled = false;
twoWayValue = 0;
minModel = 0;
maxModel = 100;
valueModel = 0;
stepModel = 0;
disabledModel = false;
control = new FormControl('0');
updateValue(input: EventTarget | null): void {
if (!input) {
return;
}
this.value = (input as HTMLInputElement).value;
}
updateMin(input: EventTarget | null): void {
if (!input) {
return;
}
this.min = (input as HTMLInputElement).value;
}
updateMax(input: EventTarget | null): void {
if (!input) {
return;
}
this.max = (input as HTMLInputElement).value;
}
updateStep(input: EventTarget | null): void {
if (!input) {
return;
}
this.step = (input as HTMLInputElement).value;
}
updateDisabledState(input: EventTarget | null): void {
if (!input) {
return;
}
this.disabled = (input as HTMLInputElement).checked;
}
updateControlValue(input: EventTarget | null): void {
if (!input) {
return;
}
this.control.setValue((input as HTMLInputElement).value);
}
updateControlDisabledState(input: EventTarget | null): void {
if (!input) {
return;
}
(input as HTMLInputElement).checked ? this.control.disable() : this.control.enable();
}
openDialog() {
this.dialog.open(SliderDialogDemo, {
data: {
color: this.colorModel,
discrete: this.discrete,
showTickMarks: this.showTickMarks,
},
});
}
}
@Component({
selector: 'slider-dialog-demo',
styleUrl: 'slider-demo.css',
template: `
<h2 mat-dialog-title>Slider in a dialog</h2>
<mat-dialog-content class="demo-dialog-content">
<mat-slider [discrete]="this.data.discrete" [showTickMarks]="this.data.showTickMarks" [color]="this.data.color" step="10">
<input value="50" matSliderThumb>
</mat-slider>
<mat-slider [discrete]="this.data.discrete" [showTickMarks]="this.data.showTickMarks" [color]="this.data.color" step="10">
<input value="30" matSliderStartThumb>
<input value="70" matSliderEndThumb>
</mat-slider>
</mat-dialog-content>
`,
imports: [MatSliderModule, MatDialogTitle, MatDialogContent],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SliderDialogDemo {
data = inject(MAT_DIALOG_DATA);
}
| {
"end_byte": 3626,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/slider/slider-demo.ts"
} |
components/src/dev-app/slider/BUILD.bazel_0_590 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "slider",
srcs = glob(["**/*.ts"]),
assets = [
"slider-demo.html",
":slider_demo_scss",
],
deps = [
"//src/material/button",
"//src/material/button-toggle",
"//src/material/checkbox",
"//src/material/dialog",
"//src/material/slider",
"//src/material/tabs",
"@npm//@angular/forms",
],
)
sass_binary(
name = "slider_demo_scss",
src = "slider-demo.scss",
)
| {
"end_byte": 590,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/slider/BUILD.bazel"
} |
components/src/dev-app/ripple/ripple-demo.ts_0_1647 | /**
* @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 {RippleOverviewExample} from '@angular/components-examples/material/core';
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 {MatRipple} from '@angular/material/core';
import {MatIconModule} from '@angular/material/icon';
import {MatInputModule} from '@angular/material/input';
@Component({
selector: 'ripple-demo',
templateUrl: 'ripple-demo.html',
styleUrl: 'ripple-demo.css',
imports: [
RippleOverviewExample,
FormsModule,
MatButtonModule,
MatCheckboxModule,
MatIconModule,
MatInputModule,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class RippleDemo {
@ViewChild(MatRipple) ripple: MatRipple;
centered = false;
disabled = false;
unbounded = false;
rounded = false;
radius: number;
rippleSpeed = 1;
rippleColor = '';
disableButtonRipples = false;
launchRipple(persistent = false, disableAnimation = false) {
if (!this.ripple) {
return;
}
const rippleConfig = {
centered: true,
persistent: persistent,
animation: disableAnimation ? {enterDuration: 0, exitDuration: 0} : undefined,
};
this.ripple.launch(0, 0, rippleConfig);
}
fadeOutAll() {
if (this.ripple) {
this.ripple.fadeOutAll();
}
}
}
| {
"end_byte": 1647,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/ripple/ripple-demo.ts"
} |
components/src/dev-app/ripple/ripple-demo.html_0_627 | <div class="demo-ripple">
<section>
<mat-checkbox [(ngModel)]="disableButtonRipples">Disable button ripples</mat-checkbox>
<button mat-button [disableRipple]="disableButtonRipples">flat</button>
<button mat-raised-button [disableRipple]="disableButtonRipples">raised</button>
<button mat-fab [disableRipple]="disableButtonRipples">
<mat-icon>check</mat-icon>
</button>
<button mat-mini-fab [disableRipple]="disableButtonRipples">
<mat-icon>check</mat-icon>
</button>
</section>
<hr>
<h3>Ripple overview example</h3>
<ripple-overview-example></ripple-overview-example>
</div>
| {
"end_byte": 627,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/ripple/ripple-demo.html"
} |
components/src/dev-app/ripple/ripple-demo.scss_0_83 | .demo-ripple {
button, a {
margin: 8px;
text-transform: uppercase;
}
}
| {
"end_byte": 83,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/ripple/ripple-demo.scss"
} |
components/src/dev-app/ripple/BUILD.bazel_0_600 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "ripple",
srcs = glob(["**/*.ts"]),
assets = [
"ripple-demo.html",
":ripple_demo_scss",
],
deps = [
"//src/components-examples/material/core",
"//src/dev-app/example",
"//src/material/button",
"//src/material/checkbox",
"//src/material/icon",
"//src/material/input",
"@npm//@angular/forms",
],
)
sass_binary(
name = "ripple_demo_scss",
src = "ripple-demo.scss",
)
| {
"end_byte": 600,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/ripple/BUILD.bazel"
} |
components/src/dev-app/stepper/stepper-demo.html_0_7218 | <p>
<mat-checkbox [(ngModel)]="isNonLinear">Disable linear mode</mat-checkbox>
</p>
<p>
<mat-checkbox [(ngModel)]="disableRipple">Disable header ripple</mat-checkbox>
</p>
<p>
<mat-checkbox [(ngModel)]="isVertical">Vertical</mat-checkbox>
</p>
<p>
<button mat-stroked-button (click)="showLabelBottom = !showLabelBottom">
Toggle label position
</button>
</p>
<p>
<mat-form-field>
<mat-label>Theme</mat-label>
<mat-select [(ngModel)]="theme">
@for (theme of availableThemes; track theme) {
<mat-option [value]="theme.value">{{theme.name}}</mat-option>
}
</mat-select>
</mat-form-field>
</p>
<h3>Linear Stepper Demo using a single form</h3>
<form [formGroup]="formGroup">
<mat-stepper
#linearStepper="matVerticalStepper"
formArrayName="formArray"
[orientation]="isVertical ? 'vertical' : 'horizontal'"
[linear]="!isNonLinear"
[disableRipple]="disableRipple"
[color]="theme">
<mat-step formGroupName="0" [stepControl]="formArray?.get([0]) === null ? undefined! : formArray?.get([0])!">
<ng-template matStepLabel>Fill out your name</ng-template>
<mat-form-field>
<mat-label>First name</mat-label>
<input matInput formControlName="firstNameFormCtrl" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Last name</mat-label>
<input matInput formControlName="lastNameFormCtrl" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step formGroupName="1" [stepControl]="formArray?.get([1]) === null ? undefined! : formArray?.get([1])!"
optional>
<ng-template matStepLabel>
<div>Fill out your email address</div>
</ng-template>
<mat-form-field>
<mat-label>Email address</mat-label>
<input matInput formControlName="emailFormCtrl">
<mat-error>The input is invalid.</mat-error>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step>
<ng-template matStepLabel>Confirm your information</ng-template>
Everything seems correct.
<div>
<button mat-button>Done</button>
<button type="button" mat-button (click)="linearStepper.reset()">Reset</button>
</div>
</mat-step>
</mat-stepper>
</form>
<h3>Linear Horizontal Stepper Demo using a different form for each step</h3>
<mat-stepper #linearHorizontalStepper="matHorizontalStepper" [linear]="!isNonLinear"
[disableRipple]="disableRipple"
[labelPosition]="showLabelBottom ? 'bottom' : 'end'"
[color]="theme">
<mat-step [stepControl]="nameFormGroup">
<form [formGroup]="nameFormGroup">
<ng-template matStepLabel>Fill out your name</ng-template>
<mat-form-field>
<mat-label>First name</mat-label>
<input matInput formControlName="firstNameCtrl" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Last name</mat-label>
<input matInput formControlName="lastNameCtrl" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</form>
</mat-step>
<mat-step [stepControl]="emailFormGroup" optional>
<form [formGroup]="emailFormGroup">
<ng-template matStepLabel>Fill out your email address</ng-template>
<mat-form-field>
<mat-label>Email address</mat-label>
<input matInput formControlName="emailCtrl">
<mat-error>The input is invalid</mat-error>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</form>
</mat-step>
<mat-step>
<form>
<ng-template matStepLabel>Confirm your information</ng-template>
Everything seems correct.
<div>
<button mat-button>Done</button>
<button type="button" mat-button (click)="linearHorizontalStepper.reset()">Reset</button>
</div>
</form>
</mat-step>
</mat-stepper>
<h3>Vertical Stepper Demo</h3>
<mat-checkbox [(ngModel)]="isNonEditable">Make steps non-editable</mat-checkbox>
<mat-stepper orientation="vertical" [color]="theme">
<mat-step [editable]="!isNonEditable">
<ng-template matStepLabel>Fill out your name</ng-template>
<mat-form-field>
<mat-label>First name</mat-label>
<input matInput>
</mat-form-field>
<mat-form-field>
<mat-label>Last name</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step [editable]="!isNonEditable">
<ng-template matStepLabel>
<div>Fill out your phone number</div>
</ng-template>
<mat-form-field>
<mat-label>Phone number</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step [editable]="!isNonEditable">
<ng-template matStepLabel>
<div>Fill out your address</div>
</ng-template>
<mat-form-field>
<mat-label>Address</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step>
<ng-template matStepLabel>Confirm your information</ng-template>
Everything seems correct.
<div>
<button mat-button>Done</button>
</div>
</mat-step>
</mat-stepper>
<h3>Horizontal Stepper Demo with Text Label</h3>
<mat-stepper [color]="theme">
<mat-step label="Fill out your name">
<mat-form-field>
<mat-label>First name</mat-label>
<input matInput>
</mat-form-field>
<mat-form-field>
<mat-label>Last name</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step label="Fill out your phone number">
<mat-form-field>
<mat-label>Phone number</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step label="Fill out your address">
<mat-form-field>
<mat-label>Address</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step label="Confirm your information">
Everything seems correct.
<div>
<button mat-button>Done</button>
</div>
</mat-step>
</mat-stepper>
<h3>Horizontal Stepper Demo with Templated Label</h3> | {
"end_byte": 7218,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/stepper/stepper-demo.html"
} |
components/src/dev-app/stepper/stepper-demo.html_7219_8023 | <mat-stepper [color]="theme">
@for (step of steps; track step) {
<mat-step>
<ng-template matStepLabel>{{step.label}}</ng-template>
<mat-form-field>
<mat-label>Answer</mat-label>
<input matInput [(ngModel)]="step.content">
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
}
</mat-stepper>
<h3>Stepper with autosize textarea</h3>
<mat-stepper [color]="theme">
<mat-step label="Step 1">
<mat-form-field>
<mat-label>Autosize textarea</mat-label>
<textarea matInput cdkTextareaAutosize>This is an autosize textarea, it should adjust to the size of its content.</textarea>
</mat-form-field>
</mat-step>
</mat-stepper> | {
"end_byte": 8023,
"start_byte": 7219,
"url": "https://github.com/angular/components/blob/main/src/dev-app/stepper/stepper-demo.html"
} |
components/src/dev-app/stepper/BUILD.bazel_0_486 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "stepper",
srcs = glob(["**/*.ts"]),
assets = ["stepper-demo.html"],
deps = [
"//src/material/button",
"//src/material/checkbox",
"//src/material/core",
"//src/material/form-field",
"//src/material/input",
"//src/material/select",
"//src/material/stepper",
"@npm//@angular/forms",
],
)
| {
"end_byte": 486,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/stepper/BUILD.bazel"
} |
components/src/dev-app/stepper/stepper-demo.ts_0_2643 | /**
* @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 {
AbstractControl,
FormBuilder,
FormsModule,
ReactiveFormsModule,
Validators,
} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {ThemePalette} from '@angular/material/core';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatStepperModule} from '@angular/material/stepper';
@Component({
selector: 'stepper-demo',
templateUrl: 'stepper-demo.html',
imports: [
FormsModule,
MatButtonModule,
MatCheckboxModule,
MatFormFieldModule,
MatInputModule,
MatStepperModule,
MatSelectModule,
ReactiveFormsModule,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class StepperDemo {
private _formBuilder = inject(FormBuilder);
isNonLinear = false;
isNonEditable = false;
disableRipple = false;
showLabelBottom = false;
isVertical = false;
nameFormGroup = this._formBuilder.group({
firstNameCtrl: ['', Validators.required],
lastNameCtrl: ['', Validators.required],
});
emailFormGroup = this._formBuilder.group({
emailCtrl: ['', Validators.email],
});
formGroup = this._formBuilder.group({
formArray: this._formBuilder.array([
this._formBuilder.group({
firstNameFormCtrl: this._formBuilder.control('', [Validators.required]),
lastNameFormCtrl: this._formBuilder.control('', [Validators.required]),
}),
this._formBuilder.group({
emailFormCtrl: this._formBuilder.control('', [Validators.email]),
}),
]),
});
steps = [
{label: 'Confirm your name', content: 'Last name, First name.'},
{label: 'Confirm your contact information', content: '123-456-7890'},
{label: 'Confirm your address', content: '1600 Amphitheater Pkwy MTV'},
{label: 'You are now done', content: 'Finished!'},
];
availableThemes: {value: ThemePalette; name: string}[] = [
{value: 'primary', name: 'Primary'},
{value: 'accent', name: 'Accent'},
{value: 'warn', name: 'Warn'},
];
theme = this.availableThemes[0].value;
/** Returns a FormArray with the name 'formArray'. */
get formArray(): AbstractControl | null {
return this.formGroup.get('formArray');
}
}
| {
"end_byte": 2643,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/stepper/stepper-demo.ts"
} |
components/src/dev-app/cdk-listbox/cdk-listbox-demo.html_0_1529 | <div>
<h4>Basic Listbox</h4>
<cdk-listbox-overview-example></cdk-listbox-overview-example>
</div>
<div>
<h4>Multiselect Listbox</h4>
<cdk-listbox-multiple-example></cdk-listbox-multiple-example>
</div>
<div>
<h4>Listbox with Value Binding</h4>
<cdk-listbox-value-binding-example></cdk-listbox-value-binding-example>
</div>
<div>
<h4>Listbox with compareWith Function</h4>
<cdk-listbox-compare-with-example></cdk-listbox-compare-with-example>
</div>
<div>
<h4>Listbox with Template-driven Forms</h4>
<cdk-listbox-template-forms-example></cdk-listbox-template-forms-example>
</div>
<div>
<h4>Listbox with Reactive Forms</h4>
<cdk-listbox-reactive-forms-example></cdk-listbox-reactive-forms-example>
</div>
<div>
<h4>Listbox with Forms Validation</h4>
<cdk-listbox-forms-validation-example></cdk-listbox-forms-validation-example>
</div>
<div>
<h4>Listbox with Disabled Options</h4>
<cdk-listbox-disabled-example></cdk-listbox-disabled-example>
</div>
<div>
<h4>Listbox with aria-activedescendant</h4>
<cdk-listbox-activedescendant-example></cdk-listbox-activedescendant-example>
</div>
<div>
<h4>Horizontal Listbox</h4>
<cdk-listbox-horizontal-example></cdk-listbox-horizontal-example>
</div>
<div>
<h4>Listbox with Custom Typeahead</h4>
<cdk-listbox-custom-typeahead-example></cdk-listbox-custom-typeahead-example>
</div>
<div>
<h4>Listbox with Custom Keyboard Navigation Options</h4>
<cdk-listbox-custom-navigation-example></cdk-listbox-custom-navigation-example>
</div>
| {
"end_byte": 1529,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-listbox/cdk-listbox-demo.html"
} |
components/src/dev-app/cdk-listbox/cdk-listbox-demo.ts_0_1305 | /**
* @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 {
CdkListboxActivedescendantExample,
CdkListboxCompareWithExample,
CdkListboxCustomNavigationExample,
CdkListboxCustomTypeaheadExample,
CdkListboxDisabledExample,
CdkListboxFormsValidationExample,
CdkListboxHorizontalExample,
CdkListboxMultipleExample,
CdkListboxOverviewExample,
CdkListboxReactiveFormsExample,
CdkListboxTemplateFormsExample,
CdkListboxValueBindingExample,
} from '@angular/components-examples/cdk/listbox';
@Component({
templateUrl: 'cdk-listbox-demo.html',
imports: [
CdkListboxActivedescendantExample,
CdkListboxCompareWithExample,
CdkListboxCustomNavigationExample,
CdkListboxCustomTypeaheadExample,
CdkListboxDisabledExample,
CdkListboxFormsValidationExample,
CdkListboxHorizontalExample,
CdkListboxMultipleExample,
CdkListboxOverviewExample,
CdkListboxReactiveFormsExample,
CdkListboxTemplateFormsExample,
CdkListboxValueBindingExample,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CdkListboxDemo {}
| {
"end_byte": 1305,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-listbox/cdk-listbox-demo.ts"
} |
components/src/dev-app/cdk-listbox/BUILD.bazel_0_291 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "cdk-listbox",
srcs = glob(["**/*.ts"]),
assets = [
"cdk-listbox-demo.html",
],
deps = [
"//src/components-examples/cdk/listbox",
],
)
| {
"end_byte": 291,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/cdk-listbox/BUILD.bazel"
} |
components/src/dev-app/progress-spinner/progress-spinner-demo.ts_0_1186 | /**
* @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 {MatButtonToggleModule} from '@angular/material/button-toggle';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {ThemePalette} from '@angular/material/core';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
@Component({
selector: 'progress-spinner-demo',
templateUrl: 'progress-spinner-demo.html',
styleUrl: 'progress-spinner-demo.css',
imports: [
MatButtonModule,
MatCheckboxModule,
MatButtonToggleModule,
FormsModule,
MatProgressSpinnerModule,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ProgressSpinnerDemo {
progressValue = 60;
color: ThemePalette = 'primary';
isDeterminate = true;
step(val: number) {
this.progressValue = Math.max(0, Math.min(100, val + this.progressValue));
}
}
| {
"end_byte": 1186,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/progress-spinner/progress-spinner-demo.ts"
} |
components/src/dev-app/progress-spinner/BUILD.bazel_0_586 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "progress-spinner",
srcs = glob(["**/*.ts"]),
assets = [
"progress-spinner-demo.html",
":progress_spinner_demo_scss",
],
deps = [
"//src/material/button",
"//src/material/button-toggle",
"//src/material/checkbox",
"//src/material/progress-spinner",
"@npm//@angular/forms",
],
)
sass_binary(
name = "progress_spinner_demo_scss",
src = "progress-spinner-demo.scss",
)
| {
"end_byte": 586,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/progress-spinner/BUILD.bazel"
} |
components/src/dev-app/progress-spinner/progress-spinner-demo.html_0_1549 | <h1>Determinate</h1>
<div class="demo-progress-spinner-controls">
<p>Value: {{progressValue}}</p>
<button mat-raised-button (click)="step(10)">Increase</button>
<button mat-raised-button (click)="step(-10)">Decrease</button>
<mat-checkbox [(ngModel)]="isDeterminate">Is determinate</mat-checkbox>
</div>
<div class="demo-progress-spinner">
<mat-progress-spinner [mode]="isDeterminate ? 'determinate' : 'indeterminate'"
[value]="progressValue" color="warn" [strokeWidth]="1.6" [diameter]="16"></mat-progress-spinner>
<mat-progress-spinner [mode]="isDeterminate ? 'determinate' : 'indeterminate'"
[value]="progressValue" color="accent" [strokeWidth]="1" [diameter]="32"></mat-progress-spinner>
<mat-progress-spinner [mode]="isDeterminate ? 'determinate' : 'indeterminate'"
[value]="progressValue" color="primary" [diameter]="50"></mat-progress-spinner>
</div>
<h1>Indeterminate</h1>
<mat-button-toggle-group class="demo-progress-spinner-controls" [(ngModel)]="color">
<mat-button-toggle value="primary">Primary Color</mat-button-toggle>
<mat-button-toggle value="accent">Accent Color</mat-button-toggle>
<mat-button-toggle value="warn">Warn Color</mat-button-toggle>
</mat-button-toggle-group>
<div class="demo-progress-spinner">
<mat-progress-spinner mode="indeterminate" [color]="color"></mat-progress-spinner>
<mat-progress-spinner mode="indeterminate" [color]="color"></mat-progress-spinner>
<mat-spinner [color]="color"></mat-spinner>
</div>
| {
"end_byte": 1549,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/progress-spinner/progress-spinner-demo.html"
} |
components/src/dev-app/progress-spinner/progress-spinner-demo.scss_0_179 | .demo-progress-spinner {
width: 100%;
.mat-mdc-progress-spinner,
.mat-mdc-spinner {
display: inline-block;
}
}
.demo-progress-spinner-controls {
margin: 10px 0;
}
| {
"end_byte": 179,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/progress-spinner/progress-spinner-demo.scss"
} |
components/src/dev-app/youtube-player/youtube-player-demo.scss_0_93 | .demo-video-selection {
margin-bottom: 20px;
.mat-radio-button {
margin: 8px;
}
}
| {
"end_byte": 93,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/youtube-player/youtube-player-demo.scss"
} |
components/src/dev-app/youtube-player/youtube-player-demo.html_0_1581 | <div #demoYouTubePlayer class="demo-youtube-player">
<h2>Basic Example</h2>
<section>
<div class="demo-video-selection">
<label>Pick the video:</label>
<mat-radio-group aria-label="Select a video" [(ngModel)]="selectedVideo">
@for (video of videos; track video) {
<mat-radio-button [value]="video">{{video.name}}</mat-radio-button>
}
<mat-radio-button [value]="undefined">Unset</mat-radio-button>
</mat-radio-group>
</div>
<div class="demo-video-selection">
<mat-checkbox [(ngModel)]="disableCookies">Disable cookies</mat-checkbox>
<mat-checkbox [(ngModel)]="disablePlaceholder">Disable placeholder</mat-checkbox>
</div>
<youtube-player [videoId]="selectedVideoId"
[playerVars]="playerVars"
[width]="videoWidth"
[height]="videoHeight"
[disableCookies]="disableCookies"
[disablePlaceholder]="disablePlaceholder"
[placeholderImageQuality]="placeholderQuality"></youtube-player>
</section>
<h2>Placeholder quality comparison (high to low)</h2>
<youtube-player
[videoId]="selectedVideoId"
[width]="videoWidth"
[height]="videoHeight"
placeholderImageQuality="high"/>
<youtube-player
[videoId]="selectedVideoId"
[width]="videoWidth"
[height]="videoHeight"
placeholderImageQuality="standard"/>
<youtube-player
[videoId]="selectedVideoId"
[width]="videoWidth"
[height]="videoHeight"
placeholderImageQuality="low"/>
</div>
| {
"end_byte": 1581,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/youtube-player/youtube-player-demo.html"
} |
components/src/dev-app/youtube-player/youtube-player-demo.ts_0_3751 | /**
* @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 {
AfterViewInit,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
OnDestroy,
ViewChild,
inject,
} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatRadioModule} from '@angular/material/radio';
import {PlaceholderImageQuality, YouTubePlayer} from '@angular/youtube-player';
interface Video {
id: string;
name: string;
isPlaylist?: boolean;
autoplay?: boolean;
placeholderQuality: PlaceholderImageQuality;
}
const VIDEOS: Video[] = [
{
id: 'hsUxJjY-PRg',
name: 'Control Flow',
placeholderQuality: 'high',
},
{
id: 'O0xx5SvjmnU',
name: 'Angular Conf',
placeholderQuality: 'high',
},
{
id: 'invalidname',
name: 'Invalid',
placeholderQuality: 'high',
},
{
id: 'PLOa5YIicjJ-XCGXwnEmMmpHHCn11gUgvL',
name: 'Angular Forms Playlist',
isPlaylist: true,
placeholderQuality: 'high',
},
{
id: 'PLOa5YIicjJ-VpOOoLczAGTLEEznZ2JEa6',
name: 'Angular Router Playlist',
isPlaylist: true,
placeholderQuality: 'high',
},
{
id: 'PXNp4LENMPA',
name: 'Angular.dev (autoplay)',
autoplay: true,
placeholderQuality: 'high',
},
{
id: 'txqiwrbYGrs',
name: 'David after dentist (only standard quality placeholder)',
placeholderQuality: 'low',
},
{
id: 'EwTZ2xpQwpA',
name: 'Chocolate rain (only low quality placeholder)',
placeholderQuality: 'low',
},
];
@Component({
selector: 'youtube-player-demo',
templateUrl: 'youtube-player-demo.html',
styleUrl: 'youtube-player-demo.css',
imports: [FormsModule, MatRadioModule, MatCheckboxModule, YouTubePlayer],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class YouTubePlayerDemo implements AfterViewInit, OnDestroy {
@ViewChild('demoYouTubePlayer') demoYouTubePlayer: ElementRef<HTMLDivElement>;
private _selectedVideo?: Video;
private _playerVars?: YT.PlayerVars;
private _selectedVideoId?: string;
private _changeDetectorRef = inject(ChangeDetectorRef);
videos = VIDEOS;
videoWidth: number | undefined;
videoHeight: number | undefined;
disableCookies = false;
disablePlaceholder = false;
placeholderQuality: PlaceholderImageQuality;
constructor() {
this.selectedVideo = VIDEOS[0];
}
ngAfterViewInit(): void {
this.onResize();
window.addEventListener('resize', this.onResize);
}
onResize = (): void => {
// Automatically expand the video to fit the page up to 1200px x 720px
this.videoWidth = Math.min(this.demoYouTubePlayer.nativeElement.clientWidth, 1200);
this.videoHeight = this.videoWidth * 0.6;
this._changeDetectorRef.markForCheck();
};
ngOnDestroy(): void {
window.removeEventListener('resize', this.onResize);
}
get selectedVideoId() {
return this._selectedVideoId;
}
get playerVars() {
return this._playerVars;
}
get selectedVideo() {
return this._selectedVideo;
}
set selectedVideo(value: Video | undefined) {
this._selectedVideo = value;
this.placeholderQuality = value?.placeholderQuality || 'standard';
// If the video is a playlist, don't send a video id, and prepare playerVars instead
if (!value?.isPlaylist) {
this._playerVars = value?.autoplay ? {autoplay: 1} : undefined;
this._selectedVideoId = value?.id;
return;
}
this._playerVars = {
list: this._selectedVideo?.id,
listType: 'playlist',
};
this._selectedVideoId = undefined;
}
}
| {
"end_byte": 3751,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/youtube-player/youtube-player-demo.ts"
} |
components/src/dev-app/youtube-player/BUILD.bazel_0_524 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "youtube-player",
srcs = glob(["**/*.ts"]),
assets = [
"youtube-player-demo.html",
":youtube_player_demo_scss",
],
deps = [
"//src/material/checkbox",
"//src/material/radio",
"//src/youtube-player",
"@npm//@angular/forms",
],
)
sass_binary(
name = "youtube_player_demo_scss",
src = "youtube-player-demo.scss",
)
| {
"end_byte": 524,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/youtube-player/BUILD.bazel"
} |
components/src/dev-app/dialog/dialog-demo.scss_0_440 | @use '@angular/material' as mat;
.demo-dialog-card {
max-width: 600px;
margin: 20px 0;
mat-form-field + mat-form-field {
margin-left: 16px;
}
[dir='rtl'] mat-form-field + mat-form-field {
margin-left: 0;
margin-right: 16px;
}
}
.demo-dialog-button {
margin-right: 8px;
[dir='rtl'] & {
margin-left: 8px;
margin-right: 0;
}
}
.demo-dialog-legacy-padding {
@include mat.dialog-legacy-padding();
}
| {
"end_byte": 440,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/dialog/dialog-demo.scss"
} |
components/src/dev-app/dialog/dialog-demo.html_0_4570 | <h1>Dialog demo</h1>
<button mat-raised-button color="primary" (click)="openJazz()" class="demo-dialog-button">
Open dialog
</button>
<button mat-raised-button color="accent" (click)="openContentElement()" class="demo-dialog-button">
Open dialog with content elements
</button>
<button mat-raised-button color="accent" (click)="openTemplate()" class="demo-dialog-button">
Open dialog with template content
</button>
<p>
<mat-checkbox [(ngModel)]="enableLegacyPadding">Enable legacy padding</mat-checkbox>
</p>
<p>
<mat-checkbox [(ngModel)]="isScrollable">Make dialog scrollable</mat-checkbox>
</p>
<mat-card class="demo-dialog-card">
<mat-card-content>
<h2>Dialog dimensions</h2>
<p>
<mat-form-field>
<mat-label>Width</mat-label>
<input matInput [(ngModel)]="config.width" />
</mat-form-field>
<mat-form-field>
<mat-label>Height</mat-label>
<input matInput [(ngModel)]="config.height" />
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Min width</mat-label>
<input matInput [(ngModel)]="config.minWidth" />
</mat-form-field>
<mat-form-field>
<mat-label>Min height</mat-label>
<input matInput [(ngModel)]="config.minHeight" />
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Max width</mat-label>
<input matInput [(ngModel)]="config.maxWidth" />
</mat-form-field>
<mat-form-field>
<mat-label>Max height</mat-label>
<input matInput [(ngModel)]="config.maxHeight" />
</mat-form-field>
</p>
<h2>Dialog position</h2>
<p>
<mat-form-field>
<mat-label>Top</mat-label>
<input matInput [(ngModel)]="config.position.top" (change)="config.position.bottom = ''" />
</mat-form-field>
<mat-form-field>
<mat-label>Bottom</mat-label>
<input matInput [(ngModel)]="config.position.bottom" (change)="config.position.top = ''" />
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Left</mat-label>
<input matInput [(ngModel)]="config.position.left" (change)="config.position.right = ''" />
</mat-form-field>
<mat-form-field>
<mat-label>Right</mat-label>
<input matInput [(ngModel)]="config.position.right" (change)="config.position.left = ''" />
</mat-form-field>
</p>
<h2>Dialog backdrop</h2>
<p>
<mat-form-field>
<mat-label>Backdrop class</mat-label>
<input matInput [(ngModel)]="config.backdropClass" />
</mat-form-field>
</p>
<mat-checkbox [(ngModel)]="config.hasBackdrop">Has backdrop</mat-checkbox>
<h2>Other options</h2>
<p>
<mat-form-field>
<mat-label>Button alignment</mat-label>
<mat-select [(ngModel)]="actionsAlignment">
<mat-option value="start">Start</mat-option>
<mat-option value="end">End</mat-option>
<mat-option value="center">Center</mat-option>
</mat-select>
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Dialog message</mat-label>
<input matInput [(ngModel)]="config.data.message" />
</mat-form-field>
</p>
<p>
<mat-checkbox [(ngModel)]="config.disableClose">Disable close</mat-checkbox>
</p>
</mat-card-content>
</mat-card>
<p>Last afterClosed result: {{lastAfterClosedResult | json}}</p>
<p>Last beforeClose result: {{lastBeforeCloseResult | json}}</p>
<ng-template let-data let-dialogRef="dialogRef">
<p>Order printer ink refills.</p>
<mat-form-field>
<mat-label>How many?</mat-label>
<input matInput #howMuch />
</mat-form-field>
<mat-form-field>
<mat-label>What color?</mat-label>
<mat-select #whatColor>
<mat-option></mat-option>
<mat-option value="black">Black</mat-option>
<mat-option value="cyan">Cyan</mat-option>
<mat-option value="magenta">Magenta</mat-option>
<mat-option value="yellow">Yellow</mat-option>
</mat-select>
</mat-form-field>
<p>{{ data.message }}</p>
<p>I'm a template dialog. I've been opened {{numTemplateOpens}} times!</p>
<button
type="button"
class="demo-dialog-button"
cdkFocusInitial
(click)="dialogRef.close({ quantity: howMuch.value, color: whatColor.value })"
>
Close dialog
</button>
<button
(click)="dialogRef.updateSize('500px', '500px').updatePosition({top: '25px', left: '25px'});"
class="demo-dialog-button"
>
Change dimensions
</button>
</ng-template>
| {
"end_byte": 4570,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/dialog/dialog-demo.html"
} |
components/src/dev-app/dialog/BUILD.bazel_0_671 | load("//tools:defaults.bzl", "ng_module", "sass_binary")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "dialog",
srcs = glob(["**/*.ts"]),
assets = [
"dialog-demo.html",
":dialog_demo_scss",
],
deps = [
"//src/cdk/drag-drop",
"//src/material/button",
"//src/material/card",
"//src/material/checkbox",
"//src/material/dialog",
"//src/material/form-field",
"//src/material/input",
"//src/material/select",
],
)
sass_binary(
name = "dialog_demo_scss",
src = "dialog-demo.scss",
deps = ["//src/material-experimental:sass_lib"],
)
| {
"end_byte": 671,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/dialog/BUILD.bazel"
} |
components/src/dev-app/dialog/dialog-demo.ts_0_8417 | /**
* @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 {DragDropModule} from '@angular/cdk/drag-drop';
import {DOCUMENT, JsonPipe} from '@angular/common';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
TemplateRef,
ViewChild,
ViewEncapsulation,
inject,
} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatCardModule} from '@angular/material/card';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {
MAT_DIALOG_DATA,
MatDialog,
MatDialogActions,
MatDialogClose,
MatDialogConfig,
MatDialogContent,
MatDialogRef,
MatDialogTitle,
} from '@angular/material/dialog';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
@Component({
selector: 'dialog-demo',
templateUrl: 'dialog-demo.html',
styleUrl: 'dialog-demo.css',
// View encapsulation is disabled since we add the legacy dialog padding
// styles that need to target the dialog (not only the projected content).
encapsulation: ViewEncapsulation.None,
imports: [
JsonPipe,
FormsModule,
MatButtonModule,
MatCardModule,
MatCheckboxModule,
MatFormFieldModule,
MatInputModule,
MatSelectModule,
JsonPipe,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DialogDemo {
dialog = inject(MatDialog);
dialogRef: MatDialogRef<JazzDialog> | null;
lastAfterClosedResult: string;
lastBeforeCloseResult: string;
actionsAlignment: 'start' | 'center' | 'end';
config = {
disableClose: false,
panelClass: 'custom-overlay-pane-class',
hasBackdrop: true,
backdropClass: '',
width: '',
height: '',
minWidth: '',
minHeight: '',
maxWidth: '',
maxHeight: '',
position: {
top: '',
bottom: '',
left: '',
right: '',
},
data: {
message: 'Jazzy jazz jazz',
},
};
numTemplateOpens = 0;
enableLegacyPadding = false;
isScrollable = false;
@ViewChild(TemplateRef) template: TemplateRef<any>;
readonly cdr = inject(ChangeDetectorRef);
constructor() {
const dialog = this.dialog;
const doc = inject(DOCUMENT);
// Possible useful example for the open and closeAll events.
// Adding a class to the body if a dialog opens and
// removing it after all open dialogs are closed
dialog.afterOpened.subscribe(() => {
if (!doc.body.classList.contains('no-scroll')) {
doc.body.classList.add('no-scroll');
}
});
dialog.afterAllClosed.subscribe(() => {
doc.body.classList.remove('no-scroll');
});
}
openJazz() {
this.dialogRef = this.dialog.open(JazzDialog, this._getDialogConfig());
this.dialogRef.beforeClosed().subscribe((result: string) => {
this.lastBeforeCloseResult = result;
this.cdr.markForCheck();
});
this.dialogRef.afterClosed().subscribe((result: string) => {
this.lastAfterClosedResult = result;
this.dialogRef = null;
this.cdr.markForCheck();
});
}
openContentElement() {
const dialogRef = this.dialog.open(ContentElementDialog, this._getDialogConfig());
dialogRef.componentInstance.actionsAlignment = this.actionsAlignment;
dialogRef.componentInstance.isScrollable = this.isScrollable;
}
openTemplate() {
this.numTemplateOpens++;
this.dialog.open(this.template, this._getDialogConfig());
}
private _getDialogConfig(): MatDialogConfig {
const config = {...this.config};
if (this.enableLegacyPadding) {
config.panelClass = `demo-dialog-legacy-padding`;
}
return config;
}
}
@Component({
selector: 'demo-jazz-dialog',
template: `
<div cdkDrag cdkDragRootElement=".cdk-overlay-pane">
<p>Order printer ink refills.</p>
<mat-form-field>
<mat-label>How many?</mat-label>
<input matInput #howMuch>
</mat-form-field>
<mat-form-field>
<mat-label>What color?</mat-label>
<mat-select #whatColor>
<mat-option></mat-option>
<mat-option value="black">Black</mat-option>
<mat-option value="cyan">Cyan</mat-option>
<mat-option value="magenta">Magenta</mat-option>
<mat-option value="yellow">Yellow</mat-option>
</mat-select>
</mat-form-field>
<p cdkDragHandle> {{ data.message }} </p>
<button type="button" class="demo-dialog-button"
(click)="dialogRef.close({ quantity: howMuch.value, color: whatColor.value })">
Close dialog
</button>
<button (click)="togglePosition()">Change dimensions</button>
<button (click)="temporarilyHide()">Hide for 2 seconds</button>
</div>
`,
encapsulation: ViewEncapsulation.None,
styles: `.hidden-dialog { opacity: 0; }`,
imports: [DragDropModule, MatInputModule, MatSelectModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class JazzDialog {
dialogRef = inject<MatDialogRef<JazzDialog>>(MatDialogRef<JazzDialog>);
data = inject(MAT_DIALOG_DATA);
private _dimensionToggle = false;
togglePosition(): void {
this._dimensionToggle = !this._dimensionToggle;
if (this._dimensionToggle) {
this.dialogRef.updateSize('500px', '500px').updatePosition({top: '25px', left: '25px'});
} else {
this.dialogRef.updateSize().updatePosition();
}
}
temporarilyHide(): void {
this.dialogRef.addPanelClass('hidden-dialog');
setTimeout(() => {
this.dialogRef.removePanelClass('hidden-dialog');
}, 2000);
}
}
@Component({
selector: 'demo-content-element-dialog',
styles: `
img {
max-width: 100%;
max-height: 800px;
}
`,
template: `
<h2 mat-dialog-title>Neptune</h2>
<mat-dialog-content>
<p>
Neptune is the eighth and farthest known planet from the Sun in the Solar System. In the
Solar System, it is the fourth-largest planet by diameter, the third-most-massive planet,
and the densest giant planet. Neptune is 17 times the mass of Earth and is slightly more
massive than its near-twin Uranus, which is 15 times the mass of Earth and slightly larger
than Neptune. Neptune orbits the Sun once every 164.8 years at an average distance of 30.1
astronomical units (4.50x109 km). It is named after the Roman god of the sea and has the
astronomical symbol ♆, a stylised version of the god Neptune's trident.
</p>
@if (isScrollable) {
@for (i of [1, 2, 3]; track $index) {
<img src="https://upload.wikimedia.org/wikipedia/commons/5/56/Neptune_Full.jpg"/>
}
}
</mat-dialog-content>
<mat-dialog-actions [align]="actionsAlignment">
<button
mat-button
color="primary"
mat-dialog-close>Close</button>
<a
mat-button
color="primary"
href="https://en.wikipedia.org/wiki/Neptune"
target="_blank">Read more on Wikipedia</a>
<button
mat-button
color="accent"
(click)="showInStackedDialog()">
Show in Dialog</button>
</mat-dialog-actions>
`,
imports: [MatButtonModule, MatDialogTitle, MatDialogContent, MatDialogClose, MatDialogActions],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ContentElementDialog {
dialog = inject(MatDialog);
actionsAlignment?: 'start' | 'center' | 'end';
isScrollable: boolean;
showInStackedDialog() {
this.dialog.open(IFrameDialog, {maxWidth: '80vw'});
}
}
@Component({
selector: 'demo-iframe-dialog',
styles: `
iframe {
width: 800px;
height: 500px;
}
`,
template: `
<h2 mat-dialog-title>Neptune</h2>
<mat-dialog-content>
<iframe style="border: 0" src="https://en.wikipedia.org/wiki/Neptune"></iframe>
</mat-dialog-content>
<mat-dialog-actions>
<button
mat-button
color="primary"
mat-dialog-close>Close</button>
</mat-dialog-actions>
`,
imports: [MatButtonModule, MatDialogTitle, MatDialogContent, MatDialogClose, MatDialogActions],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IFrameDialog {}
| {
"end_byte": 8417,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/dialog/dialog-demo.ts"
} |
components/src/dev-app/expansion/expansion-demo.html_0_4864 | <h1>Single Expansion Panel</h1>
<mat-expansion-panel class="demo-expansion-width" #myPanel
(afterExpand)="addEvent('afterExpand')"
(afterCollapse)="addEvent('afterCollapse')">
<mat-expansion-panel-header [expandedHeight]="expandedHeight" [collapsedHeight]="collapsedHeight">
<mat-panel-description>This is a panel description.</mat-panel-description>
<mat-panel-title>Panel Title</mat-panel-title>
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
This is the content text that makes sense here.
<mat-checkbox>Trigger a ripple</mat-checkbox>
</ng-template>
<mat-action-row>
<button mat-button (click)="myPanel.expanded = false">CANCEL</button>
<button mat-button>SAVE</button>
</mat-action-row>
</mat-expansion-panel>
<br>
<mat-form-field>
<mat-label>Collapsed height</mat-label>
<input matInput [(ngModel)]="collapsedHeight">
</mat-form-field>
<mat-form-field>
<mat-label>Expanded height</mat-label>
<input matInput [(ngModel)]="expandedHeight">
</mat-form-field>
<br>
<p>Expansion Panel Animation Events</p>
<code class="demo-expansion-code">
@for (event of events; track event) {
<pre>{{event}}</pre>
}
</code>
<h1>matAccordion</h1>
<div>
<p>Accordion Options</p>
<div>
<mat-slide-toggle [(ngModel)]="multi">Allow Multi Expansion</mat-slide-toggle>
<mat-slide-toggle [(ngModel)]="hideToggle">Hide Indicators</mat-slide-toggle>
<mat-slide-toggle [(ngModel)]="disabled">Disable Panel 2</mat-slide-toggle>
<mat-slide-toggle [(ngModel)]="showPanel3">Show Panel 3</mat-slide-toggle>
</div>
<p>Accordion Style</p>
<mat-radio-group [(ngModel)]="displayMode">
<mat-radio-button value="default">Default</mat-radio-button>
<mat-radio-button value="flat">Flat</mat-radio-button>
</mat-radio-group>
<p>Toggle Position</p>
<mat-radio-group [(ngModel)]="togglePosition">
<mat-radio-button value="before">Before</mat-radio-button>
<mat-radio-button value="after">After</mat-radio-button>
</mat-radio-group>
<p>Accordion Actions <sup>('Multi Expansion' mode only)</sup></p>
<div>
<button mat-button (click)="accordion.openAll()" [disabled]="!multi">Expand All</button>
<button mat-button (click)="accordion.closeAll()" [disabled]="!multi">Collapse All</button>
</div>
<p>Accordion Panel(s)</p>
<div>
<mat-checkbox [(ngModel)]="panel1.expanded">Panel 1</mat-checkbox>
<mat-checkbox [(ngModel)]="panel2.expanded">Panel 2</mat-checkbox>
</div>
</div>
<br>
<mat-accordion [displayMode]="displayMode" [multi]="multi" [hideToggle]="hideToggle"
[togglePosition]="togglePosition" class="demo-expansion-width">
<mat-expansion-panel #panel1>
<mat-expansion-panel-header>Section 1</mat-expansion-panel-header>
<p>This is the content text that makes sense here.</p>
</mat-expansion-panel>
<mat-expansion-panel #panel2 [disabled]="disabled">
<mat-expansion-panel-header>Section 2</mat-expansion-panel-header>
<p>This is the content text that makes sense here.</p>
</mat-expansion-panel>
@if (showPanel3) {
<mat-expansion-panel #panel3>
<mat-expansion-panel-header>Section 3</mat-expansion-panel-header>
<mat-checkbox #showButtons>Reveal Buttons Below</mat-checkbox>
@if (showButtons.checked) {
<mat-action-row>
<button mat-button (click)="panel2.expanded = true">OPEN SECTION 2</button>
<button mat-button (click)="panel3.expanded = false">CLOSE</button>
</mat-action-row>
}
</mat-expansion-panel>
}
</mat-accordion>
<h1>cdkAccordion</h1>
<div>
<p>Accordion Options</p>
<div>
<mat-slide-toggle [(ngModel)]="accordion1.multi">Allow Multi Expansion</mat-slide-toggle>
</div>
</div>
<cdk-accordion class="demo-expansion-width" #accordion1="cdkAccordion">
<cdk-accordion-item #item1="cdkAccordionItem">
<p>
Item 1:
<button mat-button (click)="item1.expanded = true">Expand</button>
<button mat-button (click)="item1.expanded = false">Collapse</button>
</p>
@if (item1.expanded) {
<p>I only show if item 1 is expanded</p>
}
</cdk-accordion-item>
<cdk-accordion-item #item2="cdkAccordionItem">
<p>
Item 2:
<button mat-button (click)="item2.expanded = true">Expand</button>
<button mat-button (click)="item2.expanded = false">Collapse</button>
</p>
@if (item2.expanded) {
<p>I only show if item 2 is expanded</p>
}
</cdk-accordion-item>
<cdk-accordion-item #item3="cdkAccordionItem">
<p>
Item 3:
<button mat-button (click)="item3.expanded = true">Expand</button>
<button mat-button (click)="item3.expanded = false">Collapse</button>
</p>
@if (item3.expanded) {
<p>I only show if item 3 is expanded</p>
}
</cdk-accordion-item>
</cdk-accordion>
| {
"end_byte": 4864,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/dev-app/expansion/expansion-demo.html"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.