This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(combobox): Added experimental combobox component.
- Loading branch information
Showing
47 changed files
with
1,545 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,6 @@ Thumbs.db | |
|
||
.now | ||
|
||
|
||
# bazel | ||
bazel-* | ||
.bazelrc.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
apps/components-e2e/src/components/combobox/combobox.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Dynatrace LLC | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
fixture('Combobox').page('http://localhost:4200/combobox'); | ||
|
||
// test('should execute click handlers when not disabled', async (testController: TestController) => { | ||
// await testController.click(button); | ||
// | ||
// const count = await clickCounter.textContent; | ||
// await testController.expect(count).eql('1'); | ||
// }); | ||
// | ||
// test('should not execute click handlers when disabled', async (testController: TestController) => { | ||
// await testController.click(disableButton); | ||
// | ||
// await testController.expect(button.hasAttribute('disabled')).ok(); | ||
// | ||
// await testController.click(button); | ||
// await testController.expect(await clickCounter.textContent).eql('0'); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<section> | ||
<!-- TODO ChMa: write test --> | ||
</section> |
31 changes: 31 additions & 0 deletions
31
apps/components-e2e/src/components/combobox/combobox.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Dynatrace LLC | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { Route, RouterModule } from '@angular/router'; | ||
import { DtE2ECombobox } from './combobox'; | ||
import { DtComboboxModule } from '@dynatrace/barista-components/experimental/combobox'; | ||
|
||
const routes: Route[] = [{ path: '', component: DtE2ECombobox }]; | ||
|
||
@NgModule({ | ||
declarations: [DtE2ECombobox], | ||
imports: [CommonModule, RouterModule.forChild(routes), DtComboboxModule], | ||
exports: [], | ||
providers: [], | ||
}) | ||
export class DtE2EComboboxModule {} |
19 changes: 19 additions & 0 deletions
19
apps/components-e2e/src/components/combobox/combobox.po.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Dynatrace LLC | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Selector } from 'testcafe'; | ||
|
||
export const combobox = Selector('#test-combobox'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Dynatrace LLC | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'dt-e2e-combobox', | ||
templateUrl: 'combobox.html', | ||
}) | ||
export class DtE2ECombobox {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<dt-combobox | ||
placeholder="Start typing or open dropdown for top list" | ||
aria-label="A simple combobox example" | ||
panelClass="my-demo-overlay-class" | ||
[value]="_initialValue" | ||
[loading]="_loading" | ||
[displayWith]="_displayWith" | ||
(openedChange)="openedChanged($event)" | ||
(valueChange)="valueChanged($event)" | ||
(filterChange)="filterChanged($event)" | ||
> | ||
<dt-option *ngFor="let option of _options" [value]="option"> | ||
{{ option.name }} | ||
</dt-option> | ||
</dt-combobox> | ||
<dt-select placeholder="Start typing or open dropdown for top list"> | ||
<dt-option value="1"> | ||
Value 1 | ||
</dt-option> | ||
<dt-option value="2"> | ||
Value 2 | ||
</dt-option> | ||
</dt-select> | ||
|
||
<p> | ||
Selected Value: | ||
<em>{{ selectedValue || 'No value selected' }}</em> | ||
</p> | ||
<dt-combobox | ||
placeholder="Choose your coffee" | ||
[(ngModel)]="selectedValue" | ||
aria-label="Choose your coffee" | ||
> | ||
<dt-option *ngFor="let coffee of coffees" [value]="coffee.value"> | ||
{{ coffee.viewValue }} | ||
</dt-option> | ||
</dt-combobox> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Dynatrace LLC | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { | ||
ChangeDetectionStrategy, | ||
ChangeDetectorRef, | ||
Component, | ||
ViewChild, | ||
AfterViewInit, | ||
} from '@angular/core'; | ||
import { take } from 'rxjs/operators'; | ||
import { timer } from 'rxjs'; | ||
import { DtCombobox } from '@dynatrace/barista-components/experimental/combobox'; | ||
|
||
const allOptions: { name: string; value: string }[] = [ | ||
{ name: 'Value 1', value: '[value: Value 1]' }, | ||
{ name: 'Value 2', value: '[value: Value 2]' }, | ||
{ name: 'Value 3', value: '[value: Value 3]' }, | ||
{ name: 'Value 4', value: '[value: Value 4]' }, | ||
]; | ||
|
||
@Component({ | ||
selector: 'combobox-dev-app-demo', | ||
templateUrl: 'combobox-demo.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ComboboxDemo implements AfterViewInit { | ||
@ViewChild(DtCombobox) combobox: DtCombobox<any>; | ||
|
||
_initialValue = allOptions[0]; | ||
_options = [...allOptions]; | ||
_loading = false; | ||
_displayWith = (option: { name: string; value: string }) => option.name; | ||
|
||
constructor(private _changeDetectorRef: ChangeDetectorRef) {} | ||
|
||
ngAfterViewInit(): void { | ||
this.combobox.selectionChange.subscribe((val) => { | ||
console.log(val); | ||
}); | ||
} | ||
|
||
openedChanged(event: boolean): void { | ||
console.log(`openedChanged: '${event}'`); | ||
} | ||
|
||
valueChanged(event: string): void { | ||
console.log(`valueChanged: '${event}'`); | ||
} | ||
|
||
filterChanged(event: string): void { | ||
console.log(`filterChanged: '${event}'`); | ||
|
||
this._loading = true; | ||
this._changeDetectorRef.markForCheck(); | ||
|
||
timer(1500) | ||
.pipe(take(1)) | ||
.subscribe(() => { | ||
this._options = allOptions.filter( | ||
(option) => | ||
option.value.toLowerCase().indexOf(event.toLowerCase()) >= 0, | ||
); | ||
this._loading = false; | ||
this._changeDetectorRef.markForCheck(); | ||
}); | ||
} | ||
|
||
selectedValue: string; | ||
coffees = [ | ||
{ value: 'ThePerfectPour', viewValue: 'ThePerfectPour' }, | ||
{ value: 'Affogato', viewValue: 'Affogato' }, | ||
{ value: 'Americano', viewValue: 'Americano' }, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.