Skip to content

Commit c37f2ad

Browse files
authored
Merge branch 'master' into cdk-selection-merge
2 parents f11158c + cb8de61 commit c37f2ad

File tree

80 files changed

+1885
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1885
-324
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ jobs:
440440
# The components examples package is not a release package, but we publish it
441441
# as part of this job to the docs-content repository. It's not contained in the
442442
# attached release output, so we need to build it here.
443-
- run: bazel build src/components-examples:npm_package --config=snapshot-build
443+
- run: yarn build-docs-content
444444

445445
# Ensures that we do not push the snapshot artifacts upstream until all previous
446446
# snapshot build jobs have completed. This helps avoiding conflicts when multiple

CODE_REVIEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
* Links to any relevant issues.
1313
* Screenshots (for visual changes or new additions)
1414
2. Reviews provide comments and the author responds / makes changes. Repeat until LGTM.
15-
3. One or more of the reviewers applies the "LGTM" label.
16-
4. Once the LGTM label is applied, either the author or the reviewer can add the "merge-ready"
15+
3. One or more of the reviewers approve the pull request.
16+
4. Once the PR is approved, either the author or the reviewer can add the "merge-ready"
1717
label to indicate that the PR is ready to be merged.
1818
5. The party responsible for merging PRs will do so.
1919

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"scripts": {
1616
"postinstall": "node tools/postinstall/apply-patches.js && ngcc --properties module main --create-ivy-entry-points && node tools/postinstall/update-ngcc-main-fields.js",
1717
"build": "node ./scripts/build-packages-dist.js",
18+
"build-docs-content": "node ./scripts/build-docs-content.js",
1819
"dev-app": "ibazel run //src/dev-app:devserver",
1920
"test": "node ./scripts/run-component-tests.js",
2021
"test-local": "yarn -s test --local",

scripts/build-docs-content.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script that builds the docs content NPM package and moves it into an conveniently
5+
* accessible distribution directory (the project `dist/` directory).
6+
*/
7+
8+
const {join} = require('path');
9+
const {chmod, cd, cp, mkdir, rm, set, exec} = require('shelljs');
10+
11+
/** Path to the project directory. */
12+
const projectDir = join(__dirname, '../');
13+
14+
/** Path to the distribution directory. */
15+
const distDir = join(projectDir, 'dist/');
16+
17+
/**
18+
* Path to the directory where the docs-content package is copied to. Note: When
19+
* changing the path, also change the path in the docs-content deploy script.
20+
*/
21+
const outputDir = join(distDir, 'docs-content-pkg');
22+
23+
/** Command that runs Bazel. */
24+
const bazelCmd = process.env.BAZEL_COMMAND || `yarn -s bazel`;
25+
26+
// ShellJS should exit if a command fails.
27+
set('-e');
28+
29+
// Go to project directory.
30+
cd(projectDir);
31+
32+
/** Path to the bazel bin output directory. */
33+
const bazelBinPath = exec(`${bazelCmd} info bazel-bin`).stdout.trim();
34+
35+
/** Path where the NPM package is built into by Bazel. */
36+
const bazelBinOutDir = join(bazelBinPath, 'src/components-examples/npm_package');
37+
38+
// Build the docs-content package with the snapshot-build mode. That will help
39+
// determining which commit is associated with the built docs-content.
40+
exec(`${bazelCmd} build src/components-examples:npm_package --config=snapshot-build`);
41+
42+
// Clean the output directory to ensure that the docs-content package
43+
// will not contain outdated files from previous builds.
44+
rm('-rf', outputDir);
45+
mkdir('-p', distDir);
46+
47+
// Copy the package output into the dist path. Also update the permissions
48+
// as Bazel by default marks files in the bazel-out as readonly.
49+
cp('-R', bazelBinOutDir, outputDir);
50+
chmod('-R', 'u+w', outputDir);
51+
52+
console.info(`Built docs-content into: ${outputDir}`);

scripts/deploy/publish-docs-content.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ docsDistPath="${projectPath}/dist/docs"
2323
# Path to the cloned docs-content repository.
2424
docsContentPath="${projectPath}/tmp/material2-docs-content"
2525

26-
# Path to the release output of the Bazel "@angular/components-examples" NPM package.
27-
examplesPackagePath="$(bazel info bazel-bin)/src/components-examples/npm_package"
26+
# Path to the build output of the Bazel "@angular/components-examples" NPM package.
27+
# Note: When changing this, also change the path in `scripts/build-docs-content.js`.
28+
examplesPackagePath="${projectPath}/dist/docs-content-pkg/"
2829

2930
# Git clone URL for the material2-docs-content repository.
3031
docsContentRepoUrl="https://github.com/angular/material2-docs-content"

src/cdk-experimental/column-resize/resizable.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,15 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
9494
}
9595

9696
ngAfterViewInit() {
97-
this._viewInitialized = true;
98-
9997
this._listenForRowHoverEvents();
10098
this._listenForResizeEvents();
10199
this._appendInlineHandle();
102-
this._applyMinWidthPx();
103-
this._applyMaxWidthPx();
100+
101+
this.styleScheduler.scheduleEnd(() => {
102+
this._viewInitialized = true;
103+
this._applyMinWidthPx();
104+
this._applyMaxWidthPx();
105+
});
104106
}
105107

106108
ngOnDestroy(): void {

src/cdk-experimental/combobox/BUILD.bazel

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//tools:defaults.bzl", "ng_module")
1+
load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
22

33
package(default_visibility = ["//visibility:public"])
44

@@ -9,4 +9,28 @@ ng_module(
99
exclude = ["**/*.spec.ts"],
1010
),
1111
module_name = "@angular/cdk-experimental/combobox",
12+
deps = [
13+
"//src/cdk/a11y",
14+
"//src/cdk/bidi",
15+
"//src/cdk/collections",
16+
"//src/cdk/overlay",
17+
],
18+
)
19+
20+
ng_test_library(
21+
name = "unit_test_sources",
22+
srcs = glob(
23+
["**/*.spec.ts"],
24+
exclude = ["**/*.e2e.spec.ts"],
25+
),
26+
deps = [
27+
":combobox",
28+
"//src/cdk/testing/private",
29+
"@npm//@angular/platform-browser",
30+
],
31+
)
32+
33+
ng_web_test_suite(
34+
name = "unit_tests",
35+
deps = [":unit_test_sources"],
1236
)

src/cdk-experimental/combobox/combobox-module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
*/
88

99
import {NgModule} from '@angular/core';
10+
import {OverlayModule} from '@angular/cdk/overlay';
1011
import {CdkCombobox} from './combobox';
1112
import {CdkComboboxPanel} from './combobox-panel';
1213

1314
const EXPORTED_DECLARATIONS = [CdkCombobox, CdkComboboxPanel];
1415
@NgModule({
16+
imports: [OverlayModule],
1517
exports: EXPORTED_DECLARATIONS,
1618
declarations: EXPORTED_DECLARATIONS,
1719
})

src/cdk-experimental/combobox/combobox-panel.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,40 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Directive} from '@angular/core';
9+
export type AriaHasPopupValue = 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
10+
11+
import {Directive, TemplateRef} from '@angular/core';
12+
import {Subject} from 'rxjs';
1013

1114
@Directive({
1215
selector: 'ng-template[cdkComboboxPanel]',
1316
exportAs: 'cdkComboboxPanel',
1417
})
1518
export class CdkComboboxPanel<T = unknown> {
1619

20+
valueUpdated: Subject<T> = new Subject<T>();
21+
contentIdUpdated: Subject<string> = new Subject<string>();
22+
contentTypeUpdated: Subject<AriaHasPopupValue> = new Subject<AriaHasPopupValue>();
23+
24+
contentId: string = '';
25+
contentType: AriaHasPopupValue;
26+
27+
constructor(readonly _templateRef: TemplateRef<unknown>) {}
28+
29+
/** Tells the parent combobox to closet he panel and sends back the content value. */
30+
closePanel(data?: T) {
31+
this.valueUpdated.next(data);
32+
}
33+
34+
/** Registers the content's id and the content type with the panel. */
35+
_registerContent(contentId: string, contentType: AriaHasPopupValue) {
36+
this.contentId = contentId;
37+
if (contentType !== 'listbox' && contentType !== 'dialog') {
38+
throw Error('CdkComboboxPanel currently only supports listbox or dialog content.');
39+
}
40+
this.contentType = contentType;
41+
42+
this.contentIdUpdated.next(this.contentId);
43+
this.contentTypeUpdated.next(this.contentType);
44+
}
1745
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import {Component, DebugElement} from '@angular/core';
2+
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
3+
import {By} from '@angular/platform-browser';
4+
import {CdkComboboxModule} from './combobox-module';
5+
import {CdkCombobox} from './combobox';
6+
import {dispatchMouseEvent} from '@angular/cdk/testing/private';
7+
8+
describe('Combobox', () => {
9+
describe('with a basic toggle trigger', () => {
10+
let fixture: ComponentFixture<ComboboxToggle>;
11+
12+
let combobox: DebugElement;
13+
let comboboxInstance: CdkCombobox<unknown>;
14+
let comboboxElement: HTMLElement;
15+
16+
beforeEach(async(() => {
17+
TestBed.configureTestingModule({
18+
imports: [CdkComboboxModule],
19+
declarations: [ComboboxToggle],
20+
}).compileComponents();
21+
}));
22+
23+
beforeEach(() => {
24+
fixture = TestBed.createComponent(ComboboxToggle);
25+
fixture.detectChanges();
26+
27+
combobox = fixture.debugElement.query(By.directive(CdkCombobox));
28+
comboboxInstance = combobox.injector.get<CdkCombobox<unknown>>(CdkCombobox);
29+
comboboxElement = combobox.nativeElement;
30+
});
31+
32+
it('should have the combobox role', () => {
33+
expect(comboboxElement.getAttribute('role')).toBe('combobox');
34+
});
35+
36+
it('should update the aria disabled attribute', () => {
37+
comboboxInstance.disabled = true;
38+
fixture.detectChanges();
39+
40+
expect(comboboxElement.getAttribute('aria-disabled')).toBe('true');
41+
42+
comboboxInstance.disabled = false;
43+
fixture.detectChanges();
44+
45+
expect(comboboxElement.getAttribute('aria-disabled')).toBe('false');
46+
});
47+
48+
it('should have a panel that is closed by default', () => {
49+
expect(comboboxInstance.hasPanel()).toBeTrue();
50+
expect(comboboxInstance.isOpen()).toBeFalse();
51+
});
52+
53+
it('should have an open action of click by default', () => {
54+
expect(comboboxInstance.isOpen()).toBeFalse();
55+
56+
dispatchMouseEvent(comboboxElement, 'click');
57+
fixture.detectChanges();
58+
59+
expect(comboboxInstance.isOpen()).toBeTrue();
60+
});
61+
62+
it('should not open panel when disabled', () => {
63+
expect(comboboxInstance.isOpen()).toBeFalse();
64+
comboboxInstance.disabled = true;
65+
fixture.detectChanges();
66+
67+
dispatchMouseEvent(comboboxElement, 'click');
68+
fixture.detectChanges();
69+
70+
expect(comboboxInstance.isOpen()).toBeFalse();
71+
});
72+
});
73+
74+
});
75+
76+
@Component({
77+
template: `
78+
<button cdkCombobox #toggleCombobox class="example-combobox"
79+
[cdkComboboxTriggerFor]="panel"
80+
[openAction]="'focus'">
81+
No Value
82+
</button>
83+
84+
<ng-template cdkComboboxPanel #panel="cdkComboboxPanel">
85+
Panel Content
86+
</ng-template>`,
87+
})
88+
class ComboboxToggle {
89+
}

0 commit comments

Comments
 (0)