@covalent/core
Version:
Core Teradata UI Platform for layouts, icons, custom components and themes. This should be added as a dependency for any project that wants to use layouts, icons and themes for Angular Material.
340 lines (333 loc) • 12.4 kB
TypeScript
import * as i0 from '@angular/core';
import { DoCheck, OnInit, OnDestroy, ComponentRef, ViewContainerRef, TemplateRef, Provider } from '@angular/core';
import { TemplatePortal } from '@angular/cdk/portal';
import { Observable, Subject } from 'rxjs';
declare enum LoadingType {
Circular = "circular",
Linear = "linear"
}
declare enum LoadingMode {
Determinate = "determinate",
Indeterminate = "indeterminate"
}
declare enum LoadingStrategy {
Overlay = "overlay",
Replace = "replace"
}
declare enum LoadingStyle {
FullScreen = "fullscreen",
Overlay = "overlay",
None = "none"
}
declare const TD_CIRCLE_DIAMETER = 40;
declare class TdLoadingComponent implements DoCheck {
private _elementRef;
private _changeDetectorRef;
private _mode;
private _defaultMode;
private _value;
private _circleDiameter;
/**
* Flag for animation
*/
animation: boolean;
/**
* Content injected into loading component.
*/
content: TemplatePortal<any>;
/**
* Sets mode of [TdLoadingComponent] to LoadingMode.Determinate or LoadingMode.Indeterminate
*/
set mode(mode: LoadingMode);
get mode(): LoadingMode;
/**
* Sets value of [TdLoadingComponent] if mode is 'LoadingMode.Determinate'
*/
set value(value: number);
get value(): number;
style: LoadingStyle;
/**
* height: number
* Sets height of [TdLoadingComponent].
*/
height: number;
/**
* type: LoadingType
* Sets type of [TdLoadingComponent] rendered.
*/
type: LoadingType;
/**
* color: primary' | 'accent' | 'warn'
* Sets theme color of [TdLoadingComponent] rendered.
*/
color: 'primary' | 'accent' | 'warn';
ngDoCheck(): void;
getHeight(): string | undefined;
getCircleDiameter(): number;
getCircleStrokeWidth(): number;
isCircular(): boolean;
isLinear(): boolean;
isFullScreen(): boolean;
isOverlay(): boolean;
/**
* Starts in animation and returns an observable for completition event.
*/
show(): void;
/**
* Starts out animation and returns an observable for completition event.
*/
hide(): void;
/**
* Calculate the proper diameter for the circle and set it
*/
private _setCircleDiameter;
/**
* Returns the host height of the loading component
*/
private _hostHeight;
static ɵfac: i0.ɵɵFactoryDeclaration<TdLoadingComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<TdLoadingComponent, "td-loading", never, {}, {}, never, never, true, never>;
}
/**
* Context class for variable reference
*/
declare class TdLoadingContext {
$implicit: any;
tdLoading: any;
}
declare class TdLoadingDirective implements OnInit, OnDestroy {
private _viewContainerRef;
private _templateRef;
private _loadingService;
private _context;
private _loadingRef?;
/**
* tdLoading: string
* Name reference of the loading mask, used to register/resolve requests to the mask.
*/
name: string;
/**
* tdLoadingUntil?: any
* If its null, undefined or false it will be used to register requests to the mask.
* Else if its any value that can be resolved as true, it will resolve the mask.
* [name] is optional when using [until], but can still be used to register/resolve it manually.
*/
set until(until: any);
/**
* tdLoadingType?: LoadingType or ['linear' | 'circular']
* Sets the type of loading mask depending on value.
* Defaults to [LoadingType.Circular | 'circular'].
*/
type: LoadingType;
/**
* tdLoadingMode?: LoadingMode or ['determinate' | 'indeterminate']
* Sets the mode of loading mask depending on value.
* Defaults to [LoadingMode.Indeterminate | 'indeterminate'].
*/
mode: LoadingMode;
/**
* tdLoadingStrategy?: LoadingStrategy or ['replace' | 'overlay']
* Sets the strategy of loading mask depending on value.
* Defaults to [LoadingMode.Replace | 'replace'].
*/
strategy: LoadingStrategy.Overlay | LoadingStrategy.Replace;
/**
* tdLoadingColor?: "primary" | "accent" | "warn"
* Sets the theme color of the loading component. Defaults to "primary"
*/
color: 'primary' | 'accent' | 'warn';
/**
* Registers component in the DOM, so it will be available when calling resolve/register.
*/
ngOnInit(): void;
/**
* Remove component when directive is destroyed.
*/
ngOnDestroy(): void;
/**
* Creates [TdLoadingComponent] and attaches it to this directive's [ViewContainerRef].
* Passes this directive's [TemplateRef] to modify DOM depending on loading `strategy`.
*/
private _registerComponent;
static ɵfac: i0.ɵɵFactoryDeclaration<TdLoadingDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<TdLoadingDirective, "[tdLoading]", never, { "name": { "alias": "tdLoading"; "required": false; }; "until": { "alias": "tdLoadingUntil"; "required": false; }; "type": { "alias": "tdLoadingType"; "required": false; }; "mode": { "alias": "tdLoadingMode"; "required": false; }; "strategy": { "alias": "tdLoadingStrategy"; "required": false; }; "color": { "alias": "tdLoadingColor"; "required": false; }; }, {}, never, never, true, never>;
}
declare class CovalentLoadingModule {
static ɵfac: i0.ɵɵFactoryDeclaration<CovalentLoadingModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<CovalentLoadingModule, never, [typeof TdLoadingComponent, typeof TdLoadingDirective], [typeof TdLoadingComponent, typeof TdLoadingDirective]>;
static ɵinj: i0.ɵɵInjectorDeclaration<CovalentLoadingModule>;
}
interface IInternalLoadingOptions extends ITdLoadingConfig {
height?: number;
style?: LoadingStyle;
}
interface ILoadingRef {
observable: Observable<any>;
componentRef?: ComponentRef<any>;
subject: Subject<any>;
times: number;
}
/**
* NOTE: @internal usage only.
*/
declare class TdLoadingFactory {
private _componentFactoryResolver;
private _overlay;
private _injector;
/**
* Uses material `Overlay` services to create a DOM element and attach the loading component
* into it. Leveraging the state and configuration from it.
*
* Saves a reference in context to be called when registering/resolving the loading element.
*/
createFullScreenComponent(options: ITdLoadingConfig): ILoadingRef;
/**
* Creates a loading component dynamically and attaches it into the given viewContainerRef.
* Leverages TemplatePortals from material to inject the template inside of it so it fits
* perfectly when overlaying it.
*
* Saves a reference in context to be called when registering/resolving the loading element.
*/
createOverlayComponent(options: ITdLoadingConfig, viewContainerRef: ViewContainerRef, templateRef: TemplateRef<object>): ILoadingRef;
/**
* Creates a loading component dynamically and attaches it into the given viewContainerRef.
* Replaces the template with the loading component depending if it was registered or resolved.
*
* Saves a reference in context to be called when registering/resolving the loading element.
*/
createReplaceComponent(options: ITdLoadingConfig, viewContainerRef: ViewContainerRef, templateRef: TemplateRef<object>, context: TdLoadingContext): ILoadingRef;
/**
* Creates a fullscreen overlay for the loading usage.
*/
private _createOverlay;
/**
* Creates a generic component dynamically waiting to be attached to a viewContainerRef.
*/
private _createComponent;
/**
* Initialize context for loading component.
*/
private _initializeContext;
/**
* Maps configuration to the loading component instance.
*/
private _mapOptions;
static ɵfac: i0.ɵɵFactoryDeclaration<TdLoadingFactory, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TdLoadingFactory>;
}
declare function LOADING_FACTORY_PROVIDER_FACTORY(parent: TdLoadingFactory): TdLoadingFactory;
declare const LOADING_FACTORY_PROVIDER: Provider;
interface ITdLoadingConfig {
name: string;
type?: LoadingType;
mode?: LoadingMode;
color?: 'primary' | 'accent' | 'warn';
}
declare class TdLoadingConfig implements ITdLoadingConfig {
name: string;
type?: LoadingType;
mode?: LoadingMode;
color?: 'primary' | 'accent' | 'warn';
constructor(config: ITdLoadingConfig);
}
interface ITdLoadingDirectiveConfig extends ITdLoadingConfig {
strategy?: LoadingStrategy;
}
declare class TdLoadingDirectiveConfig extends TdLoadingConfig implements ITdLoadingDirectiveConfig {
strategy: LoadingStrategy;
constructor(config: ITdLoadingDirectiveConfig);
}
declare class TdLoadingService {
private _loadingFactory;
private _context;
private _timeouts;
constructor();
/**
* params:
* - config: ILoadingDirectiveConfig
* - viewContainerRef: ViewContainerRef
* - templateRef: TemplateRef<Object>
*
* Creates an replace loading mask and attaches it to the viewContainerRef.
* Replaces the templateRef with the mask when a request is registered on it.
*
* NOTE: @internal usage only.
*/
createComponent(config: ITdLoadingDirectiveConfig, viewContainerRef: ViewContainerRef, templateRef: TemplateRef<object>, context: TdLoadingContext): ILoadingRef;
/**
* params:
* - config: ITdLoadingConfig
*
* Creates a fullscreen loading mask and attaches it to the DOM with the given configuration.
* Only displayed when the mask has a request registered on it.
*/
create(config: ITdLoadingConfig): void;
/**
* params:
* - name: string
*
* Removes `loading` component from service context.
*/
removeComponent(name: string): void;
/**
* params:
* - name: string
* - registers?: number
* returns: true if successful
*
* Resolves a request for the loading mask referenced by the name parameter.
* Can optionally pass registers argument to set a number of register calls.
*
* If no paramemeters are used, then default main mask will be used.
*
* e.g. loadingService.register()
*/
register(name?: string, registers?: number): boolean;
/**
* params:
* - name: string
* - resolves?: number
* returns: true if successful
*
* Resolves a request for the loading mask referenced by the name parameter.
* Can optionally pass resolves argument to set a number of resolve calls.
*
* If no paramemeters are used, then default main mask will be used.
*
* e.g. loadingService.resolve()
*/
resolve(name?: string, resolves?: number): boolean;
/**
* params:
* - name: string
* returns: true if successful
*
* Resolves all request for the loading mask referenced by the name parameter.
*
* If no paramemeters are used, then default main mask will be used.
*
* e.g. loadingService.resolveAll()
*/
resolveAll(name?: string): boolean;
/**
* params:
* - name: string
* - value: number
* returns: true if successful
*
* Set value on a loading mask referenced by the name parameter.
* Usage only available if its mode is 'determinate' and if loading is showing.
*/
setValue(name: string, value: number): boolean;
/**
* Clears timeout linked to the name.
* @param name Name of the loading component to be cleared
*/
private _clearTimeout;
static ɵfac: i0.ɵɵFactoryDeclaration<TdLoadingService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TdLoadingService>;
}
declare function LOADING_PROVIDER_FACTORY(parent: TdLoadingService): TdLoadingService;
declare const LOADING_PROVIDER: Provider;
export { CovalentLoadingModule, LOADING_FACTORY_PROVIDER, LOADING_FACTORY_PROVIDER_FACTORY, LOADING_PROVIDER, LOADING_PROVIDER_FACTORY, LoadingMode, LoadingStrategy, LoadingStyle, LoadingType, TD_CIRCLE_DIAMETER, TdLoadingComponent, TdLoadingConfig, TdLoadingContext, TdLoadingDirective, TdLoadingDirectiveConfig, TdLoadingFactory, TdLoadingService };
export type { IInternalLoadingOptions, ILoadingRef, ITdLoadingConfig, ITdLoadingDirectiveConfig };