Skip to content

Commit

Permalink
chore: tooltip add animation
Browse files Browse the repository at this point in the history
  • Loading branch information
igauch committed Apr 13, 2023
1 parent 2e27870 commit 102d6b3
Show file tree
Hide file tree
Showing 18 changed files with 191 additions and 81 deletions.
20 changes: 10 additions & 10 deletions src/autocomplete/autocomplete.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ export class AutoCompleteDirective
declare innerSelector: string;

@Output('auiAutocompleteShow')
override show = new EventEmitter<void>();
override showed = new EventEmitter<void>();

@Output('auiAutocompleteHide')
override hide = new EventEmitter<void>();
override hided = new EventEmitter<void>();

@Output('auiAutocompleteSelected')
selected = new EventEmitter<string>();
Expand Down Expand Up @@ -135,10 +135,10 @@ export class AutoCompleteDirective
}

ngOnInit() {
this.show.subscribe(() => {
this.showed.subscribe(() => {
this.updateSuggestionsContext();
});
this.hide.subscribe(() => {
this.hided.subscribe(() => {
this.resetFocusedSuggestion();
});

Expand Down Expand Up @@ -196,7 +196,7 @@ export class AutoCompleteDirective
onInput(event: Event) {
const value = (event.target as HTMLInputElement).value;
this.inputValue$$.next(value);
this.createTooltip();
this.show();
}

onKeyDown(event: KeyboardEvent) {
Expand All @@ -219,7 +219,7 @@ export class AutoCompleteDirective
}
break;
case 'Escape':
this.disposeTooltip();
this.hide();
event.stopPropagation();
event.preventDefault();
break;
Expand Down Expand Up @@ -249,11 +249,11 @@ export class AutoCompleteDirective
this.inputValue$$.next(isArrCtrl ? '' : value);

this.selected.emit(value);
this.disposeTooltip();
this.hide();
}

override createTooltip() {
super.createTooltip();
override show() {
super.show();
this.autoFocusFirstSuggestion();
}

Expand Down Expand Up @@ -281,7 +281,7 @@ export class AutoCompleteDirective

private focusSuggestionDir(dir: 'down' | 'up') {
if (!this.isCreated) {
this.createTooltip();
this.show();
return;
}
const visibleSuggestions = this.autocomplete.suggestions.filter(
Expand Down
3 changes: 2 additions & 1 deletion src/autocomplete/autocomplete.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { OverlayModule } from '@angular/cdk/overlay';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { TooltipModule } from '../tooltip';

Expand All @@ -15,7 +16,7 @@ import { SuggestionGroupComponent } from './suggestion-group/suggestion-group.co
import { SuggestionComponent } from './suggestion/suggestion.component';

@NgModule({
imports: [CommonModule, OverlayModule, TooltipModule],
imports: [CommonModule, OverlayModule, TooltipModule, NoopAnimationsModule],
declarations: [
AutoCompleteDirective,
CustomAutoCompleteDirective,
Expand Down
2 changes: 1 addition & 1 deletion src/date-picker/date-picker/date-picker.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
[maxDate]="maxDate"
(click)="$event.stopImmediatePropagation()"
(clear)="clearValue()"
(confirm)="tooltip.disposeTooltip(); emitValue(value)"
(confirm)="tooltip.hide(); emitValue(value)"
></aui-date-picker-panel>
</ng-template>
2 changes: 1 addition & 1 deletion src/date-picker/range-picker/range-picker.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
[maxDate]="maxDate"
(click)="$event.stopImmediatePropagation()"
(clear)="clearValue()"
(confirm)="tooltip.disposeTooltip(); emitValue(value)"
(confirm)="tooltip.hide(); emitValue(value)"
></aui-date-range-picker-panel>
</ng-template>
8 changes: 4 additions & 4 deletions src/dropdown/dropdown.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export class DropdownDirective extends BaseTooltip implements OnInit {
override hideOnClick = true;

@Output('auiDropdownShow')
override show = new EventEmitter<void>();
override showed = new EventEmitter<void>();

@Output('auiDropdownHide')
override hide = new EventEmitter<void>();
override hided = new EventEmitter<void>();

private _menu: MenuComponent;

Expand All @@ -78,14 +78,14 @@ export class DropdownDirective extends BaseTooltip implements OnInit {
}

ngOnInit() {
this.show.pipe(debounceTime(0)).subscribe(() => {
this.showed.pipe(debounceTime(0)).subscribe(() => {
if (this.menu.lazyContent) {
this.menu.lazyContent.attach(this.lazyContentContext);
this.updatePosition();
}
});

this.hide.subscribe(() => {
this.hided.subscribe(() => {
if (this.menu.lazyContent) {
this.menu.lazyContent.detach();
}
Expand Down
9 changes: 8 additions & 1 deletion src/dropdown/dropdown.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { ButtonModule } from '../button';
import { IconModule } from '../icon';
Expand All @@ -16,7 +17,13 @@ import { MenuComponent } from './menu/menu.component';
import { SubmenuComponent } from './submenu/submenu.component';

@NgModule({
imports: [CommonModule, TooltipModule, IconModule, ButtonModule],
imports: [
CommonModule,
TooltipModule,
IconModule,
ButtonModule,
NoopAnimationsModule,
],
declarations: [
DropdownDirective,
DropdownActiveDirective,
Expand Down
4 changes: 2 additions & 2 deletions src/select/base-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ export abstract class BaseSelect<T, V = T>
}

openOption() {
this.tooltipRef.createTooltip();
this.tooltipRef.show();
}

closeOption() {
this.tooltipRef.disposeTooltip();
this.tooltipRef.hide();
}

onShowOptions() {
Expand Down
4 changes: 2 additions & 2 deletions src/time-picker/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ export class TimePickerComponent extends CommonFormControl<
if (this.tooltipRef.isCreated) {
return;
}
this.tooltipRef.createTooltip();
this.tooltipRef.show();
this.open.next();
}

closePanel() {
if (!this.tooltipRef.isCreated) {
return;
}
this.tooltipRef.disposeTooltip();
this.tooltipRef.hide();
this.close.next();
}

Expand Down
Loading

0 comments on commit 102d6b3

Please sign in to comment.