Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combobox dev app #20276

Merged
merged 26 commits into from Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6b43b7c
build: Added required files to listbox directory.
nielsr98 Jun 11, 2020
c89cb4d
build: added listbox option directive and renamed listbox directive f…
nielsr98 Jun 11, 2020
fd65034
build: Added required files to listbox directory.
nielsr98 Jun 11, 2020
33032f9
build: added listbox option directive and renamed listbox directive f…
nielsr98 Jun 11, 2020
9d9fdcf
build: Added required files to listbox directory.
nielsr98 Jun 11, 2020
357bfa7
build: added listbox option directive and renamed listbox directive f…
nielsr98 Jun 11, 2020
df41e8b
build: Added required files to listbox directory.
nielsr98 Jun 11, 2020
081e970
build: added listbox option directive and renamed listbox directive f…
nielsr98 Jun 11, 2020
89ff036
feat(dev-app/listbox): added cdk listbox example to the dev-app.
nielsr98 Jul 15, 2020
6fad24e
fix(listbox): removed duplicate dep in dev-app build file.
nielsr98 Jul 22, 2020
7b0e864
fix(listbox): deleted unused files.
nielsr98 Aug 4, 2020
c4c72e6
feat(combobox): added all basic features to combobox and combobox pan…
nielsr98 Aug 6, 2020
b6be785
fix(combobox): fixed import path for combobox panel.
nielsr98 Aug 6, 2020
e496bc3
refactor(combobox): changed names and made coerceOpenActionProperty s…
nielsr98 Aug 10, 2020
93966d9
fix(combobox): updated syntax for casting.
nielsr98 Aug 10, 2020
9242faf
refactor(combobox): changed casting syntax back.
nielsr98 Aug 10, 2020
cfc9af5
fix(combobox): fixed trailing whitespace.
nielsr98 Aug 10, 2020
7c1c731
feat(combobox): added combobox to dev app.
nielsr98 Aug 12, 2020
3b89ac4
refactor(combobox): removed commented out import and fixed the name o…
nielsr98 Aug 12, 2020
e13b571
fix(combobox): removed duplicate import.
nielsr98 Aug 12, 2020
77ba67d
nit(combobox): removed console logs.
nielsr98 Aug 12, 2020
09ab50d
refactor(combobox): removed unused panel test file.
nielsr98 Aug 12, 2020
e7b7189
refactor(combobox): used lightweight injection token for grabbing par…
nielsr98 Aug 12, 2020
a52c1a9
nit(combobox): formatted build file.
nielsr98 Aug 12, 2020
11587d6
refactor(combobox): removed unused imports and fixed long line length.
nielsr98 Aug 12, 2020
a36b01e
refactor(combobox): reduced the functions of the panel directive and …
nielsr98 Aug 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -146,6 +146,7 @@
/src/dev-app/button-toggle/** @jelbourn
/src/dev-app/button/** @jelbourn
/src/dev-app/card/** @jelbourn
/src/dev-app/cdk-experimental-combobox/** @jelbourn @nielsr98
/src/dev-app/cdk-experimental-listbox/** @jelbourn @nielsr98
/src/dev-app/cdk-experimental-menu/** @jelbourn @andy9775
/src/dev-app/checkbox/** @jelbourn @devversion
Expand Down
2 changes: 1 addition & 1 deletion src/cdk-experimental/combobox/combobox.spec.ts
Expand Up @@ -77,7 +77,7 @@ describe('Combobox', () => {
template: `
<button cdkCombobox #toggleCombobox class="example-combobox"
[cdkComboboxTriggerFor]="panel"
[openAction]="'focus'">
[openActions]="'focus'">
No Value
</button>

Expand Down
13 changes: 10 additions & 3 deletions src/cdk-experimental/combobox/combobox.ts
Expand Up @@ -58,10 +58,10 @@ export class CdkCombobox<T = unknown> implements OnDestroy, AfterContentInit {
private _disabled: boolean = false;

@Input()
get openAction(): OpenAction[] {
get openActions(): OpenAction[] {
return this._openActions;
}
set openAction(action: OpenAction[]) {
set openActions(action: OpenAction[]) {
this._openActions = this._coerceOpenActionProperty(action);
}
private _openActions: OpenAction[] = ['click'];
Expand Down Expand Up @@ -143,6 +143,13 @@ export class CdkCombobox<T = unknown> implements OnDestroy, AfterContentInit {

if (valueChanged) {
this.panelValueChanged.emit(value);
this._setTextContent(value);
}
}

private _setTextContent(content: T) {
if (typeof content === 'string') {
nielsr98 marked this conversation as resolved.
Show resolved Hide resolved
this._elementRef.nativeElement.textContent = `${content}`;
}
}

Expand Down Expand Up @@ -189,6 +196,6 @@ export class CdkCombobox<T = unknown> implements OnDestroy, AfterContentInit {
return actions;
}

static ngAcceptInputType_disabled: BooleanInput;
static ngAcceptInputType_openActions: OpenActionInput;
static ngAcceptInputType_disabled: BooleanInput;
}
1 change: 1 addition & 0 deletions src/dev-app/BUILD.bazel
Expand Up @@ -23,6 +23,7 @@ ng_module(
"//src/dev-app/button",
"//src/dev-app/button-toggle",
"//src/dev-app/card",
"//src/dev-app/cdk-experimental-combobox",
"//src/dev-app/cdk-experimental-listbox",
"//src/dev-app/cdk-experimental-menu",
"//src/dev-app/checkbox",
Expand Down
15 changes: 15 additions & 0 deletions src/dev-app/cdk-experimental-combobox/BUILD.bazel
@@ -0,0 +1,15 @@
load("//tools:defaults.bzl", "ng_module")

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

ng_module(
name = "cdk-experimental-combobox",
srcs = glob(["**/*.ts"]),
assets = [
"cdk-combobox-demo.html",
],
deps = [
"//src/cdk-experimental/combobox",
"@npm//@angular/router",
],
)
24 changes: 24 additions & 0 deletions src/dev-app/cdk-experimental-combobox/cdk-combobox-demo-module.ts
@@ -0,0 +1,24 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule} from '@angular/router';
import {CdkComboboxModule} from '@angular/cdk-experimental/combobox';
import {CdkComboboxDemo} from './cdk-combobox-demo';
import {PanelContent} from './panel-content';

@NgModule({
imports: [
CdkComboboxModule,
CommonModule,
RouterModule.forChild([{path: '', component: CdkComboboxDemo}]),
],
declarations: [CdkComboboxDemo, PanelContent],
})
export class CdkComboboxDemoModule {}
12 changes: 12 additions & 0 deletions src/dev-app/cdk-experimental-combobox/cdk-combobox-demo.html
@@ -0,0 +1,12 @@
Toggle Combobox!
<br>
<button cdkCombobox class="example-combobox" [cdkComboboxTriggerFor]="panel" [openActions]="'toggle'">
No Value
</button>

<ng-template cdkComboboxPanel #panel="cdkComboboxPanel">
<div panelContent [parentPanel]="panel">
<input #input>
<button (click)="panel.closePanel(input.value)">Apply</button>
</div>
</ng-template>
15 changes: 15 additions & 0 deletions src/dev-app/cdk-experimental-combobox/cdk-combobox-demo.ts
@@ -0,0 +1,15 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {Component} from '@angular/core';

@Component({
templateUrl: 'cdk-combobox-demo.html',
})
export class CdkComboboxDemo {
}
46 changes: 46 additions & 0 deletions src/dev-app/cdk-experimental-combobox/panel-content.ts
@@ -0,0 +1,46 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {Directive, Inject, InjectionToken, Input, OnInit, Optional} from '@angular/core';
import {AriaHasPopupValue, CdkComboboxPanel} from '@angular/cdk-experimental/combobox';

export const PANEL = new InjectionToken<CdkComboboxPanel>('CdkComboboxPanel');

let id = 0;

@Directive({
selector: '[panelContent]',
exportAs: 'panelContent',
host: {
'role': 'role',
'[id]': 'dialogId'
}
})
export class PanelContent<V> implements OnInit {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just for testing, or do you intend for this to be the ultimate API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this directive is just for testing/demo purposes. It is the directive that is applied to the custom panel content the user wishes to use, like their own dialog. It handles registering the content with the panel. I did realize it was doing more than I needed it to do in this example so I've toned it down.


dialogId = `dialog-${id++}`;
role = 'dialog';

@Input('parentPanel') private readonly _explicitPanel: CdkComboboxPanel;

constructor(
@Optional() @Inject(PANEL) readonly _parentPanel?: CdkComboboxPanel<V>,
) { }

ngOnInit() {
this.registerWithPanel();
}

registerWithPanel(): void {
if (this._parentPanel === null || this._parentPanel === undefined) {
this._explicitPanel._registerContent(this.dialogId, this.role as AriaHasPopupValue);
} else {
this._parentPanel._registerContent(this.dialogId, this.role as AriaHasPopupValue);
}
}
}
1 change: 1 addition & 0 deletions src/dev-app/dev-app/dev-app-layout.ts
Expand Up @@ -33,6 +33,7 @@ export class DevAppLayout {
{name: 'Button Toggle', route: '/button-toggle'},
{name: 'Button', route: '/button'},
{name: 'Card', route: '/card'},
{name: 'Cdk Experimental Combobox', route: '/cdk-experimental-combobox'},
{name: 'Cdk Experimental Listbox', route: '/cdk-experimental-listbox'},
{name: 'Cdk Experimental Menu', route: '/cdk-experimental-menu'},
{name: 'Checkbox', route: '/checkbox'},
Expand Down
4 changes: 4 additions & 0 deletions src/dev-app/dev-app/routes.ts
Expand Up @@ -28,6 +28,10 @@ export const DEV_APP_ROUTES: Routes = [
loadChildren: 'button-toggle/button-toggle-demo-module#ButtonToggleDemoModule'
},
{path: 'card', loadChildren: 'card/card-demo-module#CardDemoModule'},
{
path: 'cdk-experimental-combobox',
loadChildren: 'cdk-experimental-combobox/cdk-combobox-demo-module#CdkComboboxDemoModule'
},
{
path: 'cdk-experimental-listbox',
loadChildren: 'cdk-experimental-listbox/cdk-listbox-demo-module#CdkListboxDemoModule'
Expand Down