ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
149 lines • 6.33 kB
TypeScript
import { ComponentType } from "@angular/cdk/overlay";
import * as i0 from "@angular/core";
import { ChangeDetectorRef, DestroyRef, ElementRef, EventEmitter, Injector, OnInit, Signal, TemplateRef } from "@angular/core";
import { MessageConfig, NzConfigService } from "ng-zorro-antd/core/config";
import { NzSingletonService } from "ng-zorro-antd/core/services";
import { Subject } from "rxjs";
import { NgClassInterface, NgStyleInterface, NzSafeAny } from "ng-zorro-antd/core/types";
import { Direction } from "@angular/cdk/bidi";
export type NzMessageType = 'success' | 'info' | 'warning' | 'error' | 'loading';
export type NzMessageContentType = string | TemplateRef<void | {
$implicit: NzMNComponent;
data: NzSafeAny;
}>;
export interface NzMessageDataOptions {
nzDuration?: number;
nzAnimate?: boolean;
nzPauseOnHover?: boolean;
nzData?: NzSafeAny;
nzStyle?: NgStyleInterface | string;
nzClass?: NgClassInterface | string;
}
export interface NzMessageData {
type?: NzMessageType | string;
content?: NzMessageContentType;
messageId?: string;
createdAt?: Date;
options?: NzMessageDataOptions;
onClose?: Subject<boolean>;
}
export type NzMessageRef = Pick<Required<NzMessageData>, 'onClose' | 'messageId'>;
export declare abstract class NzMNService<T extends NzMNContainerComponent> {
protected abstract componentPrefix: string;
protected container?: T;
protected nzSingletonService: NzSingletonService;
protected injector: Injector;
remove(id?: string): void;
protected getInstanceId(): string;
protected withContainer(ctor: ComponentType<T>): T;
}
export declare abstract class NzMNContainerComponent<C extends MessageConfig = MessageConfig, D extends NzMessageData = NzMessageData> {
config?: Required<C>;
instances: Array<Required<D>>;
private readonly _afterAllInstancesRemoved;
readonly afterAllInstancesRemoved: import("rxjs").Observable<void>;
protected cdr: ChangeDetectorRef;
protected nzConfigService: NzConfigService;
constructor();
create(data: D): Required<D>;
remove(id: string, userAction?: boolean): void;
removeAll(): void;
protected onCreate(instance: D): Required<D>;
protected onRemove(instance: Required<D>, userAction: boolean): void;
private onAllInstancesRemoved;
protected readyInstances(): void;
protected abstract subscribeConfigChange(): void;
protected mergeOptions(options?: D['options']): D['options'];
static ɵfac: i0.ɵɵFactoryDeclaration<NzMNContainerComponent<any, any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<NzMNContainerComponent<any, any>, never, never, {}, {}, never, never, true, never>;
}
export declare abstract class NzMNComponent implements OnInit {
abstract instance: Required<NzMessageData>;
abstract index?: number;
abstract destroyed: EventEmitter<{
id: string;
userAction: boolean;
}>;
protected destroyRef: DestroyRef;
protected elementRef: ElementRef<any>;
/**
* To get the element which triggers the animation.
*/
protected abstract animationElement: Signal<ElementRef<HTMLElement>>;
/**
* When the animation is enabled, it is used to judge whether the leave animation is done or not.
* @note Keyframe of notification may have different keyframe names with individual placements, so use array here.
*/
protected abstract _animationKeyframeMap: Record<'enter' | 'leave', string | string[]>;
/**
* The animation class map for enter and leave.
*/
protected abstract _animationClassMap: Record<'enter' | 'leave', string>;
protected options: Required<NzMessageDataOptions>;
protected autoClose?: boolean;
protected userAction: boolean;
protected eraseTimer?: ReturnType<typeof setTimeout>;
protected eraseTimingStart?: number;
protected eraseTTL: number;
constructor();
ngOnInit(): void;
onEnter(): void;
onLeave(): void;
protected destroy(userAction?: boolean): void;
private initErase;
private updateTTL;
private startEraseTimeout;
private clearEraseTimeout;
private _startEnterAnimation;
private _startLeaveAnimation;
private matchAnimationKeyframe;
static ɵfac: i0.ɵɵFactoryDeclaration<NzMNComponent, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<NzMNComponent, never, never, {}, {}, never, never, true, never>;
}
export declare class NzMessageContainerComponent extends NzMNContainerComponent {
dir: Direction;
top?: string | null;
constructor();
protected subscribeConfigChange(): void;
protected updateConfig(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NzMessageContainerComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NzMessageContainerComponent, "nz-message-container", ["nzMessageContainer"], {}, {}, never, never, true, never>;
}
export declare class NzMessageComponent extends NzMNComponent implements OnInit {
instance: Required<NzMessageData>;
readonly destroyed: EventEmitter<{
id: string;
userAction: boolean;
}>;
index?: number;
readonly animationElement: import("@angular/core").Signal<ElementRef<any>>;
protected readonly _animationKeyframeMap: {
enter: string;
leave: string;
};
protected readonly _animationClassMap: {
enter: string;
leave: string;
};
static ɵfac: i0.ɵɵFactoryDeclaration<NzMessageComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NzMessageComponent, "nz-message", ["nzMessage"], {
"instance": {
"alias": "instance";
"required": false;
};
}, {
"destroyed": "destroyed";
}, never, never, true, never>;
}
export declare class NzMessageService extends NzMNService<NzMessageContainerComponent> {
protected componentPrefix: string;
success(content: NzMessageContentType, options?: NzMessageDataOptions): NzMessageRef;
error(content: NzMessageContentType, options?: NzMessageDataOptions): NzMessageRef;
info(content: NzMessageContentType, options?: NzMessageDataOptions): NzMessageRef;
warning(content: NzMessageContentType, options?: NzMessageDataOptions): NzMessageRef;
loading(content: NzMessageContentType, options?: NzMessageDataOptions): NzMessageRef;
create(type: NzMessageType | string, content: NzMessageContentType, options?: NzMessageDataOptions): NzMessageRef;
private createInstance;
static ɵfac: i0.ɵɵFactoryDeclaration<NzMessageService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
}