ngx-mat-slide-panel
Version:
166 lines (158 loc) • 8 kB
TypeScript
import * as i2 from '@angular/cdk/overlay';
import { ScrollStrategy, OverlayRef, Overlay } from '@angular/cdk/overlay';
import * as i4 from '@angular/cdk/portal';
import { PortalOutlet, CdkPortalOutlet, ComponentPortal, TemplatePortal, ComponentType } from '@angular/cdk/portal';
import * as i0 from '@angular/core';
import { ViewContainerRef, InjectionToken, OnDestroy, EventEmitter, ElementRef, ChangeDetectorRef, ComponentRef, EmbeddedViewRef, Injector, TemplateRef } from '@angular/core';
import { Location } from '@angular/common';
import { Direction } from '@angular/cdk/bidi';
import { Observable } from 'rxjs';
import { AnimationEvent, AnimationTriggerMetadata } from '@angular/animations';
import { FocusTrapFactory } from '@angular/cdk/a11y';
import * as i3 from '@angular/material/core';
declare const MAT_SLIDE_PANEL_DATA: InjectionToken<any>;
declare class MatSlidePanelConfig<D = any> {
/** The view container to place the overlay for the mat slide panel into. */
viewContainerRef?: ViewContainerRef;
/** Extra CSS classes to be added to the mat slide panel container. */
panelClass?: string | string[];
/** Text layout direction for the mat slide panel. */
direction?: Direction;
/** Data being injected into the child component. */
data?: D | null;
/** Whether the mat slide panel has a backdrop. */
hasBackdrop?: boolean;
/** Custom class for the backdrop. */
backdropClass?: string;
/** Whether the user can use escape or clicking outside to close the mat slide panel. */
disableClose?: boolean;
/** Aria label to assign to the mat slide panel element. */
ariaLabel?: string | null;
/**
* Whether the mat slide panel should close when the user goes backwards/forwards in history.
* Note that this usually doesn't include clicking on links (unless the user is using
* the `HashLocationStrategy`).
*/
closeOnNavigation?: boolean;
/** Whether the mat slide panel should focus the first focusable element on open. */
autoFocus?: boolean;
/**
* Whether the mat slide panel should restore focus to the
* previously-focused element, after it's closed.
*/
restoreFocus?: boolean;
/** Scroll strategy to be used for the mat slide panel. */
scrollStrategy?: ScrollStrategy;
/** Slide from which side of viewport. */
slideFrom?: 'left' | 'right';
}
declare class MatSlidePanelContainer implements PortalOutlet, OnDestroy {
private _elementRef;
private _changeDetectorRef;
private _focusTrapFactory;
matSlidePanelConfig: MatSlidePanelConfig;
/** The portal outlet inside of this container into which the content will be loaded. */
_portalOutlet: CdkPortalOutlet;
_animationState: 'void' | 'visible' | 'hidden';
/** Emits whenever the state of the animation changes. */
_animationStateChanged: EventEmitter<AnimationEvent>;
private _focusTrap;
private _elementFocusedBeforeOpened;
/** Server-side rendering-compatible reference to the global document object. */
private _document;
/** Whether the component has been destroyed. */
private _destroyed;
constructor(_elementRef: ElementRef<HTMLElement>, _changeDetectorRef: ChangeDetectorRef, _focusTrapFactory: FocusTrapFactory, document: any, matSlidePanelConfig: MatSlidePanelConfig);
/** Attach a component portal as content to this bottom sheet container. */
attachComponentPortal<T>(portal: ComponentPortal<T>): ComponentRef<T>;
/** Attach a template portal as content to this bottom sheet container. */
attachTemplatePortal<C>(portal: TemplatePortal<C>): EmbeddedViewRef<C>;
/** Attach a portal to this outlet. */
attach<T = any>(portal: any): T;
/** Detach the currently attached portal from this outlet. */
detach(): void;
/** Performs cleanup before the outlet is destroyed. */
dispose(): void;
/** Whether this outlet has an attached portal. */
hasAttached(): boolean;
enter(): void;
exit(): void;
ngOnDestroy(): void;
_onAnimationDone(event: AnimationEvent): void;
_onAnimationStart(event: AnimationEvent): void;
private _validatePortalAttached;
private _setPanelClass;
/** Moves the focus inside the focus trap. */
private _trapFocus;
private _restoreFocus;
private _savePreviouslyFocusedElement;
static ɵfac: i0.ɵɵFactoryDeclaration<MatSlidePanelContainer, [null, null, null, { optional: true; }, null]>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatSlidePanelContainer, "mat-slide-panel-container", never, {}, {}, never, never, false, never>;
}
declare class MatSlidePanelRef<T = any, R = any> {
private _overlayRef;
instance: T;
containerInstance: MatSlidePanelContainer;
disableClose: boolean | undefined;
private readonly _afterDismissed;
private readonly _afterOpened;
private _result;
private _closeFallbackTimeout;
constructor(containerInstance: MatSlidePanelContainer, _overlayRef: OverlayRef, _location?: Location);
dismiss(result?: R): void;
afterDismissed(): Observable<R | undefined>;
afterOpened(): Observable<void>;
backdropClick(): Observable<MouseEvent>;
keydownEvents(): Observable<KeyboardEvent>;
}
declare const MAT_SLIDE_PANEL_DEFAULT_OPTIONS: InjectionToken<MatSlidePanelConfig<any>>;
declare class MatSlidePanel implements OnDestroy {
private _overlay;
private _injector;
private _parentMatSlidePanel;
private _location?;
private _defaultOptions?;
private _matSlidePanelAtThisLevel;
/** Reference to the currently opened mat slide panel. */
get _openedMatSlidePanelRef(): MatSlidePanelRef<any> | null;
set _openedMatSlidePanelRef(value: MatSlidePanelRef<any> | null);
constructor(_overlay: Overlay, _injector: Injector, _parentMatSlidePanel: MatSlidePanel, _location?: Location, _defaultOptions?: MatSlidePanelConfig);
open<T, D = any, R = any>(component: ComponentType<T>, config?: MatSlidePanelConfig<D>): MatSlidePanelRef<T, R>;
open<T, D = any, R = any>(template: TemplateRef<T>, config?: MatSlidePanelConfig<D>): MatSlidePanelRef<T, R>;
/**
* Dismisses the currently-visible mat slide panel.
*/
dismiss(): void;
ngOnDestroy(): void;
/**
* Attaches the mat slide panel container component to the overlay.
*/
private _attachContainer;
/**
* Creates a new overlay and places it in the correct location.
* @param config The user-specified mat slide panel config.
*/
private _createOverlay;
/**
* Creates an injector to be used inside of a mat slide panel component.
* @param config Config that was used to create the mat slide panel.
* @param bottomSheetRef Reference to the mat slide panel.
*/
private _createInjector;
static ɵfac: i0.ɵɵFactoryDeclaration<MatSlidePanel, [null, null, { optional: true; skipSelf: true; }, { optional: true; }, { optional: true; }]>;
static ɵprov: i0.ɵɵInjectableDeclaration<MatSlidePanel>;
}
declare class MatSlidePanelModule {
static ɵfac: i0.ɵɵFactoryDeclaration<MatSlidePanelModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<MatSlidePanelModule, [typeof MatSlidePanelContainer], [typeof i2.OverlayModule, typeof i3.MatCommonModule, typeof i4.PortalModule], [typeof MatSlidePanelContainer, typeof i3.MatCommonModule]>;
static ɵinj: i0.ɵɵInjectorDeclaration<MatSlidePanelModule>;
}
/** Animations used by the Material bottom sheet. */
declare const slideFromLeftAnimations: {
readonly slideFromLeftAnimationsState: AnimationTriggerMetadata;
};
/** Animations used by the Material bottom sheet. */
declare const slideFromRightAnimations: {
readonly slideFromLeftAnimationsState: AnimationTriggerMetadata;
};
export { MAT_SLIDE_PANEL_DATA, MAT_SLIDE_PANEL_DEFAULT_OPTIONS, MatSlidePanel, MatSlidePanelConfig, MatSlidePanelContainer, MatSlidePanelModule, MatSlidePanelRef, slideFromLeftAnimations, slideFromRightAnimations };