|
|
@@ -1,18 +1,9 @@
|
|
|
-import {
|
|
|
- ConnectedPosition,
|
|
|
- HorizontalConnectionPos,
|
|
|
- Overlay,
|
|
|
- OverlayRef,
|
|
|
- PositionStrategy,
|
|
|
- VerticalConnectionPos,
|
|
|
-} from '@angular/cdk/overlay';
|
|
|
+import { ConnectedPosition, Overlay, OverlayRef, PositionStrategy } from '@angular/cdk/overlay';
|
|
|
import { TemplatePortal } from '@angular/cdk/portal';
|
|
|
import {
|
|
|
AfterViewInit,
|
|
|
ChangeDetectionStrategy,
|
|
|
Component,
|
|
|
- ContentChild,
|
|
|
- ElementRef,
|
|
|
HostListener,
|
|
|
Input,
|
|
|
OnDestroy,
|
|
|
@@ -23,7 +14,10 @@ import {
|
|
|
} from '@angular/core';
|
|
|
import { Subscription } from 'rxjs';
|
|
|
|
|
|
-import { DropdownTriggerDirective } from './dropdown-trigger.directive';
|
|
|
+import {
|
|
|
+ LocalizationDirectionType,
|
|
|
+ LocalizationService,
|
|
|
+} from '../../../providers/localization/localization.service';
|
|
|
import { DropdownComponent } from './dropdown.component';
|
|
|
|
|
|
export type DropdownPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
|
@@ -41,14 +35,16 @@ export type DropdownPosition = 'top-left' | 'top-right' | 'bottom-left' | 'botto
|
|
|
selector: 'vdr-dropdown-menu',
|
|
|
template: `
|
|
|
<ng-template #menu>
|
|
|
- <div class="dropdown open">
|
|
|
- <div class="dropdown-menu" [ngClass]="customClasses">
|
|
|
- <div
|
|
|
- class="dropdown-content-wrapper"
|
|
|
- [cdkTrapFocus]="true"
|
|
|
- [cdkTrapFocusAutoCapture]="true"
|
|
|
- >
|
|
|
- <ng-content></ng-content>
|
|
|
+ <div [dir]="direction$ | async">
|
|
|
+ <div class="dropdown open">
|
|
|
+ <div class="dropdown-menu" [ngClass]="customClasses">
|
|
|
+ <div
|
|
|
+ class="dropdown-content-wrapper"
|
|
|
+ [cdkTrapFocus]="true"
|
|
|
+ [cdkTrapFocusAutoCapture]="true"
|
|
|
+ >
|
|
|
+ <ng-content></ng-content>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -58,6 +54,8 @@ export type DropdownPosition = 'top-left' | 'top-right' | 'bottom-left' | 'botto
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
|
})
|
|
|
export class DropdownMenuComponent implements AfterViewInit, OnInit, OnDestroy {
|
|
|
+ direction$: LocalizationDirectionType;
|
|
|
+
|
|
|
@Input('vdrPosition') private position: DropdownPosition = 'bottom-left';
|
|
|
@Input() customClasses: string;
|
|
|
@ViewChild('menu', { static: true }) private menuTemplate: TemplateRef<any>;
|
|
|
@@ -104,9 +102,12 @@ export class DropdownMenuComponent implements AfterViewInit, OnInit, OnDestroy {
|
|
|
private overlay: Overlay,
|
|
|
private viewContainerRef: ViewContainerRef,
|
|
|
private dropdown: DropdownComponent,
|
|
|
+ private localizationService: LocalizationService,
|
|
|
) {}
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
+ this.direction$ = this.localizationService.direction$;
|
|
|
+
|
|
|
this.dropdown.onOpenChange(isOpen => {
|
|
|
if (isOpen) {
|
|
|
this.overlayRef.attach(this.menuPortal);
|