-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Combobox dev app #20276
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
Changes from all commits
6b43b7c
c89cb4d
fd65034
33032f9
9d9fdcf
357bfa7
df41e8b
081e970
89ff036
6fad24e
7b0e864
c4c72e6
b6be785
e496bc3
93966d9
9242faf
cfc9af5
7c1c731
3b89ac4
e13b571
77ba67d
09ab50d
e7b7189
a52c1a9
11587d6
a36b01e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.