UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

476 lines (444 loc) 22.5 kB
import { Direction } from '@angular/cdk/bidi'; import * as i0 from '@angular/core'; import { TemplateRef, EventEmitter, Type, ViewContainerRef, ChangeDetectorRef, NgZone, ElementRef, Renderer2, DestroyRef, ComponentRef, EmbeddedViewRef, OnDestroy, InjectionToken, OnChanges, SimpleChanges, OnInit } from '@angular/core'; import { NzButtonType, NzButtonShape, NzButtonSize } from 'ng-zorro-antd/button'; import { NzSafeAny } from 'ng-zorro-antd/core/types'; import { Observable, Subject } from 'rxjs'; import * as i1 from '@angular/cdk/overlay'; import { OverlayRef } from '@angular/cdk/overlay'; import { AnimationEvent, AnimationTriggerMetadata } from '@angular/animations'; import { FocusTrapFactory } from '@angular/cdk/a11y'; import { BasePortalOutlet, CdkPortalOutlet, ComponentPortal, TemplatePortal } from '@angular/cdk/portal'; import { NzConfigService, NzConfigKey } from 'ng-zorro-antd/core/config'; import { NzModalI18nInterface } from 'ng-zorro-antd/i18n'; /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ type OnClickCallback<T> = (instance: T) => (false | void | {}) | Promise<false | void | {}>; type ModalTypes = 'default' | 'confirm'; type ConfirmType = 'confirm' | 'info' | 'success' | 'error' | 'warning'; interface StyleObjectLike { [key: string]: string; } declare class ModalOptions<T = NzSafeAny, D = NzSafeAny, R = NzSafeAny> { nzCentered?: boolean; nzClosable?: boolean; nzOkLoading?: boolean; nzOkDisabled?: boolean; nzCancelDisabled?: boolean; nzCancelLoading?: boolean; nzDraggable?: boolean; nzNoAnimation?: boolean; nzAutofocus?: 'ok' | 'cancel' | 'auto' | null; nzMask?: boolean; nzMaskClosable?: boolean; nzKeyboard?: boolean; nzZIndex?: number; nzWidth?: number | string; nzCloseIcon?: string | TemplateRef<void>; nzOkType?: NzButtonType; nzOkDanger?: boolean; nzModalType?: ModalTypes; nzOnCancel?: EventEmitter<T> | OnClickCallback<T>; nzOnOk?: EventEmitter<T> | OnClickCallback<T>; nzData?: D; nzMaskStyle?: StyleObjectLike; nzBodyStyle?: StyleObjectLike; nzWrapClassName?: string; nzClassName?: string; nzStyle?: object; nzTitle?: string | TemplateRef<{}>; nzFooter?: string | TemplateRef<{}> | Array<ModalButtonOptions<T>> | null; nzCancelText?: string | null; nzOkText?: string | null; nzContent?: string | TemplateRef<NzSafeAny> | Type<T>; nzCloseOnNavigation?: boolean; nzViewContainerRef?: ViewContainerRef; nzAfterOpen?: EventEmitter<void>; nzAfterClose?: EventEmitter<R>; nzIconType?: string; nzDirection?: Direction; } interface ModalButtonOptions<T = NzSafeAny> { label: string; type?: NzButtonType; danger?: boolean; shape?: NzButtonShape; ghost?: boolean; size?: NzButtonSize; autoLoading?: boolean; show?: boolean | ((this: ModalButtonOptions<T>, contentComponentInstance?: T) => boolean); loading?: boolean | ((this: ModalButtonOptions<T>, contentComponentInstance?: T) => boolean); disabled?: boolean | ((this: ModalButtonOptions<T>, contentComponentInstance?: T) => boolean); onClick?(this: ModalButtonOptions<T>, contentComponentInstance?: T): NzSafeAny | Promise<NzSafeAny>; [key: string]: NzSafeAny; } /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare function throwNzModalContentAlreadyAttachedError(): never; declare class BaseModalContainerComponent extends BasePortalOutlet { readonly document: Document; readonly cdr: ChangeDetectorRef; readonly config: ModalOptions; protected ngZone: NgZone; protected host: ElementRef<HTMLElement>; protected focusTrapFactory: FocusTrapFactory; protected render: Renderer2; protected overlayRef: OverlayRef; protected nzConfigService: NzConfigService; protected animationType: "NoopAnimations" | "BrowserAnimations" | null; protected destroyRef: DestroyRef; portalOutlet: CdkPortalOutlet; modalElementRef: ElementRef<HTMLDivElement>; animationStateChanged: EventEmitter<AnimationEvent>; containerClick: EventEmitter<void>; cancelTriggered: EventEmitter<void>; okTriggered: EventEmitter<void>; state: 'void' | 'enter' | 'exit'; modalRef: NzModalRef; isStringContent: boolean; dir: Direction; private elementFocusedBeforeModalWasOpened; private focusTrap; private mouseDown; private oldMaskStyle; get showMask(): boolean; get maskClosable(): boolean; constructor(); onContainerClick(e: MouseEvent): void; onCloseClick(): void; onOkClick(): void; attachComponentPortal<T>(portal: ComponentPortal<T>): ComponentRef<T>; attachTemplatePortal<C>(portal: TemplatePortal<C>): EmbeddedViewRef<C>; attachStringContent(): void; getNativeElement(): HTMLElement; private animationDisabled; private setModalTransformOrigin; private savePreviouslyFocusedElement; private trapFocus; private restoreFocus; private setEnterAnimationClass; private setExitAnimationClass; private setMaskExitAnimationClass; private cleanAnimationClass; private setZIndexForBackdrop; bindBackdropStyle(): void; updateMaskClassname(): void; onAnimationDone(event: AnimationEvent): void; onAnimationStart(event: AnimationEvent): void; startExitAnimation(): void; protected setupMouseListeners(modalContainer: ElementRef<HTMLElement>): void; static ɵfac: i0.ɵɵFactoryDeclaration<BaseModalContainerComponent, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<BaseModalContainerComponent, never, never, {}, {}, never, never, true, never>; } /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare abstract class NzModalLegacyAPI<T, R> { abstract afterOpen: Observable<void>; abstract afterClose: Observable<R | undefined>; abstract close(result?: R): void; abstract destroy(result?: R): void; /** * Trigger the nzOnOk/nzOnCancel by manual */ abstract triggerOk(): void; abstract triggerCancel(): void; /** * Return the component instance of nzContent when specify nzContent as a Component */ abstract getContentComponent(): T | void; /** * Get the dom element of this Modal */ abstract getElement(): HTMLElement | void; } /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare const NzModalState: { readonly OPEN: 0; readonly CLOSING: 1; readonly CLOSED: 2; }; type NzModalState = (typeof NzModalState)[keyof typeof NzModalState]; declare const NzTriggerAction: { readonly CANCEL: "cancel"; readonly OK: "ok"; }; type NzTriggerAction = (typeof NzTriggerAction)[keyof typeof NzTriggerAction]; declare class NzModalRef<T = NzSafeAny, R = NzSafeAny> implements NzModalLegacyAPI<T, R> { private overlayRef; private config; containerInstance: BaseModalContainerComponent; componentInstance: T | null; componentRef: ComponentRef<T> | null; result?: R; state: NzModalState; afterClose: Subject<R | undefined>; afterOpen: Subject<void>; private closeTimeout?; private destroy$; constructor(overlayRef: OverlayRef, config: ModalOptions, containerInstance: BaseModalContainerComponent); getContentComponent(): T; getContentComponentRef(): Readonly<ComponentRef<T> | null>; getElement(): HTMLElement; destroy(result?: R): void; triggerOk(): Promise<void>; triggerCancel(): Promise<void>; close(result?: R): void; updateConfig(config: ModalOptions): void; getState(): NzModalState; getConfig(): ModalOptions; getBackdropElement(): HTMLElement | null; private trigger; private closeWhitResult; _finishDialogClose(): void; } declare class NzModalService implements OnDestroy { private overlay; private injector; private nzConfigService; private directionality; private parentModal; private openModalsAtThisLevel; private readonly afterAllClosedAtThisLevel; get openModals(): NzModalRef[]; get _afterAllClosed(): Subject<void>; readonly afterAllClose: Observable<void>; create<T, D = NzSafeAny, R = NzSafeAny>(config: ModalOptions<T, D, R>): NzModalRef<T, R>; closeAll(): void; confirm<T>(options?: ModalOptions<T>, confirmType?: ConfirmType): NzModalRef<T>; info<T>(options?: ModalOptions<T>): NzModalRef<T>; success<T>(options?: ModalOptions<T>): NzModalRef<T>; error<T>(options?: ModalOptions<T>): NzModalRef<T>; warning<T>(options?: ModalOptions<T>): NzModalRef<T>; private open; private removeOpenModal; private closeModals; private createOverlay; private attachModalContainer; private attachModalContent; private createInjector; private confirmFactory; ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration<NzModalService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<NzModalService>; } /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare const ZOOM_CLASS_NAME_MAP: { enter: string; enterActive: string; leave: string; leaveActive: string; }; declare const FADE_CLASS_NAME_MAP: { enter: string; enterActive: string; leave: string; leaveActive: string; }; declare const MODAL_MASK_CLASS_NAME = "ant-modal-mask"; declare const NZ_CONFIG_MODULE_NAME: NzConfigKey; declare const NZ_MODAL_DATA: InjectionToken<any>; /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare class NzModalComponent<T extends ModalOptions = NzSafeAny, R = NzSafeAny> implements OnChanges, NzModalLegacyAPI<T, R> { private cdr; private modal; private viewContainerRef; private destroyRef; nzMask?: boolean; nzMaskClosable?: boolean; nzCloseOnNavigation?: boolean; nzVisible: boolean; nzClosable: boolean; nzOkLoading: boolean; nzOkDisabled: boolean; nzCancelDisabled: boolean; nzCancelLoading: boolean; nzKeyboard: boolean; nzNoAnimation: boolean; nzCentered: boolean; nzDraggable: boolean; nzContent?: string | TemplateRef<{}> | Type<T>; nzFooter?: string | TemplateRef<{}> | Array<ModalButtonOptions<T>> | null; nzZIndex: number; nzWidth: number | string; nzWrapClassName?: string; nzClassName?: string; nzStyle?: object; nzTitle?: string | TemplateRef<{}>; nzCloseIcon: string | TemplateRef<void>; nzMaskStyle?: StyleObjectLike; nzBodyStyle?: StyleObjectLike; nzOkText?: string | null; nzCancelText?: string | null; nzOkType: NzButtonType; nzOkDanger: boolean; nzIconType: string; nzModalType: ModalTypes; nzAutofocus: 'ok' | 'cancel' | 'auto' | null; readonly nzOnOk: EventEmitter<T> | OnClickCallback<T> | NzSafeAny; readonly nzOnCancel: EventEmitter<T> | OnClickCallback<T> | NzSafeAny; readonly nzAfterOpen: EventEmitter<void>; readonly nzAfterClose: EventEmitter<R>; readonly nzVisibleChange: EventEmitter<boolean>; set modalTitle(value: TemplateRef<NzSafeAny>); contentFromContentChild: TemplateRef<NzSafeAny>; set modalFooter(value: TemplateRef<NzSafeAny>); private modalRef; get afterOpen(): Observable<void>; get afterClose(): Observable<R>; constructor(); open(): void; close(result?: R): void; destroy(result?: R): void; triggerOk(): void; triggerCancel(): void; getContentComponent(): T | void; getElement(): HTMLElement | void; getModalRef(): NzModalRef | null; private setTitleWithTemplate; private setFooterWithTemplate; private getConfig; ngOnChanges(changes: SimpleChanges): void; static ɵfac: i0.ɵɵFactoryDeclaration<NzModalComponent<any, any>, never>; static ɵcmp: i0.ɵɵComponentDeclaration<NzModalComponent<any, any>, "nz-modal", ["nzModal"], { "nzMask": { "alias": "nzMask"; "required": false; }; "nzMaskClosable": { "alias": "nzMaskClosable"; "required": false; }; "nzCloseOnNavigation": { "alias": "nzCloseOnNavigation"; "required": false; }; "nzVisible": { "alias": "nzVisible"; "required": false; }; "nzClosable": { "alias": "nzClosable"; "required": false; }; "nzOkLoading": { "alias": "nzOkLoading"; "required": false; }; "nzOkDisabled": { "alias": "nzOkDisabled"; "required": false; }; "nzCancelDisabled": { "alias": "nzCancelDisabled"; "required": false; }; "nzCancelLoading": { "alias": "nzCancelLoading"; "required": false; }; "nzKeyboard": { "alias": "nzKeyboard"; "required": false; }; "nzNoAnimation": { "alias": "nzNoAnimation"; "required": false; }; "nzCentered": { "alias": "nzCentered"; "required": false; }; "nzDraggable": { "alias": "nzDraggable"; "required": false; }; "nzContent": { "alias": "nzContent"; "required": false; }; "nzFooter": { "alias": "nzFooter"; "required": false; }; "nzZIndex": { "alias": "nzZIndex"; "required": false; }; "nzWidth": { "alias": "nzWidth"; "required": false; }; "nzWrapClassName": { "alias": "nzWrapClassName"; "required": false; }; "nzClassName": { "alias": "nzClassName"; "required": false; }; "nzStyle": { "alias": "nzStyle"; "required": false; }; "nzTitle": { "alias": "nzTitle"; "required": false; }; "nzCloseIcon": { "alias": "nzCloseIcon"; "required": false; }; "nzMaskStyle": { "alias": "nzMaskStyle"; "required": false; }; "nzBodyStyle": { "alias": "nzBodyStyle"; "required": false; }; "nzOkText": { "alias": "nzOkText"; "required": false; }; "nzCancelText": { "alias": "nzCancelText"; "required": false; }; "nzOkType": { "alias": "nzOkType"; "required": false; }; "nzOkDanger": { "alias": "nzOkDanger"; "required": false; }; "nzIconType": { "alias": "nzIconType"; "required": false; }; "nzModalType": { "alias": "nzModalType"; "required": false; }; "nzAutofocus": { "alias": "nzAutofocus"; "required": false; }; "nzOnOk": { "alias": "nzOnOk"; "required": false; }; "nzOnCancel": { "alias": "nzOnCancel"; "required": false; }; }, { "nzOnOk": "nzOnOk"; "nzOnCancel": "nzOnCancel"; "nzAfterOpen": "nzAfterOpen"; "nzAfterClose": "nzAfterClose"; "nzVisibleChange": "nzVisibleChange"; }, ["modalTitle", "contentFromContentChild", "modalFooter"], never, true, never>; static ngAcceptInputType_nzMask: unknown; static ngAcceptInputType_nzMaskClosable: unknown; static ngAcceptInputType_nzCloseOnNavigation: unknown; static ngAcceptInputType_nzVisible: unknown; static ngAcceptInputType_nzClosable: unknown; static ngAcceptInputType_nzOkLoading: unknown; static ngAcceptInputType_nzOkDisabled: unknown; static ngAcceptInputType_nzCancelDisabled: unknown; static ngAcceptInputType_nzCancelLoading: unknown; static ngAcceptInputType_nzKeyboard: unknown; static ngAcceptInputType_nzNoAnimation: unknown; static ngAcceptInputType_nzCentered: unknown; static ngAcceptInputType_nzDraggable: unknown; static ngAcceptInputType_nzZIndex: unknown; static ngAcceptInputType_nzOkDanger: unknown; } /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare class NzModalTitleDirective { readonly templateRef: TemplateRef<{}>; private nzModalRef; constructor(); static ɵfac: i0.ɵɵFactoryDeclaration<NzModalTitleDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<NzModalTitleDirective, "[nzModalTitle]", ["nzModalTitle"], {}, {}, never, never, true, never>; } /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare class NzModalFooterDirective { readonly templateRef: TemplateRef<{}>; private nzModalRef; constructor(); static ɵfac: i0.ɵɵFactoryDeclaration<NzModalFooterDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<NzModalFooterDirective, "[nzModalFooter]", ["nzModalFooter"], {}, {}, never, never, true, never>; } /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare class NzModalContentDirective { readonly templateRef: TemplateRef<{}>; static ɵfac: i0.ɵɵFactoryDeclaration<NzModalContentDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<NzModalContentDirective, "[nzModalContent]", ["nzModalContent"], {}, {}, never, never, true, never>; } declare class NzModalCloseComponent { readonly config: ModalOptions<any, any, any>; static ɵfac: i0.ɵɵFactoryDeclaration<NzModalCloseComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<NzModalCloseComponent, "button[nz-modal-close]", ["nzModalCloseBuiltin"], {}, {}, never, never, true, never>; } /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare class NzModalFooterComponent { private i18n; readonly config: ModalOptions<any, any, any>; buttonsFooter: boolean; buttons: ModalButtonOptions[]; locale: NzModalI18nInterface; readonly cancelTriggered: EventEmitter<void>; readonly okTriggered: EventEmitter<void>; modalRef: NzModalRef; constructor(); onCancel(): void; onOk(): void; /** * Returns the value of the specified key. * If it is a function, run and return the return value of the function. */ getButtonCallableProp(options: ModalButtonOptions, prop: keyof ModalButtonOptions): boolean; /** * Run function based on the type and set its `loading` prop if needed. */ onButtonClick(options: ModalButtonOptions): void; static ɵfac: i0.ɵɵFactoryDeclaration<NzModalFooterComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<NzModalFooterComponent, "div[nz-modal-footer]", ["nzModalFooterBuiltin"], { "modalRef": { "alias": "modalRef"; "required": false; }; }, { "cancelTriggered": "cancelTriggered"; "okTriggered": "okTriggered"; }, never, never, true, never>; } declare class NzModalTitleComponent { config: ModalOptions<any, any, any>; static ɵfac: i0.ɵɵFactoryDeclaration<NzModalTitleComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<NzModalTitleComponent, "div[nz-modal-title]", ["nzModalTitleBuiltin"], {}, {}, never, never, true, never>; } declare class NzModalContainerComponent extends BaseModalContainerComponent implements OnInit { set _portalOutlet(portalOutlet: CdkPortalOutlet); set _modalElementRef(elementRef: ElementRef<HTMLDivElement>); ngOnInit(): void; static ɵfac: i0.ɵɵFactoryDeclaration<NzModalContainerComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<NzModalContainerComponent, "nz-modal-container", ["nzModalContainer"], {}, {}, never, never, true, [{ directive: typeof i1.CdkScrollable; inputs: {}; outputs: {}; }]>; } declare class NzModalConfirmContainerComponent extends BaseModalContainerComponent implements OnInit { private i18n; set _portalOutlet(portalOutlet: CdkPortalOutlet); set _modalElementRef(elementRef: ElementRef<HTMLDivElement>); readonly cancelTriggered: EventEmitter<void>; readonly okTriggered: EventEmitter<void>; locale: NzModalI18nInterface; constructor(); ngOnInit(): void; onCancel(): void; onOk(): void; static ɵfac: i0.ɵɵFactoryDeclaration<NzModalConfirmContainerComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<NzModalConfirmContainerComponent, "nz-modal-confirm-container", ["nzModalConfirmContainer"], {}, { "cancelTriggered": "cancelTriggered"; "okTriggered": "okTriggered"; }, never, never, true, [{ directive: typeof i1.CdkScrollable; inputs: {}; outputs: {}; }]>; } declare class NzModalModule { static ɵfac: i0.ɵɵFactoryDeclaration<NzModalModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<NzModalModule, never, [typeof NzModalComponent, typeof NzModalFooterDirective, typeof NzModalContentDirective, typeof NzModalCloseComponent, typeof NzModalFooterComponent, typeof NzModalTitleComponent, typeof NzModalTitleDirective, typeof NzModalContainerComponent, typeof NzModalConfirmContainerComponent], [typeof NzModalComponent, typeof NzModalFooterDirective, typeof NzModalContentDirective, typeof NzModalTitleDirective]>; static ɵinj: i0.ɵɵInjectorDeclaration<NzModalModule>; } /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare const nzModalAnimations: { readonly modalContainer: AnimationTriggerMetadata; }; /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ declare function applyConfigDefaults(config: ModalOptions, defaultOptions: ModalOptions): ModalOptions; declare function getValueWithConfig<T>(userValue: T | undefined, configValue: T | undefined, defaultValue: T): T | undefined; declare function getConfigFromComponent<T extends ModalOptions>(component: T): ModalOptions; export { BaseModalContainerComponent, FADE_CLASS_NAME_MAP, MODAL_MASK_CLASS_NAME, ModalOptions, NZ_CONFIG_MODULE_NAME, NZ_MODAL_DATA, NzModalCloseComponent, NzModalComponent, NzModalConfirmContainerComponent, NzModalContainerComponent, NzModalContentDirective, NzModalFooterComponent, NzModalFooterDirective, NzModalLegacyAPI, NzModalModule, NzModalRef, NzModalService, NzModalState, NzModalTitleComponent, NzModalTitleDirective, NzTriggerAction, ZOOM_CLASS_NAME_MAP, applyConfigDefaults, getConfigFromComponent, getValueWithConfig, nzModalAnimations, throwNzModalContentAlreadyAttachedError }; export type { ConfirmType, ModalButtonOptions, ModalTypes, OnClickCallback, StyleObjectLike };