_id
stringlengths 21
254
| text
stringlengths 1
93.7k
| metadata
dict |
---|---|---|
components/src/components-examples/material/list/list-single-selection-reactive-form/list-single-selection-reactive-form-example.ts_0_936 | import {Component} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatListModule} from '@angular/material/list';
interface Shoes {
value: string;
name: string;
}
/**
* @title List with single selection using Reactive forms
*/
@Component({
selector: 'list-single-selection-reactive-form-example',
templateUrl: 'list-single-selection-form-example.html',
imports: [MatListModule, FormsModule, ReactiveFormsModule],
})
export class ListSingleSelectionReactiveFormExample {
form: FormGroup;
shoes: Shoes[] = [
{value: 'boots', name: 'Boots'},
{value: 'clogs', name: 'Clogs'},
{value: 'loafers', name: 'Loafers'},
{value: 'moccasins', name: 'Moccasins'},
{value: 'sneakers', name: 'Sneakers'},
];
shoesControl = new FormControl();
constructor() {
this.form = new FormGroup({
clothes: this.shoesControl,
});
}
}
| {
"end_byte": 936,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-single-selection-reactive-form/list-single-selection-reactive-form-example.ts"
} |
components/src/components-examples/material/list/list-sections/list-sections-example.css_0_58 | .mat-mdc-list-item-icon {
color: rgba(0, 0, 0, 0.54);
}
| {
"end_byte": 58,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-sections/list-sections-example.css"
} |
components/src/components-examples/material/list/list-sections/list-sections-example.ts_0_1031 | import {Component} from '@angular/core';
import {MatDividerModule} from '@angular/material/divider';
import {MatIconModule} from '@angular/material/icon';
import {DatePipe} from '@angular/common';
import {MatListModule} from '@angular/material/list';
export interface Section {
name: string;
updated: Date;
}
/**
* @title List with sections
*/
@Component({
selector: 'list-sections-example',
styleUrl: 'list-sections-example.css',
templateUrl: 'list-sections-example.html',
imports: [MatListModule, MatIconModule, MatDividerModule, DatePipe],
})
export class ListSectionsExample {
folders: Section[] = [
{
name: 'Photos',
updated: new Date('1/1/16'),
},
{
name: 'Recipes',
updated: new Date('1/17/16'),
},
{
name: 'Work',
updated: new Date('1/28/16'),
},
];
notes: Section[] = [
{
name: 'Vacation Itinerary',
updated: new Date('2/20/16'),
},
{
name: 'Kitchen Remodel',
updated: new Date('1/18/16'),
},
];
}
| {
"end_byte": 1031,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-sections/list-sections-example.ts"
} |
components/src/components-examples/material/list/list-sections/list-sections-example.html_0_603 | <mat-list>
<div mat-subheader>Folders</div>
@for (folder of folders; track folder) {
<mat-list-item>
<mat-icon matListItemIcon>folder</mat-icon>
<div matListItemTitle>{{folder.name}}</div>
<div matListItemLine>{{folder.updated | date}}</div>
</mat-list-item>
}
<mat-divider></mat-divider>
<div mat-subheader>Notes</div>
@for (note of notes; track note) {
<mat-list-item>
<mat-icon matListItemIcon>note</mat-icon>
<div matListItemTitle>{{note.name}}</div>
<div matListItemLine>{{note.updated | date}}</div>
</mat-list-item>
}
</mat-list>
| {
"end_byte": 603,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-sections/list-sections-example.html"
} |
components/src/components-examples/material/list/list-variants/list-variants-example.css_0_47 | .example-list-wrapping {
max-width: 500px;
}
| {
"end_byte": 47,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-variants/list-variants-example.css"
} |
components/src/components-examples/material/list/list-variants/list-variants-example.ts_0_333 | import {Component} from '@angular/core';
import {MatListModule} from '@angular/material/list';
/**
* @title List variants
*/
@Component({
selector: 'list-variants-example',
templateUrl: 'list-variants-example.html',
styleUrl: './list-variants-example.css',
imports: [MatListModule],
})
export class ListVariantsExample {}
| {
"end_byte": 333,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-variants/list-variants-example.ts"
} |
components/src/components-examples/material/list/list-variants/list-variants-example.html_0_2042 | <h3>Single line lists</h3>
<mat-list>
<mat-list-item>
<span matListItemTitle>This is the title</span>
</mat-list-item>
<mat-list-item>Also the title</mat-list-item>
</mat-list>
<h3>Two line lists</h3>
<mat-list>
<mat-list-item>
<span matListItemTitle>Title</span>
<span matListItemLine>Second line</span>
</mat-list-item>
<mat-list-item>
<span matListItemTitle>Title</span>
<span>Second line</span>
</mat-list-item>
<mat-list-item>
<span matListItemTitle>Title</span>
Second line
</mat-list-item>
</mat-list>
<h3>Three line lists</h3>
<mat-list>
<mat-list-item>
<span matListItemTitle>Title</span>
<span matListItemLine>Second line</span>
<span matListItemLine>Third line</span>
</mat-list-item>
<mat-list-item>
<span matListItemTitle>Title</span>
<span matListItemLine>Second line. This line will truncate.</span>
<span>Third line</span>
</mat-list-item>
<mat-list-item>
<span matListItemTitle>Title</span>
<span matListItemLine>Second line. This line will truncate.</span>
Third line
</mat-list-item>
</mat-list>
<h3>Three line list with secondary text wrapping</h3>
<mat-list class="example-list-wrapping">
<mat-list-item lines="3">
<span matListItemTitle>Title</span>
<span>
Secondary line that will wrap because the list lines is explicitly set to 3 lines. Text
inside of a `matListItemTitle` or `matListItemLine` will never wrap.
</span>
</mat-list-item>
<mat-list-item lines="3">
<span matListItemTitle>Title</span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est
</mat-list-item>
</mat-list>
| {
"end_byte": 2042,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-variants/list-variants-example.html"
} |
components/src/components-examples/material/list/list-selection/list-selection-example.html_0_218 | <mat-selection-list #shoes>
@for (shoe of typesOfShoes; track shoe) {
<mat-list-option>{{shoe}}</mat-list-option>
}
</mat-selection-list>
<p>
Options selected: {{shoes.selectedOptions.selected.length}}
</p>
| {
"end_byte": 218,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-selection/list-selection-example.html"
} |
components/src/components-examples/material/list/list-selection/list-selection-example.ts_0_383 | import {Component} from '@angular/core';
import {MatListModule} from '@angular/material/list';
/**
* @title List with selection
*/
@Component({
selector: 'list-selection-example',
templateUrl: 'list-selection-example.html',
imports: [MatListModule],
})
export class ListSelectionExample {
typesOfShoes: string[] = ['Boots', 'Clogs', 'Loafers', 'Moccasins', 'Sneakers'];
}
| {
"end_byte": 383,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-selection/list-selection-example.ts"
} |
components/src/components-examples/material/list/list-harness/list-harness-example.spec.ts_0_2212 | import {HarnessLoader, parallel} from '@angular/cdk/testing';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatListHarness} from '@angular/material/list/testing';
import {ListHarnessExample} from './list-harness-example';
describe('ListHarnessExample', () => {
let fixture: ComponentFixture<ListHarnessExample>;
let loader: HarnessLoader;
beforeEach(() => {
fixture = TestBed.createComponent(ListHarnessExample);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
});
it('should get all items', async () => {
const list = await loader.getHarness(MatListHarness);
const items = await list.getItems();
expect(await parallel(() => items.map(i => i.getFullText()))).toEqual([
'Item 1',
'Item 2',
'Item 3',
]);
});
it('should get all items matching text', async () => {
const list = await loader.getHarness(MatListHarness);
const items = await list.getItems({text: /[13]/});
expect(await parallel(() => items.map(i => i.getFullText()))).toEqual(['Item 1', 'Item 3']);
});
it('should get items by subheader', async () => {
const list = await loader.getHarness(MatListHarness);
const sections = await list.getItemsGroupedBySubheader();
expect(sections.length).toBe(3);
expect(sections[0].heading).toBeUndefined();
expect(await parallel(() => sections[0].items.map(i => i.getFullText()))).toEqual(['Item 1']);
expect(sections[1].heading).toBe('Section 1');
expect(await parallel(() => sections[1].items.map(i => i.getFullText()))).toEqual([
'Item 2',
'Item 3',
]);
expect(sections[2].heading).toBe('Section 2');
expect(sections[2].items.length).toEqual(0);
});
it('should get the different sections of an item', async () => {
const list = await loader.getHarness(MatListHarness);
const firstItem = (await list.getItems())[0];
expect(await firstItem.getTitle()).toBe('Item');
expect(await firstItem.getSecondaryText()).toBe('1');
expect(await firstItem.hasAvatar()).toBe(true);
expect(await firstItem.hasIcon()).toBe(true);
});
});
| {
"end_byte": 2212,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-harness/list-harness-example.spec.ts"
} |
components/src/components-examples/material/list/list-harness/list-harness-example.ts_0_301 | import {Component} from '@angular/core';
import {MatListModule} from '@angular/material/list';
/**
* @title Testing with MatListHarness
*/
@Component({
selector: 'list-harness-example',
templateUrl: 'list-harness-example.html',
imports: [MatListModule],
})
export class ListHarnessExample {}
| {
"end_byte": 301,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-harness/list-harness-example.ts"
} |
components/src/components-examples/material/list/list-harness/list-harness-example.html_0_370 | <mat-list>
<mat-list-item>
<div matListItemTitle>Item </div>
<div matListItemLine>1</div>
<div matListItemIcon>icon</div>
<div matListItemAvatar>Avatar</div>
</mat-list-item>
<div matSubheader>Section 1</div>
<a mat-list-item>
<span>Item 2</span>
</a>
<button mat-list-item>Item 3</button>
<div matSubheader>Section 2</div>
</mat-list>
| {
"end_byte": 370,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-harness/list-harness-example.html"
} |
components/src/components-examples/material/list/list-overview/list-overview-example.html_0_203 | <mat-list role="list">
<mat-list-item role="listitem">Item 1</mat-list-item>
<mat-list-item role="listitem">Item 2</mat-list-item>
<mat-list-item role="listitem">Item 3</mat-list-item>
</mat-list>
| {
"end_byte": 203,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-overview/list-overview-example.html"
} |
components/src/components-examples/material/list/list-overview/list-overview-example.ts_0_287 | import {Component} from '@angular/core';
import {MatListModule} from '@angular/material/list';
/**
* @title Basic list
*/
@Component({
selector: 'list-overview-example',
templateUrl: 'list-overview-example.html',
imports: [MatListModule],
})
export class ListOverviewExample {}
| {
"end_byte": 287,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-overview/list-overview-example.ts"
} |
components/src/components-examples/material/list/list-single-selection/list-single-selection-example.ts_0_904 | import {Component} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatListModule} from '@angular/material/list';
interface Shoes {
value: string;
name: string;
}
/**
* @title List with single selection using Reactive Forms
*/
@Component({
selector: 'list-single-selection-example',
templateUrl: 'list-single-selection-example.html',
imports: [MatListModule, FormsModule, ReactiveFormsModule],
})
export class ListSingleSelectionExample {
form: FormGroup;
shoes: Shoes[] = [
{value: 'boots', name: 'Boots'},
{value: 'clogs', name: 'Clogs'},
{value: 'loafers', name: 'Loafers'},
{value: 'moccasins', name: 'Moccasins'},
{value: 'sneakers', name: 'Sneakers'},
];
shoesControl = new FormControl();
constructor() {
this.form = new FormGroup({
clothes: this.shoesControl,
});
}
}
| {
"end_byte": 904,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-single-selection/list-single-selection-example.ts"
} |
components/src/components-examples/material/list/list-single-selection/list-single-selection-example.html_0_365 | <form [formGroup]="form">
<mat-selection-list #shoesList [formControl]="shoesControl" name="shoes" [multiple]="false">
@for (shoe of shoes; track shoe) {
<mat-list-option [value]="shoe.value">{{shoe.name}}</mat-list-option>
}
</mat-selection-list>
<p>
Option selected: {{shoesControl.value ? shoesControl.value[0] : 'None'}}
</p>
</form> | {
"end_byte": 365,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-single-selection/list-single-selection-example.html"
} |
components/src/components-examples/material/divider/BUILD.bazel_0_1063 | load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "divider",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
assets = glob([
"**/*.html",
"**/*.css",
]),
deps = [
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/divider",
"//src/material/divider/testing",
"//src/material/list",
"@npm//@angular/platform-browser",
"@npm//@types/jasmine",
],
)
filegroup(
name = "source-files",
srcs = glob([
"**/*.html",
"**/*.css",
"**/*.ts",
]),
)
ng_test_library(
name = "unit_tests_lib",
srcs = glob(["**/*.spec.ts"]),
deps = [
":divider",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/divider",
"//src/material/divider/testing",
],
)
ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
| {
"end_byte": 1063,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/divider/BUILD.bazel"
} |
components/src/components-examples/material/divider/index.ts_0_165 | export {DividerOverviewExample} from './divider-overview/divider-overview-example';
export {DividerHarnessExample} from './divider-harness/divider-harness-example';
| {
"end_byte": 165,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/divider/index.ts"
} |
components/src/components-examples/material/divider/divider-harness/divider-harness-example.html_0_71 | <mat-divider></mat-divider>
<mat-divider inset vertical></mat-divider>
| {
"end_byte": 71,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/divider/divider-harness/divider-harness-example.html"
} |
components/src/components-examples/material/divider/divider-harness/divider-harness-example.ts_0_398 | import {ChangeDetectionStrategy, Component} from '@angular/core';
import {MatDividerModule} from '@angular/material/divider';
/**
* @title Testing with MatDividerHarness
*/
@Component({
selector: 'divider-harness-example',
templateUrl: 'divider-harness-example.html',
imports: [MatDividerModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DividerHarnessExample {}
| {
"end_byte": 398,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/divider/divider-harness/divider-harness-example.ts"
} |
components/src/components-examples/material/divider/divider-harness/divider-harness-example.spec.ts_0_1299 | import {ComponentFixture, TestBed} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatDividerHarness} from '@angular/material/divider/testing';
import {HarnessLoader} from '@angular/cdk/testing';
import {DividerHarnessExample} from './divider-harness-example';
describe('DividerHarnessExample', () => {
let fixture: ComponentFixture<DividerHarnessExample>;
let loader: HarnessLoader;
beforeEach(() => {
fixture = TestBed.createComponent(DividerHarnessExample);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
});
it('should load all divider harnesses', async () => {
const dividers = await loader.getAllHarnesses(MatDividerHarness);
expect(dividers.length).toBe(2);
});
it('should check if divider is inset', async () => {
const dividers = await loader.getAllHarnesses(MatDividerHarness);
expect(await dividers[0].isInset()).toBe(false);
expect(await dividers[1].isInset()).toBe(true);
});
it('should get divider orientation', async () => {
const dividers = await loader.getAllHarnesses(MatDividerHarness);
expect(await dividers[0].getOrientation()).toBe('horizontal');
expect(await dividers[1].getOrientation()).toBe('vertical');
});
});
| {
"end_byte": 1299,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/divider/divider-harness/divider-harness-example.spec.ts"
} |
components/src/components-examples/material/divider/divider-overview/divider-overview-example.html_0_203 | <mat-list>
<mat-list-item>Item 1</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item>Item 2</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item>Item 3</mat-list-item>
</mat-list>
| {
"end_byte": 203,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/divider/divider-overview/divider-overview-example.html"
} |
components/src/components-examples/material/divider/divider-overview/divider-overview-example.ts_0_453 | import {ChangeDetectionStrategy, Component} from '@angular/core';
import {MatDividerModule} from '@angular/material/divider';
import {MatListModule} from '@angular/material/list';
/**
* @title Basic divider
*/
@Component({
selector: 'divider-overview-example',
templateUrl: 'divider-overview-example.html',
imports: [MatListModule, MatDividerModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DividerOverviewExample {}
| {
"end_byte": 453,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/divider/divider-overview/divider-overview-example.ts"
} |
components/src/components-examples/material/menu/BUILD.bazel_0_1150 | load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "menu",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
assets = glob([
"**/*.html",
"**/*.css",
]),
deps = [
"//src/cdk/overlay",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/button",
"//src/material/icon",
"//src/material/menu",
"//src/material/menu/testing",
"@npm//@angular/platform-browser",
"@npm//@types/jasmine",
],
)
filegroup(
name = "source-files",
srcs = glob([
"**/*.html",
"**/*.css",
"**/*.ts",
]),
)
ng_test_library(
name = "unit_tests_lib",
srcs = glob(["**/*.spec.ts"]),
deps = [
":menu",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/menu",
"//src/material/menu/testing",
"@npm//@angular/platform-browser",
],
)
ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
| {
"end_byte": 1150,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/BUILD.bazel"
} |
components/src/components-examples/material/menu/index.ts_0_357 | export {MenuIconsExample} from './menu-icons/menu-icons-example';
export {MenuOverviewExample} from './menu-overview/menu-overview-example';
export {MenuPositionExample} from './menu-position/menu-position-example';
export {MenuNestedExample} from './menu-nested/menu-nested-example';
export {MenuHarnessExample} from './menu-harness/menu-harness-example';
| {
"end_byte": 357,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/index.ts"
} |
components/src/components-examples/material/menu/menu-harness/menu-harness-example.html_0_276 | <button type="button" [matMenuTriggerFor]="settingsMenu">Settings</button>
<button type="button" disabled [matMenuTriggerFor]="settingsMenu">Disabled menu</button>
<mat-menu #settingsMenu>
<menu mat-menu-item>Profile</menu>
<menu mat-menu-item>Account</menu>
</mat-menu>
| {
"end_byte": 276,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-harness/menu-harness-example.html"
} |
components/src/components-examples/material/menu/menu-harness/menu-harness-example.ts_0_301 | import {Component} from '@angular/core';
import {MatMenuModule} from '@angular/material/menu';
/**
* @title Testing with MatMenuHarness
*/
@Component({
selector: 'menu-harness-example',
templateUrl: 'menu-harness-example.html',
imports: [MatMenuModule],
})
export class MenuHarnessExample {}
| {
"end_byte": 301,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-harness/menu-harness-example.ts"
} |
components/src/components-examples/material/menu/menu-harness/menu-harness-example.spec.ts_0_2071 | import {ComponentFixture, TestBed} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatMenuHarness} from '@angular/material/menu/testing';
import {HarnessLoader} from '@angular/cdk/testing';
import {MatMenuModule} from '@angular/material/menu';
import {MenuHarnessExample} from './menu-harness-example';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
describe('MenuHarnessExample', () => {
let fixture: ComponentFixture<MenuHarnessExample>;
let loader: HarnessLoader;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [MatMenuModule, NoopAnimationsModule, MenuHarnessExample],
});
fixture = TestBed.createComponent(MenuHarnessExample);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
});
it('should load all menu harnesses', async () => {
const menues = await loader.getAllHarnesses(MatMenuHarness);
expect(menues.length).toBe(2);
});
it('should get disabled state', async () => {
const [enabledMenu, disabledMenu] = await loader.getAllHarnesses(MatMenuHarness);
expect(await enabledMenu.isDisabled()).toBe(false);
expect(await disabledMenu.isDisabled()).toBe(true);
});
it('should get menu text', async () => {
const [firstMenu, secondMenu] = await loader.getAllHarnesses(MatMenuHarness);
expect(await firstMenu.getTriggerText()).toBe('Settings');
expect(await secondMenu.getTriggerText()).toBe('Disabled menu');
});
it('should open and close', async () => {
const menu = await loader.getHarness(MatMenuHarness.with({triggerText: 'Settings'}));
expect(await menu.isOpen()).toBe(false);
await menu.open();
expect(await menu.isOpen()).toBe(true);
await menu.close();
expect(await menu.isOpen()).toBe(false);
});
it('should get all items', async () => {
const menu = await loader.getHarness(MatMenuHarness.with({triggerText: 'Settings'}));
await menu.open();
expect((await menu.getItems()).length).toBe(2);
});
});
| {
"end_byte": 2071,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-harness/menu-harness-example.spec.ts"
} |
components/src/components-examples/material/menu/menu-icons/menu-icons-example.ts_0_427 | import {Component} from '@angular/core';
import {MatIconModule} from '@angular/material/icon';
import {MatMenuModule} from '@angular/material/menu';
import {MatButtonModule} from '@angular/material/button';
/**
* @title Menu with icons
*/
@Component({
selector: 'menu-icons-example',
templateUrl: 'menu-icons-example.html',
imports: [MatButtonModule, MatMenuModule, MatIconModule],
})
export class MenuIconsExample {}
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-icons/menu-icons-example.ts"
} |
components/src/components-examples/material/menu/menu-icons/menu-icons-example.html_0_500 | <button mat-icon-button [matMenuTriggerFor]="menu" aria-label="Example icon-button with a menu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #menu="matMenu">
<button mat-menu-item>
<mat-icon>dialpad</mat-icon>
<span>Redial</span>
</button>
<button mat-menu-item disabled>
<mat-icon>voicemail</mat-icon>
<span>Check voice mail</span>
</button>
<button mat-menu-item>
<mat-icon>notifications_off</mat-icon>
<span>Disable alerts</span>
</button>
</mat-menu>
| {
"end_byte": 500,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-icons/menu-icons-example.html"
} |
components/src/components-examples/material/menu/menu-overview/menu-overview-example.html_0_264 | <!-- #docregion mat-menu-trigger-for -->
<button mat-button [matMenuTriggerFor]="menu">Menu</button>
<!-- #enddocregion mat-menu-trigger-for -->
<mat-menu #menu="matMenu">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
| {
"end_byte": 264,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-overview/menu-overview-example.html"
} |
components/src/components-examples/material/menu/menu-overview/menu-overview-example.ts_0_362 | import {Component} from '@angular/core';
import {MatMenuModule} from '@angular/material/menu';
import {MatButtonModule} from '@angular/material/button';
/**
* @title Basic menu
*/
@Component({
selector: 'menu-overview-example',
templateUrl: 'menu-overview-example.html',
imports: [MatButtonModule, MatMenuModule],
})
export class MenuOverviewExample {}
| {
"end_byte": 362,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-overview/menu-overview-example.ts"
} |
components/src/components-examples/material/menu/menu-nested/menu-nested-example.ts_0_357 | import {Component} from '@angular/core';
import {MatMenuModule} from '@angular/material/menu';
import {MatButtonModule} from '@angular/material/button';
/**
* @title Nested menu
*/
@Component({
selector: 'menu-nested-example',
templateUrl: 'menu-nested-example.html',
imports: [MatButtonModule, MatMenuModule],
})
export class MenuNestedExample {}
| {
"end_byte": 357,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-nested/menu-nested-example.ts"
} |
components/src/components-examples/material/menu/menu-nested/menu-nested-example.html_0_1852 | <button mat-button [matMenuTriggerFor]="animals">Animal index</button>
<!-- #docregion sub-menu -->
<mat-menu #animals="matMenu">
<button mat-menu-item [matMenuTriggerFor]="vertebrates">Vertebrates</button>
<button mat-menu-item [matMenuTriggerFor]="invertebrates">Invertebrates</button>
</mat-menu>
<mat-menu #vertebrates="matMenu">
<button mat-menu-item [matMenuTriggerFor]="fish">Fishes</button>
<button mat-menu-item [matMenuTriggerFor]="amphibians">Amphibians</button>
<button mat-menu-item [matMenuTriggerFor]="reptiles">Reptiles</button>
<button mat-menu-item>Birds</button>
<button mat-menu-item>Mammals</button>
</mat-menu>
<!-- #enddocregion sub-menu -->
<mat-menu #invertebrates="matMenu">
<button mat-menu-item>Insects</button>
<button mat-menu-item>Molluscs</button>
<button mat-menu-item>Crustaceans</button>
<button mat-menu-item>Corals</button>
<button mat-menu-item>Arachnids</button>
<button mat-menu-item>Velvet worms</button>
<button mat-menu-item>Horseshoe crabs</button>
</mat-menu>
<mat-menu #fish="matMenu">
<button mat-menu-item>Baikal oilfish</button>
<button mat-menu-item>Bala shark</button>
<button mat-menu-item>Ballan wrasse</button>
<button mat-menu-item>Bamboo shark</button>
<button mat-menu-item>Banded killifish</button>
</mat-menu>
<mat-menu #amphibians="matMenu">
<button mat-menu-item>Sonoran desert toad</button>
<button mat-menu-item>Western toad</button>
<button mat-menu-item>Arroyo toad</button>
<button mat-menu-item>Yosemite toad</button>
</mat-menu>
<mat-menu #reptiles="matMenu">
<button mat-menu-item>Banded Day Gecko</button>
<button mat-menu-item>Banded Gila Monster</button>
<button mat-menu-item>Black Tree Monitor</button>
<button mat-menu-item>Blue Spiny Lizard</button>
<button mat-menu-item disabled>Velociraptor</button>
</mat-menu>
| {
"end_byte": 1852,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-nested/menu-nested-example.html"
} |
components/src/components-examples/material/menu/menu-position/menu-position-example.html_0_911 | <button mat-button [matMenuTriggerFor]="aboveMenu">Above</button>
<!-- #docregion menu-position -->
<mat-menu #aboveMenu="matMenu" yPosition="above">
<!-- #enddocregion menu-position -->
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
<button mat-button [matMenuTriggerFor]="belowMenu">Below</button>
<mat-menu #belowMenu="matMenu" yPosition="below">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
<button mat-button [matMenuTriggerFor]="beforeMenu">Before</button>
<mat-menu #beforeMenu="matMenu" xPosition="before">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
<button mat-button [matMenuTriggerFor]="afterMenu">After</button>
<mat-menu #afterMenu="matMenu" xPosition="after">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
| {
"end_byte": 911,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-position/menu-position-example.html"
} |
components/src/components-examples/material/menu/menu-position/menu-position-example.ts_0_368 | import {Component} from '@angular/core';
import {MatMenuModule} from '@angular/material/menu';
import {MatButtonModule} from '@angular/material/button';
/**
* @title Menu positioning
*/
@Component({
selector: 'menu-position-example',
templateUrl: 'menu-position-example.html',
imports: [MatButtonModule, MatMenuModule],
})
export class MenuPositionExample {}
| {
"end_byte": 368,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/menu/menu-position/menu-position-example.ts"
} |
components/src/components-examples/material/grid-list/BUILD.bazel_0_1044 | load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "grid-list",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
assets = glob([
"**/*.html",
"**/*.css",
]),
deps = [
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/grid-list",
"//src/material/grid-list/testing",
"@npm//@angular/platform-browser",
"@npm//@types/jasmine",
],
)
filegroup(
name = "source-files",
srcs = glob([
"**/*.html",
"**/*.css",
"**/*.ts",
]),
)
ng_test_library(
name = "unit_tests_lib",
srcs = glob(["**/*.spec.ts"]),
deps = [
":grid-list",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/grid-list",
"//src/material/grid-list/testing",
],
)
ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
| {
"end_byte": 1044,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/grid-list/BUILD.bazel"
} |
components/src/components-examples/material/grid-list/index.ts_0_261 | export {GridListDynamicExample} from './grid-list-dynamic/grid-list-dynamic-example';
export {GridListOverviewExample} from './grid-list-overview/grid-list-overview-example';
export {GridListHarnessExample} from './grid-list-harness/grid-list-harness-example';
| {
"end_byte": 261,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/grid-list/index.ts"
} |
components/src/components-examples/material/grid-list/grid-list-dynamic/grid-list-dynamic-example.ts_0_666 | import {Component} from '@angular/core';
import {MatGridListModule} from '@angular/material/grid-list';
export interface Tile {
color: string;
cols: number;
rows: number;
text: string;
}
/**
* @title Dynamic grid-list
*/
@Component({
selector: 'grid-list-dynamic-example',
templateUrl: 'grid-list-dynamic-example.html',
imports: [MatGridListModule],
})
export class GridListDynamicExample {
tiles: Tile[] = [
{text: 'One', cols: 3, rows: 1, color: 'lightblue'},
{text: 'Two', cols: 1, rows: 2, color: 'lightgreen'},
{text: 'Three', cols: 1, rows: 1, color: 'lightpink'},
{text: 'Four', cols: 2, rows: 1, color: '#DDBDF1'},
];
}
| {
"end_byte": 666,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/grid-list/grid-list-dynamic/grid-list-dynamic-example.ts"
} |
components/src/components-examples/material/grid-list/grid-list-dynamic/grid-list-dynamic-example.html_0_244 | <mat-grid-list cols="4" rowHeight="100px">
@for (tile of tiles; track tile) {
<mat-grid-tile
[colspan]="tile.cols"
[rowspan]="tile.rows"
[style.background]="tile.color">{{tile.text}}</mat-grid-tile>
}
</mat-grid-list>
| {
"end_byte": 244,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/grid-list/grid-list-dynamic/grid-list-dynamic-example.html"
} |
components/src/components-examples/material/grid-list/grid-list-overview/grid-list-overview-example.html_0_198 | <mat-grid-list cols="2" rowHeight="2:1">
<mat-grid-tile>1</mat-grid-tile>
<mat-grid-tile>2</mat-grid-tile>
<mat-grid-tile>3</mat-grid-tile>
<mat-grid-tile>4</mat-grid-tile>
</mat-grid-list>
| {
"end_byte": 198,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/grid-list/grid-list-overview/grid-list-overview-example.html"
} |
components/src/components-examples/material/grid-list/grid-list-overview/grid-list-overview-example.ts_0_365 | import {Component} from '@angular/core';
import {MatGridListModule} from '@angular/material/grid-list';
/**
* @title Basic grid-list
*/
@Component({
selector: 'grid-list-overview-example',
styleUrl: 'grid-list-overview-example.css',
templateUrl: 'grid-list-overview-example.html',
imports: [MatGridListModule],
})
export class GridListOverviewExample {}
| {
"end_byte": 365,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/grid-list/grid-list-overview/grid-list-overview-example.ts"
} |
components/src/components-examples/material/grid-list/grid-list-overview/grid-list-overview-example.css_0_43 | mat-grid-tile {
background: lightblue;
}
| {
"end_byte": 43,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/grid-list/grid-list-overview/grid-list-overview-example.css"
} |
components/src/components-examples/material/grid-list/grid-list-harness/grid-list-harness-example.spec.ts_0_1991 | import {ComponentFixture, TestBed} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatGridListHarness, MatGridTileHarness} from '@angular/material/grid-list/testing';
import {HarnessLoader} from '@angular/cdk/testing';
import {MatGridListModule} from '@angular/material/grid-list';
import {GridListHarnessExample} from './grid-list-harness-example';
describe('GridListHarnessExample', () => {
let fixture: ComponentFixture<GridListHarnessExample>;
let loader: HarnessLoader;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [MatGridListModule, GridListHarnessExample],
});
fixture = TestBed.createComponent(GridListHarnessExample);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
});
it('should be able to load grid-list harnesses', async () => {
const harnesses = await loader.getAllHarnesses(MatGridListHarness);
expect(harnesses.length).toBe(1);
});
it('should be able to load grid-tile harnesses', async () => {
const harnesses = await loader.getAllHarnesses(MatGridTileHarness);
expect(harnesses.length).toBe(4);
});
it('should be able to get tiles of grid-list with filters', async () => {
const gridList = await loader.getHarness(MatGridListHarness);
const tiles = await gridList.getTiles({headerText: /Tile [34]/});
expect(tiles.length).toBe(2);
});
it('should be able to check whether tile has header', async () => {
const tiles = await loader.getAllHarnesses(MatGridTileHarness);
expect(await tiles[0].hasHeader()).toBe(false);
expect(await (await tiles[0].host()).text()).toBe('Tile 1 (no header, no footer)');
});
it('should be able to check whether tile has footer', async () => {
const tiles = await loader.getAllHarnesses(MatGridTileHarness);
expect(await tiles[2].hasFooter()).toBe(true);
expect(await tiles[2].getFooterText()).toBe('Tile 3 footer');
});
});
| {
"end_byte": 1991,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/grid-list/grid-list-harness/grid-list-harness-example.spec.ts"
} |
components/src/components-examples/material/grid-list/grid-list-harness/grid-list-harness-example.ts_0_332 | import {Component} from '@angular/core';
import {MatGridListModule} from '@angular/material/grid-list';
/**
* @title Testing with MatGridListHarness
*/
@Component({
selector: 'grid-list-harness-example',
templateUrl: 'grid-list-harness-example.html',
imports: [MatGridListModule],
})
export class GridListHarnessExample {}
| {
"end_byte": 332,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/grid-list/grid-list-harness/grid-list-harness-example.ts"
} |
components/src/components-examples/material/grid-list/grid-list-harness/grid-list-harness-example.html_0_477 | <mat-grid-list cols="2" rowHeight="100px">
<mat-grid-tile>Tile 1 (no header, no footer)</mat-grid-tile>
<mat-grid-tile>
<mat-grid-tile-header>Tile 2</mat-grid-tile-header>
</mat-grid-tile>
<mat-grid-tile colspan="2">
<mat-grid-tile-header>Tile 3</mat-grid-tile-header>
<mat-grid-tile-footer>Tile 3 footer</mat-grid-tile-footer>
</mat-grid-tile>
<mat-grid-tile>
<mat-grid-tile-header>Tile 4</mat-grid-tile-header>
</mat-grid-tile>
</mat-grid-list>
| {
"end_byte": 477,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/grid-list/grid-list-harness/grid-list-harness-example.html"
} |
components/src/components-examples/material/bottom-sheet/BUILD.bazel_0_1198 | load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "bottom-sheet",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
assets = glob([
"**/*.html",
"**/*.css",
]),
deps = [
"//src/cdk/overlay",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/bottom-sheet",
"//src/material/bottom-sheet/testing",
"//src/material/button",
"//src/material/list",
"@npm//@angular/platform-browser",
"@npm//@types/jasmine",
],
)
filegroup(
name = "source-files",
srcs = glob([
"**/*.html",
"**/*.css",
"**/*.ts",
]),
)
ng_test_library(
name = "unit_tests_lib",
srcs = glob(["**/*.spec.ts"]),
deps = [
":bottom-sheet",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/bottom-sheet",
"//src/material/bottom-sheet/testing",
"@npm//@angular/platform-browser",
],
)
ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
| {
"end_byte": 1198,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/bottom-sheet/BUILD.bazel"
} |
components/src/components-examples/material/bottom-sheet/index.ts_0_233 | export {
BottomSheetOverviewExample,
BottomSheetOverviewExampleSheet,
} from './bottom-sheet-overview/bottom-sheet-overview-example';
export {BottomSheetHarnessExample} from './bottom-sheet-harness/bottom-sheet-harness-example';
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/bottom-sheet/index.ts"
} |
components/src/components-examples/material/bottom-sheet/bottom-sheet-overview/bottom-sheet-overview-example-sheet.html_0_751 | <mat-nav-list>
<a href="https://keep.google.com/" mat-list-item (click)="openLink($event)">
<span matListItemTitle>Google Keep</span>
<span matLine>Add to a note</span>
</a>
<a href="https://docs.google.com/" mat-list-item (click)="openLink($event)">
<span matListItemTitle>Google Docs</span>
<span matLine>Embed in a document</span>
</a>
<a href="https://plus.google.com/" mat-list-item (click)="openLink($event)">
<span matListItemTitle>Google Plus</span>
<span matLine>Share with your friends</span>
</a>
<a href="https://hangouts.google.com/" mat-list-item (click)="openLink($event)">
<span matListItemTitle>Google Hangouts</span>
<span matLine>Show to your coworkers</span>
</a>
</mat-nav-list>
| {
"end_byte": 751,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/bottom-sheet/bottom-sheet-overview/bottom-sheet-overview-example-sheet.html"
} |
components/src/components-examples/material/bottom-sheet/bottom-sheet-overview/bottom-sheet-overview-example.ts_0_1090 | import {Component, inject} from '@angular/core';
import {
MatBottomSheet,
MatBottomSheetModule,
MatBottomSheetRef,
} from '@angular/material/bottom-sheet';
import {MatListModule} from '@angular/material/list';
import {MatButtonModule} from '@angular/material/button';
/**
* @title Bottom Sheet Overview
*/
@Component({
selector: 'bottom-sheet-overview-example',
templateUrl: 'bottom-sheet-overview-example.html',
imports: [MatButtonModule, MatBottomSheetModule],
})
export class BottomSheetOverviewExample {
private _bottomSheet = inject(MatBottomSheet);
openBottomSheet(): void {
this._bottomSheet.open(BottomSheetOverviewExampleSheet);
}
}
@Component({
selector: 'bottom-sheet-overview-example-sheet',
templateUrl: 'bottom-sheet-overview-example-sheet.html',
imports: [MatListModule],
})
export class BottomSheetOverviewExampleSheet {
private _bottomSheetRef =
inject<MatBottomSheetRef<BottomSheetOverviewExampleSheet>>(MatBottomSheetRef);
openLink(event: MouseEvent): void {
this._bottomSheetRef.dismiss();
event.preventDefault();
}
}
| {
"end_byte": 1090,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/bottom-sheet/bottom-sheet-overview/bottom-sheet-overview-example.ts"
} |
components/src/components-examples/material/bottom-sheet/bottom-sheet-overview/bottom-sheet-overview-example.html_0_133 | <p>You have received a file called "cat-picture.jpeg".</p>
<button mat-raised-button (click)="openBottomSheet()">Open file</button>
| {
"end_byte": 133,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/bottom-sheet/bottom-sheet-overview/bottom-sheet-overview-example.html"
} |
components/src/components-examples/material/bottom-sheet/bottom-sheet-harness/bottom-sheet-harness-example.ts_0_639 | import {Component, TemplateRef, ViewChild, inject} from '@angular/core';
import {
MatBottomSheet,
MatBottomSheetConfig,
MatBottomSheetModule,
} from '@angular/material/bottom-sheet';
/**
* @title Testing with MatBottomSheetHarness
*/
@Component({
selector: 'bottom-sheet-harness-example',
templateUrl: 'bottom-sheet-harness-example.html',
imports: [MatBottomSheetModule],
})
export class BottomSheetHarnessExample {
readonly bottomSheet = inject(MatBottomSheet);
@ViewChild(TemplateRef) template: TemplateRef<any>;
open(config?: MatBottomSheetConfig) {
return this.bottomSheet.open(this.template, config);
}
}
| {
"end_byte": 639,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/bottom-sheet/bottom-sheet-harness/bottom-sheet-harness-example.ts"
} |
components/src/components-examples/material/bottom-sheet/bottom-sheet-harness/bottom-sheet-harness-example.spec.ts_0_1822 | import {ComponentFixture, TestBed} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatBottomSheetHarness} from '@angular/material/bottom-sheet/testing';
import {HarnessLoader} from '@angular/cdk/testing';
import {BottomSheetHarnessExample} from './bottom-sheet-harness-example';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {MatBottomSheetModule} from '@angular/material/bottom-sheet';
describe('BottomSheetHarnessExample', () => {
let fixture: ComponentFixture<BottomSheetHarnessExample>;
let loader: HarnessLoader;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [MatBottomSheetModule, NoopAnimationsModule],
});
fixture = TestBed.createComponent(BottomSheetHarnessExample);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.documentRootLoader(fixture);
});
it('should load harness for a bottom sheet', async () => {
fixture.componentInstance.open();
const bottomSheets = await loader.getAllHarnesses(MatBottomSheetHarness);
expect(bottomSheets.length).toBe(1);
});
it('should be able to get aria-label of the bottom sheet', async () => {
fixture.componentInstance.open({ariaLabel: 'Confirm purchase.'});
const bottomSheet = await loader.getHarness(MatBottomSheetHarness);
expect(await bottomSheet.getAriaLabel()).toBe('Confirm purchase.');
});
it('should be able to dismiss the bottom sheet', async () => {
fixture.componentInstance.open();
let bottomSheets = await loader.getAllHarnesses(MatBottomSheetHarness);
expect(bottomSheets.length).toBe(1);
await bottomSheets[0].dismiss();
bottomSheets = await loader.getAllHarnesses(MatBottomSheetHarness);
expect(bottomSheets.length).toBe(0);
});
});
| {
"end_byte": 1822,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/bottom-sheet/bottom-sheet-harness/bottom-sheet-harness-example.spec.ts"
} |
components/src/components-examples/material/bottom-sheet/bottom-sheet-harness/bottom-sheet-harness-example.html_0_60 | <ng-template>
Hello from the bottom sheet!
</ng-template>
| {
"end_byte": 60,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/bottom-sheet/bottom-sheet-harness/bottom-sheet-harness-example.html"
} |
components/src/components-examples/material/select/BUILD.bazel_0_1205 | load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "select",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
assets = glob([
"**/*.html",
"**/*.css",
]),
deps = [
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/checkbox",
"//src/material/form-field",
"//src/material/input",
"//src/material/select",
"//src/material/select/testing",
"@npm//@angular/forms",
"@npm//@angular/platform-browser",
"@npm//@types/jasmine",
],
)
filegroup(
name = "source-files",
srcs = glob([
"**/*.html",
"**/*.css",
"**/*.ts",
]),
)
ng_test_library(
name = "unit_tests_lib",
srcs = glob(["**/*.spec.ts"]),
deps = [
":select",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/select",
"//src/material/select/testing",
"@npm//@angular/platform-browser",
],
)
ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
| {
"end_byte": 1205,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/BUILD.bazel"
} |
components/src/components-examples/material/select/index.ts_0_1296 | export {SelectCustomTriggerExample} from './select-custom-trigger/select-custom-trigger-example';
export {SelectDisabledExample} from './select-disabled/select-disabled-example';
export {SelectErrorStateMatcherExample} from './select-error-state-matcher/select-error-state-matcher-example';
export {SelectFormExample} from './select-form/select-form-example';
export {SelectHintErrorExample} from './select-hint-error/select-hint-error-example';
export {SelectMultipleExample} from './select-multiple/select-multiple-example';
export {SelectNoRippleExample} from './select-no-ripple/select-no-ripple-example';
export {SelectOptgroupExample} from './select-optgroup/select-optgroup-example';
export {SelectOverviewExample} from './select-overview/select-overview-example';
export {SelectPanelClassExample} from './select-panel-class/select-panel-class-example';
export {SelectResetExample} from './select-reset/select-reset-example';
export {SelectValueBindingExample} from './select-value-binding/select-value-binding-example';
export {SelectReactiveFormExample} from './select-reactive-form/select-reactive-form-example';
export {SelectInitialValueExample} from './select-initial-value/select-initial-value-example';
export {SelectHarnessExample} from './select-harness/select-harness-example';
| {
"end_byte": 1296,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/index.ts"
} |
components/src/components-examples/material/select/select-error-state-matcher/select-error-state-matcher-example.ts_0_1468 | import {Component} from '@angular/core';
import {
FormControl,
FormGroupDirective,
NgForm,
Validators,
FormsModule,
ReactiveFormsModule,
} from '@angular/forms';
import {ErrorStateMatcher} from '@angular/material/core';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
/** Error when invalid control is dirty, touched, or submitted. */
export class MyErrorStateMatcher implements ErrorStateMatcher {
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted = form && form.submitted;
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
}
}
/** @title Select with a custom ErrorStateMatcher */
@Component({
selector: 'select-error-state-matcher-example',
templateUrl: 'select-error-state-matcher-example.html',
imports: [MatFormFieldModule, MatSelectModule, FormsModule, ReactiveFormsModule, MatInputModule],
})
export class SelectErrorStateMatcherExample {
selected = new FormControl('valid', [Validators.required, Validators.pattern('valid')]);
selectFormControl = new FormControl('valid', [Validators.required, Validators.pattern('valid')]);
nativeSelectFormControl = new FormControl('valid', [
Validators.required,
Validators.pattern('valid'),
]);
matcher = new MyErrorStateMatcher();
}
| {
"end_byte": 1468,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-error-state-matcher/select-error-state-matcher-example.ts"
} |
components/src/components-examples/material/select/select-error-state-matcher/select-error-state-matcher-example.html_0_1249 | <h4>mat-select</h4>
<mat-form-field>
<mat-label>Choose one</mat-label>
<mat-select [formControl]="selected" [errorStateMatcher]="matcher">
<mat-option>Clear</mat-option>
<mat-option value="valid">Valid option</mat-option>
<mat-option value="invalid">Invalid option</mat-option>
</mat-select>
<mat-hint>Errors appear instantly!</mat-hint>
@if (selected.hasError('required')) {
<mat-error>You must make a selection</mat-error>
}
@if (selected.hasError('pattern') && !selected.hasError('required')) {
<mat-error>Your selection is invalid</mat-error>
}
</mat-form-field>
<h4>native html select</h4>
<mat-form-field class="demo-full-width">
<mat-label>Choose one</mat-label>
<select matNativeControl [formControl]="nativeSelectFormControl" [errorStateMatcher]="matcher">
<option value=""></option>
<option value="valid" selected>Valid option</option>
<option value="invalid">Invalid option</option>
</select>
@if (nativeSelectFormControl.hasError('required')) {
<mat-error>You must make a selection</mat-error>
}
@if (nativeSelectFormControl.hasError('pattern') && !nativeSelectFormControl.hasError('required')) {
<mat-error>Your selection is invalid</mat-error>
}
</mat-form-field>
| {
"end_byte": 1249,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-error-state-matcher/select-error-state-matcher-example.html"
} |
components/src/components-examples/material/select/select-reactive-form/select-reactive-form-example.ts_0_1225 | import {Component} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
interface Food {
value: string;
viewValue: string;
}
interface Car {
value: string;
viewValue: string;
}
/**
* @title Select in a reactive form
*/
@Component({
selector: 'select-reactive-form-example',
templateUrl: 'select-reactive-form-example.html',
imports: [FormsModule, ReactiveFormsModule, MatFormFieldModule, MatSelectModule, MatInputModule],
})
export class SelectReactiveFormExample {
foods: Food[] = [
{value: 'steak-0', viewValue: 'Steak'},
{value: 'pizza-1', viewValue: 'Pizza'},
{value: 'tacos-2', viewValue: 'Tacos'},
];
cars: Car[] = [
{value: 'volvo', viewValue: 'Volvo'},
{value: 'saab', viewValue: 'Saab'},
{value: 'mercedes', viewValue: 'Mercedes'},
];
foodControl = new FormControl(this.foods[2].value);
carControl = new FormControl(this.cars[1].value);
form = new FormGroup({
food: this.foodControl,
car: this.carControl,
});
}
| {
"end_byte": 1225,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-reactive-form/select-reactive-form-example.ts"
} |
components/src/components-examples/material/select/select-reactive-form/select-reactive-form-example.html_0_782 | <form [formGroup]="form">
<h4>mat-select</h4>
<mat-form-field>
<mat-label>Favorite Food</mat-label>
<mat-select [formControl]="foodControl" name="food">
<mat-option>None</mat-option>
@for (food of foods; track food) {
<mat-option [value]="food.value">{{food.viewValue}}</mat-option>
}
</mat-select>
</mat-form-field>
<p>Selected: {{foodControl.value}}</p>
<h4>Native select</h4>
<mat-form-field>
<mat-label>Favorite Car</mat-label>
<select matNativeControl [formControl]="carControl" name="car">
<option value="">None</option>
@for (car of cars; track car) {
<option [value]="car.value">{{car.viewValue}}</option>
}
</select>
</mat-form-field>
<p>Selected: {{carControl.value}}</p>
</form>
| {
"end_byte": 782,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-reactive-form/select-reactive-form-example.html"
} |
components/src/components-examples/material/select/select-no-ripple/select-no-ripple-example.html_0_266 | <mat-form-field>
<mat-label>Select an option</mat-label>
<mat-select disableRipple>
<mat-option value="1">Option 1</mat-option>
<mat-option value="2">Option 2</mat-option>
<mat-option value="3">Option 3</mat-option>
</mat-select>
</mat-form-field>
| {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-no-ripple/select-no-ripple-example.html"
} |
components/src/components-examples/material/select/select-no-ripple/select-no-ripple-example.ts_0_400 | import {Component} from '@angular/core';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
/** @title Select with no option ripple */
@Component({
selector: 'select-no-ripple-example',
templateUrl: 'select-no-ripple-example.html',
imports: [MatFormFieldModule, MatSelectModule],
})
export class SelectNoRippleExample {}
| {
"end_byte": 400,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-no-ripple/select-no-ripple-example.ts"
} |
components/src/components-examples/material/select/select-hint-error/select-hint-error-example.html_0_1009 | <h4>mat select</h4>
<mat-form-field>
<mat-label>Favorite animal</mat-label>
<mat-select [formControl]="animalControl" required>
<mat-option>--</mat-option>
@for (animal of animals; track animal) {
<mat-option [value]="animal">{{animal.name}}</mat-option>
}
</mat-select>
@if (animalControl.hasError('required')) {
<mat-error>Please choose an animal</mat-error>
}
<mat-hint>{{animalControl.value?.sound}}</mat-hint>
</mat-form-field>
<h4>native html select</h4>
<mat-form-field>
<mat-label>Select your car (required)</mat-label>
<select matNativeControl required [formControl]="selectFormControl">
<option label="--select something --"></option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
@if (selectFormControl.hasError('required')) {
<mat-error>This field is required</mat-error>
}
<mat-hint>You can pick up your favorite car here</mat-hint>
</mat-form-field>
| {
"end_byte": 1009,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-hint-error/select-hint-error-example.html"
} |
components/src/components-examples/material/select/select-hint-error/select-hint-error-example.ts_0_984 | import {Component} from '@angular/core';
import {FormControl, Validators, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
interface Animal {
name: string;
sound: string;
}
/** @title Select with form field features */
@Component({
selector: 'select-hint-error-example',
templateUrl: 'select-hint-error-example.html',
imports: [MatFormFieldModule, MatSelectModule, FormsModule, ReactiveFormsModule, MatInputModule],
})
export class SelectHintErrorExample {
animalControl = new FormControl<Animal | null>(null, Validators.required);
selectFormControl = new FormControl('', Validators.required);
animals: Animal[] = [
{name: 'Dog', sound: 'Woof!'},
{name: 'Cat', sound: 'Meow!'},
{name: 'Cow', sound: 'Moo!'},
{name: 'Fox', sound: 'Wa-pa-pa-pa-pa-pa-pow!'},
];
}
| {
"end_byte": 984,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-hint-error/select-hint-error-example.ts"
} |
components/src/components-examples/material/select/select-custom-trigger/select-custom-trigger-example.html_0_560 | <mat-form-field>
<mat-label>Toppings</mat-label>
<mat-select [formControl]="toppings" multiple>
<mat-select-trigger>
{{toppings.value?.[0] || ''}}
@if ((toppings.value?.length || 0) > 1) {
<span class="example-additional-selection">
(+{{(toppings.value?.length || 0) - 1}} {{toppings.value?.length === 2 ? 'other' : 'others'}})
</span>
}
</mat-select-trigger>
@for (topping of toppingList; track topping) {
<mat-option [value]="topping">{{topping}}</mat-option>
}
</mat-select>
</mat-form-field>
| {
"end_byte": 560,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-custom-trigger/select-custom-trigger-example.html"
} |
components/src/components-examples/material/select/select-custom-trigger/select-custom-trigger-example.ts_0_714 | import {Component} from '@angular/core';
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
/** @title Select with custom trigger text */
@Component({
selector: 'select-custom-trigger-example',
templateUrl: 'select-custom-trigger-example.html',
styleUrl: 'select-custom-trigger-example.css',
imports: [MatFormFieldModule, MatSelectModule, FormsModule, ReactiveFormsModule],
})
export class SelectCustomTriggerExample {
toppings = new FormControl('');
toppingList: string[] = ['Extra cheese', 'Mushroom', 'Onion', 'Pepperoni', 'Sausage', 'Tomato'];
}
| {
"end_byte": 714,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-custom-trigger/select-custom-trigger-example.ts"
} |
components/src/components-examples/material/select/select-custom-trigger/select-custom-trigger-example.css_0_90 | .example-additional-selection {
opacity: 0.75;
font-size: 0.75em;
line-height: 1;
}
| {
"end_byte": 90,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-custom-trigger/select-custom-trigger-example.css"
} |
components/src/components-examples/material/select/select-initial-value/select-initial-value-example.ts_0_1161 | import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
interface Food {
value: string;
viewValue: string;
}
interface Car {
value: string;
viewValue: string;
}
/**
* @title Basic select with initial value and no form
*/
@Component({
selector: 'select-initial-value-example',
templateUrl: 'select-initial-value-example.html',
imports: [MatFormFieldModule, MatSelectModule, MatInputModule, FormsModule],
})
export class SelectInitialValueExample {
foods: Food[] = [
{value: 'steak-0', viewValue: 'Steak'},
{value: 'pizza-1', viewValue: 'Pizza'},
{value: 'tacos-2', viewValue: 'Tacos'},
];
cars: Car[] = [
{value: 'ford', viewValue: 'Ford'},
{value: 'chevrolet', viewValue: 'Chevrolet'},
{value: 'dodge', viewValue: 'Dodge'},
];
selectedFood = this.foods[2].value;
selectedCar = this.cars[0].value;
selectCar(event: Event) {
this.selectedCar = (event.target as HTMLSelectElement).value;
}
}
| {
"end_byte": 1161,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-initial-value/select-initial-value-example.ts"
} |
components/src/components-examples/material/select/select-initial-value/select-initial-value-example.html_0_799 | <h4>Basic mat-select with initial value</h4>
<mat-form-field>
<mat-label>Favorite Food</mat-label>
<mat-select [(value)]="selectedFood">
<mat-option></mat-option>
@for (option of foods; track option) {
<mat-option [value]="option.value">{{ option.viewValue }}</mat-option>
}
</mat-select>
</mat-form-field>
<p>You selected: {{selectedFood}}</p>
<h4>Basic native select with initial value</h4>
<mat-form-field>
<mat-label>Favorite Car</mat-label>
<select matNativeControl (change)="selectCar($event)">
<option value=""></option>
@for (option of cars; track option) {
<option [value]="option.value"
[selected]="selectedCar === option.value">{{ option.viewValue }}</option>
}
</select>
</mat-form-field>
<p>You selected: {{selectedCar}}</p>
| {
"end_byte": 799,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-initial-value/select-initial-value-example.html"
} |
components/src/components-examples/material/select/select-multiple/select-multiple-example.html_0_252 | <mat-form-field>
<mat-label>Toppings</mat-label>
<mat-select [formControl]="toppings" multiple>
@for (topping of toppingList; track topping) {
<mat-option [value]="topping">{{topping}}</mat-option>
}
</mat-select>
</mat-form-field>
| {
"end_byte": 252,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-multiple/select-multiple-example.html"
} |
components/src/components-examples/material/select/select-multiple/select-multiple-example.ts_0_646 | import {Component} from '@angular/core';
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
/** @title Select with multiple selection */
@Component({
selector: 'select-multiple-example',
templateUrl: 'select-multiple-example.html',
imports: [MatFormFieldModule, MatSelectModule, FormsModule, ReactiveFormsModule],
})
export class SelectMultipleExample {
toppings = new FormControl('');
toppingList: string[] = ['Extra cheese', 'Mushroom', 'Onion', 'Pepperoni', 'Sausage', 'Tomato'];
}
| {
"end_byte": 646,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-multiple/select-multiple-example.ts"
} |
components/src/components-examples/material/select/select-optgroup/select-optgroup-example.ts_0_1648 | import {Component} from '@angular/core';
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
interface Pokemon {
value: string;
viewValue: string;
}
interface PokemonGroup {
disabled?: boolean;
name: string;
pokemon: Pokemon[];
}
/** @title Select with option groups */
@Component({
selector: 'select-optgroup-example',
templateUrl: 'select-optgroup-example.html',
imports: [MatFormFieldModule, MatSelectModule, FormsModule, ReactiveFormsModule, MatInputModule],
})
export class SelectOptgroupExample {
pokemonControl = new FormControl('');
pokemonGroups: PokemonGroup[] = [
{
name: 'Grass',
pokemon: [
{value: 'bulbasaur-0', viewValue: 'Bulbasaur'},
{value: 'oddish-1', viewValue: 'Oddish'},
{value: 'bellsprout-2', viewValue: 'Bellsprout'},
],
},
{
name: 'Water',
pokemon: [
{value: 'squirtle-3', viewValue: 'Squirtle'},
{value: 'psyduck-4', viewValue: 'Psyduck'},
{value: 'horsea-5', viewValue: 'Horsea'},
],
},
{
name: 'Fire',
disabled: true,
pokemon: [
{value: 'charmander-6', viewValue: 'Charmander'},
{value: 'vulpix-7', viewValue: 'Vulpix'},
{value: 'flareon-8', viewValue: 'Flareon'},
],
},
{
name: 'Psychic',
pokemon: [
{value: 'mew-9', viewValue: 'Mew'},
{value: 'mewtwo-10', viewValue: 'Mewtwo'},
],
},
];
}
| {
"end_byte": 1648,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-optgroup/select-optgroup-example.ts"
} |
components/src/components-examples/material/select/select-optgroup/select-optgroup-example.html_0_916 | <h4>mat-select</h4>
<mat-form-field>
<mat-label>Pokemon</mat-label>
<mat-select [formControl]="pokemonControl">
<mat-option>-- None --</mat-option>
@for (group of pokemonGroups; track group) {
<mat-optgroup [label]="group.name"
[disabled]="group.disabled">
@for (pokemon of group.pokemon; track pokemon) {
<mat-option [value]="pokemon.value">{{pokemon.viewValue}}</mat-option>
}
</mat-optgroup>
}
</mat-select>
</mat-form-field>
<h4>native html select</h4>
<mat-form-field>
<mat-label>Cars</mat-label>
<select matNativeControl>
<optgroup label="Swedish Cars">
<option value="volvo">volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
</mat-form-field>
| {
"end_byte": 916,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-optgroup/select-optgroup-example.html"
} |
components/src/components-examples/material/select/select-value-binding/select-value-binding-example.ts_0_440 | import {Component} from '@angular/core';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
/** @title Select with 2-way value binding */
@Component({
selector: 'select-value-binding-example',
templateUrl: 'select-value-binding-example.html',
imports: [MatFormFieldModule, MatSelectModule],
})
export class SelectValueBindingExample {
selected = 'option2';
}
| {
"end_byte": 440,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-value-binding/select-value-binding-example.ts"
} |
components/src/components-examples/material/select/select-value-binding/select-value-binding-example.html_0_360 | <mat-form-field>
<mat-label>Select an option</mat-label>
<mat-select [(value)]="selected">
<mat-option>None</mat-option>
<mat-option value="option1">Option 1</mat-option>
<mat-option value="option2">Option 2</mat-option>
<mat-option value="option3">Option 3</mat-option>
</mat-select>
</mat-form-field>
<p>You selected: {{selected}}</p>
| {
"end_byte": 360,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-value-binding/select-value-binding-example.html"
} |
components/src/components-examples/material/select/select-form/select-form-example.ts_0_983 | import {Component} from '@angular/core';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
import {FormsModule} from '@angular/forms';
interface Food {
value: string;
viewValue: string;
}
interface Car {
value: string;
viewValue: string;
}
/**
* @title Select in a form
*/
@Component({
selector: 'select-form-example',
templateUrl: 'select-form-example.html',
imports: [FormsModule, MatFormFieldModule, MatSelectModule, MatInputModule],
})
export class SelectFormExample {
selectedValue: string;
selectedCar: string;
foods: Food[] = [
{value: 'steak-0', viewValue: 'Steak'},
{value: 'pizza-1', viewValue: 'Pizza'},
{value: 'tacos-2', viewValue: 'Tacos'},
];
cars: Car[] = [
{value: 'volvo', viewValue: 'Volvo'},
{value: 'saab', viewValue: 'Saab'},
{value: 'mercedes', viewValue: 'Mercedes'},
];
}
| {
"end_byte": 983,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-form/select-form-example.ts"
} |
components/src/components-examples/material/select/select-form/select-form-example.html_0_740 | <form>
<h4>mat-select</h4>
<mat-form-field>
<mat-label>Favorite food</mat-label>
<mat-select [(ngModel)]="selectedValue" name="food">
@for (food of foods; track food) {
<mat-option [value]="food.value">{{food.viewValue}}</mat-option>
}
</mat-select>
</mat-form-field>
<p> Selected food: {{selectedValue}} </p>
<h4>native html select</h4>
<mat-form-field>
<mat-label>Favorite car</mat-label>
<select matNativeControl [(ngModel)]="selectedCar" name="car">
<option value="" selected></option>
@for (car of cars; track car) {
<option [value]="car.value">{{car.viewValue}}</option>
}
</select>
</mat-form-field>
<p> Selected car: {{selectedCar}} </p>
</form>
| {
"end_byte": 740,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-form/select-form-example.html"
} |
components/src/components-examples/material/select/select-reset/select-reset-example.html_0_632 | <h4>mat-select</h4>
<mat-form-field>
<mat-label>State</mat-label>
<mat-select>
<mat-option>None</mat-option>
@for (state of states; track state) {
<mat-option [value]="state">{{state}}</mat-option>
}
</mat-select>
</mat-form-field>
<h4>native html select</h4>
<mat-form-field>
<mat-label>Select your car</mat-label>
<select matNativeControl id="mySelectId">
<option value="" disabled selected></option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
</mat-form-field>
| {
"end_byte": 632,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-reset/select-reset-example.html"
} |
components/src/components-examples/material/select/select-reset/select-reset-example.ts_0_1365 | import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
/** @title Select with reset option */
@Component({
selector: 'select-reset-example',
templateUrl: 'select-reset-example.html',
imports: [MatFormFieldModule, MatSelectModule, MatInputModule, FormsModule],
})
export class SelectResetExample {
states: string[] = [
'Alabama',
'Alaska',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
'Florida',
'Georgia',
'Hawaii',
'Idaho',
'Illinois',
'Indiana',
'Iowa',
'Kansas',
'Kentucky',
'Louisiana',
'Maine',
'Maryland',
'Massachusetts',
'Michigan',
'Minnesota',
'Mississippi',
'Missouri',
'Montana',
'Nebraska',
'Nevada',
'New Hampshire',
'New Jersey',
'New Mexico',
'New York',
'North Carolina',
'North Dakota',
'Ohio',
'Oklahoma',
'Oregon',
'Pennsylvania',
'Rhode Island',
'South Carolina',
'South Dakota',
'Tennessee',
'Texas',
'Utah',
'Vermont',
'Virginia',
'Washington',
'West Virginia',
'Wisconsin',
'Wyoming',
];
}
| {
"end_byte": 1365,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-reset/select-reset-example.ts"
} |
components/src/components-examples/material/select/select-panel-class/select-panel-class-example.css_0_245 | .example-panel-red.mat-mdc-select-panel {
background: rgba(255, 0, 0, 0.5);
}
.example-panel-green.mat-mdc-select-panel {
background: rgba(0, 255, 0, 0.5);
}
.example-panel-blue.mat-mdc-select-panel {
background: rgba(0, 0, 255, 0.5);
}
| {
"end_byte": 245,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-panel-class/select-panel-class-example.css"
} |
components/src/components-examples/material/select/select-panel-class/select-panel-class-example.html_0_333 | <mat-form-field>
<mat-label>Panel color</mat-label>
<mat-select [formControl]="panelColor"
panelClass="example-panel-{{panelColor.value}}">
<mat-option value="red">Red</mat-option>
<mat-option value="green">Green</mat-option>
<mat-option value="blue">Blue</mat-option>
</mat-select>
</mat-form-field>
| {
"end_byte": 333,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-panel-class/select-panel-class-example.html"
} |
components/src/components-examples/material/select/select-panel-class/select-panel-class-example.ts_0_778 | import {Component, ViewEncapsulation} from '@angular/core';
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
/**
* @title Select with custom panel styling
*/
@Component({
selector: 'select-panel-class-example',
templateUrl: 'select-panel-class-example.html',
styleUrl: 'select-panel-class-example.css',
// Encapsulation has to be disabled in order for the
// component style to apply to the select panel.
encapsulation: ViewEncapsulation.None,
imports: [MatFormFieldModule, MatSelectModule, FormsModule, ReactiveFormsModule],
})
export class SelectPanelClassExample {
panelColor = new FormControl('red');
}
| {
"end_byte": 778,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-panel-class/select-panel-class-example.ts"
} |
components/src/components-examples/material/select/select-overview/select-overview-example.html_0_557 | <h4>Basic mat-select</h4>
<mat-form-field>
<mat-label>Favorite food</mat-label>
<mat-select>
@for (food of foods; track food) {
<mat-option [value]="food.value">{{food.viewValue}}</mat-option>
}
</mat-select>
</mat-form-field>
<h4>Basic native select</h4>
<mat-form-field>
<mat-label>Cars</mat-label>
<select matNativeControl required>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
</mat-form-field>
| {
"end_byte": 557,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-overview/select-overview-example.html"
} |
components/src/components-examples/material/select/select-overview/select-overview-example.ts_0_731 | import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
interface Food {
value: string;
viewValue: string;
}
/**
* @title Basic select
*/
@Component({
selector: 'select-overview-example',
templateUrl: 'select-overview-example.html',
imports: [MatFormFieldModule, MatSelectModule, MatInputModule, FormsModule],
})
export class SelectOverviewExample {
foods: Food[] = [
{value: 'steak-0', viewValue: 'Steak'},
{value: 'pizza-1', viewValue: 'Pizza'},
{value: 'tacos-2', viewValue: 'Tacos'},
];
}
| {
"end_byte": 731,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-overview/select-overview-example.ts"
} |
components/src/components-examples/material/select/select-harness/select-harness-example.html_0_221 | <mat-form-field>
<mat-label>Favorite food</mat-label>
<mat-select>
@for (food of foods; track food) {
<mat-option [value]="food.value">{{food.viewValue}}</mat-option>
}
</mat-select>
</mat-form-field>
| {
"end_byte": 221,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-harness/select-harness-example.html"
} |
components/src/components-examples/material/select/select-harness/select-harness-example.spec.ts_0_1862 | import {ComponentFixture, TestBed} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatSelectHarness} from '@angular/material/select/testing';
import {HarnessLoader} from '@angular/cdk/testing';
import {SelectHarnessExample} from './select-harness-example';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {MatSelectModule} from '@angular/material/select';
describe('SelectHarnessExample', () => {
let fixture: ComponentFixture<SelectHarnessExample>;
let loader: HarnessLoader;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [MatSelectModule, NoopAnimationsModule],
});
fixture = TestBed.createComponent(SelectHarnessExample);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
});
it('should load all select harnesses', async () => {
const selects = await loader.getAllHarnesses(MatSelectHarness);
expect(selects.length).toBe(1);
});
it('should be able to check whether a select is in multi-selection mode', async () => {
const select = await loader.getHarness(MatSelectHarness);
expect(await select.isMultiple()).toBe(false);
});
it('should be able to open and close a select', async () => {
const select = await loader.getHarness(MatSelectHarness);
expect(await select.isOpen()).toBe(false);
await select.open();
expect(await select.isOpen()).toBe(true);
await select.close();
expect(await select.isOpen()).toBe(false);
});
it('should be able to get the value text from a select', async () => {
const select = await loader.getHarness(MatSelectHarness);
await select.open();
const options = await select.getOptions();
await options[2].click();
expect(await select.getValueText()).toBe('Tacos');
});
});
| {
"end_byte": 1862,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-harness/select-harness-example.spec.ts"
} |
components/src/components-examples/material/select/select-harness/select-harness-example.ts_0_550 | import {Component} from '@angular/core';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
/**
* @title Testing with MatSelectHarness
*/
@Component({
selector: 'select-harness-example',
templateUrl: 'select-harness-example.html',
imports: [MatFormFieldModule, MatSelectModule],
})
export class SelectHarnessExample {
foods = [
{value: 'steak-0', viewValue: 'Steak'},
{value: 'pizza-1', viewValue: 'Pizza'},
{value: 'tacos-2', viewValue: 'Tacos'},
];
}
| {
"end_byte": 550,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-harness/select-harness-example.ts"
} |
components/src/components-examples/material/select/select-disabled/select-disabled-example.ts_0_722 | import {Component} from '@angular/core';
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatCheckboxModule} from '@angular/material/checkbox';
/** @title Disabled select */
@Component({
selector: 'select-disabled-example',
templateUrl: 'select-disabled-example.html',
imports: [
MatCheckboxModule,
FormsModule,
ReactiveFormsModule,
MatFormFieldModule,
MatSelectModule,
MatInputModule,
],
})
export class SelectDisabledExample {
disableSelect = new FormControl(false);
}
| {
"end_byte": 722,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-disabled/select-disabled-example.ts"
} |
components/src/components-examples/material/select/select-disabled/select-disabled-example.html_0_824 | <p>
<mat-checkbox [formControl]="disableSelect">Disable select</mat-checkbox>
</p>
<h4>mat-select</h4>
<mat-form-field>
<mat-label>Choose an option</mat-label>
<mat-select [disabled]="disableSelect.value">
<mat-option value="option1">Option 1</mat-option>
<mat-option value="option2" disabled>Option 2 (disabled)</mat-option>
<mat-option value="option3">Option 3</mat-option>
</mat-select>
</mat-form-field>
<h4>native html select</h4>
<mat-form-field>
<mat-label>Choose an option</mat-label>
<select matNativeControl [disabled]="disableSelect.value">
<option value="" selected></option>
<option value="volvo">Volvo</option>
<option value="saab" disabled>Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
</mat-form-field>
| {
"end_byte": 824,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/select/select-disabled/select-disabled-example.html"
} |
components/src/components-examples/material/icon/BUILD.bazel_0_1057 | load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "icon",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
assets = glob([
"**/*.html",
"**/*.css",
]),
deps = [
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/icon",
"//src/material/icon/testing",
"@npm//@angular/platform-browser",
"@npm//@types/jasmine",
],
)
filegroup(
name = "source-files",
srcs = glob([
"**/*.html",
"**/*.css",
"**/*.ts",
]),
)
ng_test_library(
name = "unit_tests_lib",
srcs = glob(["**/*.spec.ts"]),
deps = [
":icon",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/icon",
"//src/material/icon/testing",
"@npm//@angular/platform-browser",
],
)
ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
| {
"end_byte": 1057,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/icon/BUILD.bazel"
} |
components/src/components-examples/material/icon/index.ts_0_207 | export {IconOverviewExample} from './icon-overview/icon-overview-example';
export {IconSvgExample} from './icon-svg/icon-svg-example';
export {IconHarnessExample} from './icon-harness/icon-harness-example';
| {
"end_byte": 207,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/icon/index.ts"
} |
components/src/components-examples/material/icon/icon-harness/icon-harness-example.ts_0_377 | import {ChangeDetectionStrategy, Component} from '@angular/core';
import {MatIconModule} from '@angular/material/icon';
/**
* @title Testing with MatIconHarness
*/
@Component({
selector: 'icon-harness-example',
templateUrl: 'icon-harness-example.html',
imports: [MatIconModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconHarnessExample {}
| {
"end_byte": 377,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/icon/icon-harness/icon-harness-example.ts"
} |
components/src/components-examples/material/icon/icon-harness/icon-harness-example.html_0_213 | <mat-icon fontSet="fontIcons" fontIcon="fontIcon"></mat-icon>
<mat-icon svgIcon="svgIcons:svgIcon"></mat-icon>
<mat-icon inline>ligature_icon</mat-icon>
<mat-icon fontIcon="ligature_icon_by_attribute"></mat-icon>
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/icon/icon-harness/icon-harness-example.html"
} |
components/src/components-examples/material/icon/icon-harness/icon-harness-example.spec.ts_0_2159 | import {ComponentFixture, TestBed} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {HarnessLoader, parallel} from '@angular/cdk/testing';
import {IconHarnessExample} from './icon-harness-example';
import {MatIconModule, MatIconRegistry} from '@angular/material/icon';
import {MatIconHarness} from '@angular/material/icon/testing';
import {DomSanitizer} from '@angular/platform-browser';
describe('IconHarnessExample', () => {
let fixture: ComponentFixture<IconHarnessExample>;
let loader: HarnessLoader;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [MatIconModule],
});
const registry = TestBed.inject(MatIconRegistry);
const sanitizer = TestBed.inject(DomSanitizer);
// We use `bypassSecurityTrustHtml` exclusively for testing here.
registry.addSvgIconLiteralInNamespace(
'svgIcons',
'svgIcon',
sanitizer.bypassSecurityTrustHtml('<svg></svg>'),
);
fixture = TestBed.createComponent(IconHarnessExample);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
});
it('should load all icon harnesses', async () => {
const icons = await loader.getAllHarnesses(MatIconHarness);
expect(icons.length).toBe(4);
});
it('should get the name of an icon', async () => {
const icons = await loader.getAllHarnesses(MatIconHarness);
const names = await parallel(() => icons.map(icon => icon.getName()));
expect(names).toEqual(['fontIcon', 'svgIcon', 'ligature_icon', 'ligature_icon_by_attribute']);
});
it('should get the namespace of an icon', async () => {
const icons = await loader.getAllHarnesses(MatIconHarness);
const namespaces = await parallel(() => icons.map(icon => icon.getNamespace()));
expect(namespaces).toEqual(['fontIcons', 'svgIcons', null, null]);
});
it('should get whether an icon is inline', async () => {
const icons = await loader.getAllHarnesses(MatIconHarness);
const inlineStates = await parallel(() => icons.map(icon => icon.isInline()));
expect(inlineStates).toEqual([false, false, true, false]);
});
});
| {
"end_byte": 2159,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/icon/icon-harness/icon-harness-example.spec.ts"
} |
components/src/components-examples/material/icon/icon-overview/icon-overview-example.ts_0_364 | import {ChangeDetectionStrategy, Component} from '@angular/core';
import {MatIconModule} from '@angular/material/icon';
/**
* @title Basic icons
*/
@Component({
selector: 'icon-overview-example',
templateUrl: 'icon-overview-example.html',
imports: [MatIconModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconOverviewExample {}
| {
"end_byte": 364,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/icon/icon-overview/icon-overview-example.ts"
} |
components/src/components-examples/material/icon/icon-overview/icon-overview-example.html_0_89 | <mat-icon aria-hidden="false" aria-label="Example home icon" fontIcon="home"></mat-icon>
| {
"end_byte": 89,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/icon/icon-overview/icon-overview-example.html"
} |
components/src/components-examples/material/icon/icon-svg/icon-svg-example.ts_0_1308 | import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';
import {MatIconRegistry, MatIconModule} from '@angular/material/icon';
const THUMBUP_ICON =
`
<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M1 21h4V9H1v12zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.` +
`44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5` +
`1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-1.91l-.01-.01L23 10z"/>
</svg>
`;
/**
* @title SVG icons
*/
@Component({
selector: 'icon-svg-example',
templateUrl: 'icon-svg-example.html',
imports: [MatIconModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconSvgExample {
constructor() {
const iconRegistry = inject(MatIconRegistry);
const sanitizer = inject(DomSanitizer);
// Note that we provide the icon here as a string literal here due to a limitation in
// Stackblitz. If you want to provide the icon from a URL, you can use:
// `iconRegistry.addSvgIcon('thumbs-up', sanitizer.bypassSecurityTrustResourceUrl('icon.svg'));`
iconRegistry.addSvgIconLiteral('thumbs-up', sanitizer.bypassSecurityTrustHtml(THUMBUP_ICON));
}
}
| {
"end_byte": 1308,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/icon/icon-svg/icon-svg-example.ts"
} |
components/src/components-examples/material/icon/icon-svg/icon-svg-example.html_0_102 | <mat-icon svgIcon="thumbs-up" aria-hidden="false" aria-label="Example thumbs up SVG icon"></mat-icon>
| {
"end_byte": 102,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/icon/icon-svg/icon-svg-example.html"
} |
components/src/components-examples/material/snack-bar/BUILD.bazel_0_1217 | load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "snack-bar",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
assets = glob([
"**/*.html",
"**/*.css",
]),
deps = [
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/button",
"//src/material/input",
"//src/material/select",
"//src/material/snack-bar",
"//src/material/snack-bar/testing",
"@npm//@angular/forms",
"@npm//@angular/platform-browser",
"@npm//@types/jasmine",
],
)
filegroup(
name = "source-files",
srcs = glob([
"**/*.html",
"**/*.css",
"**/*.ts",
]),
)
ng_test_library(
name = "unit_tests_lib",
srcs = glob(["**/*.spec.ts"]),
deps = [
":snack-bar",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/snack-bar",
"//src/material/snack-bar/testing",
"@npm//@angular/platform-browser",
],
)
ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
| {
"end_byte": 1217,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/snack-bar/BUILD.bazel"
} |
components/src/components-examples/material/snack-bar/index.ts_0_542 | export {
PizzaPartyComponent,
SnackBarComponentExample,
} from './snack-bar-component/snack-bar-component-example';
export {
PizzaPartyAnnotatedComponent,
SnackBarAnnotatedComponentExample,
} from './snack-bar-annotated-component/snack-bar-annotated-component-example';
export {SnackBarOverviewExample} from './snack-bar-overview/snack-bar-overview-example';
export {SnackBarPositionExample} from './snack-bar-position/snack-bar-position-example';
export {SnackBarHarnessExample} from './snack-bar-harness/snack-bar-harness-example';
| {
"end_byte": 542,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/components-examples/material/snack-bar/index.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.