source: trip-planner-front/node_modules/@angular/cdk/portal/portal.d.ts@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.5 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { TemplateRef, ViewContainerRef, ElementRef, ComponentRef, EmbeddedViewRef, Injector, ComponentFactoryResolver } from '@angular/core';
9/** Interface that can be used to generically type a class. */
10export interface ComponentType<T> {
11 new (...args: any[]): T;
12}
13/**
14 * A `Portal` is something that you want to render somewhere else.
15 * It can be attach to / detached from a `PortalOutlet`.
16 */
17export declare abstract class Portal<T> {
18 private _attachedHost;
19 /** Attach this portal to a host. */
20 attach(host: PortalOutlet): T;
21 /** Detach this portal from its host */
22 detach(): void;
23 /** Whether this portal is attached to a host. */
24 get isAttached(): boolean;
25 /**
26 * Sets the PortalOutlet reference without performing `attach()`. This is used directly by
27 * the PortalOutlet when it is performing an `attach()` or `detach()`.
28 */
29 setAttachedHost(host: PortalOutlet | null): void;
30}
31/**
32 * A `ComponentPortal` is a portal that instantiates some Component upon attachment.
33 */
34export declare class ComponentPortal<T> extends Portal<ComponentRef<T>> {
35 /** The type of the component that will be instantiated for attachment. */
36 component: ComponentType<T>;
37 /**
38 * [Optional] Where the attached component should live in Angular's *logical* component tree.
39 * This is different from where the component *renders*, which is determined by the PortalOutlet.
40 * The origin is necessary when the host is outside of the Angular application context.
41 */
42 viewContainerRef?: ViewContainerRef | null;
43 /** [Optional] Injector used for the instantiation of the component. */
44 injector?: Injector | null;
45 /**
46 * Alternate `ComponentFactoryResolver` to use when resolving the associated component.
47 * Defaults to using the resolver from the outlet that the portal is attached to.
48 */
49 componentFactoryResolver?: ComponentFactoryResolver | null;
50 constructor(component: ComponentType<T>, viewContainerRef?: ViewContainerRef | null, injector?: Injector | null, componentFactoryResolver?: ComponentFactoryResolver | null);
51}
52/**
53 * A `TemplatePortal` is a portal that represents some embedded template (TemplateRef).
54 */
55export declare class TemplatePortal<C = any> extends Portal<EmbeddedViewRef<C>> {
56 /** The embedded template that will be used to instantiate an embedded View in the host. */
57 templateRef: TemplateRef<C>;
58 /** Reference to the ViewContainer into which the template will be stamped out. */
59 viewContainerRef: ViewContainerRef;
60 /** Contextual data to be passed in to the embedded view. */
61 context: C | undefined;
62 constructor(template: TemplateRef<C>, viewContainerRef: ViewContainerRef, context?: C);
63 get origin(): ElementRef;
64 /**
65 * Attach the portal to the provided `PortalOutlet`.
66 * When a context is provided it will override the `context` property of the `TemplatePortal`
67 * instance.
68 */
69 attach(host: PortalOutlet, context?: C | undefined): EmbeddedViewRef<C>;
70 detach(): void;
71}
72/**
73 * A `DomPortal` is a portal whose DOM element will be taken from its current position
74 * in the DOM and moved into a portal outlet, when it is attached. On detach, the content
75 * will be restored to its original position.
76 */
77export declare class DomPortal<T = HTMLElement> extends Portal<T> {
78 /** DOM node hosting the portal's content. */
79 readonly element: T;
80 constructor(element: T | ElementRef<T>);
81}
82/** A `PortalOutlet` is an space that can contain a single `Portal`. */
83export interface PortalOutlet {
84 /** Attaches a portal to this outlet. */
85 attach(portal: Portal<any>): any;
86 /** Detaches the currently attached portal from this outlet. */
87 detach(): any;
88 /** Performs cleanup before the outlet is destroyed. */
89 dispose(): void;
90 /** Whether there is currently a portal attached to this outlet. */
91 hasAttached(): boolean;
92}
93/**
94 * @deprecated Use `PortalOutlet` instead.
95 * @breaking-change 9.0.0
96 */
97export declare type PortalHost = PortalOutlet;
98/**
99 * Partial implementation of PortalOutlet that handles attaching
100 * ComponentPortal and TemplatePortal.
101 */
102export declare abstract class BasePortalOutlet implements PortalOutlet {
103 /** The portal currently attached to the host. */
104 protected _attachedPortal: Portal<any> | null;
105 /** A function that will permanently dispose this host. */
106 private _disposeFn;
107 /** Whether this host has already been permanently disposed. */
108 private _isDisposed;
109 /** Whether this host has an attached portal. */
110 hasAttached(): boolean;
111 attach<T>(portal: ComponentPortal<T>): ComponentRef<T>;
112 attach<T>(portal: TemplatePortal<T>): EmbeddedViewRef<T>;
113 attach(portal: any): any;
114 abstract attachComponentPortal<T>(portal: ComponentPortal<T>): ComponentRef<T>;
115 abstract attachTemplatePortal<C>(portal: TemplatePortal<C>): EmbeddedViewRef<C>;
116 readonly attachDomPortal: null | ((portal: DomPortal) => any);
117 /** Detaches a previously attached portal. */
118 detach(): void;
119 /** Permanently dispose of this portal host. */
120 dispose(): void;
121 /** @docs-private */
122 setDisposeFn(fn: () => void): void;
123 private _invokeDisposeFn;
124}
125/**
126 * @deprecated Use `BasePortalOutlet` instead.
127 * @breaking-change 9.0.0
128 */
129export declare abstract class BasePortalHost extends BasePortalOutlet {
130}
Note: See TracBrowser for help on using the repository browser.