UNPKG

@obliczeniowo/elementary

Version:
141 lines (130 loc) 5.98 kB
import * as i0 from '@angular/core'; import { TemplateRef, Type, OnInit, EventEmitter, ViewContainerRef, Injector } from '@angular/core'; import * as i6 from '@angular/cdk/overlay'; import { OverlayRef, OverlayContainer, Overlay, OverlayConfig } from '@angular/cdk/overlay'; import { Subject } from 'rxjs'; import * as i5 from '@angular/common'; import * as i7 from '@obliczeniowo/elementary/buttons'; import * as i8 from '@obliczeniowo/elementary/icons'; interface OverlayCloseEvent<R> { type: 'backdropClick' | 'close'; data: R; } declare class DialogOverlayRef<R = any, T = any> { overlay: OverlayRef; content: string | TemplateRef<any> | Type<any>; data: T | undefined; afterClosed: Subject<OverlayCloseEvent<R | undefined>>; constructor(overlay: OverlayRef, content: string | TemplateRef<any> | Type<any>, data: T | undefined); close(data?: R | undefined): void; private _close; } declare class DialogComponent implements OnInit { private readonly ref; private readonly overlayContainer; private static dialogsCount; private static onOpen; static onClose(overlayContainer: HTMLElement): void; closed: EventEmitter<any>; afterClosed: Subject<any>; contentType: 'template' | 'string' | 'component'; content: string | TemplateRef<any> | Type<any>; context: any; viewContainerRef: ViewContainerRef; protected component: any; constructor(ref: DialogOverlayRef, overlayContainer: OverlayContainer); close(): void; ngOnInit(): void; ngOnDestroy(): void; get template(): TemplateRef<any>; private createComponent; private _close; static ɵfac: i0.ɵɵFactoryDeclaration<DialogComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<DialogComponent, "obl-dialog", never, {}, { "closed": "closed"; }, never, never, false, never>; } declare class DialogHeaderComponent { closeAction: EventEmitter<void>; static ɵfac: i0.ɵɵFactoryDeclaration<DialogHeaderComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<DialogHeaderComponent, "obl-dialog-header", never, {}, { "closeAction": "closeAction"; }, never, ["title"], false, never>; } declare class DialogService { private readonly overlay; private readonly injector; constructor(overlay: Overlay, injector: Injector); open<R = any, T = any>(content: string | TemplateRef<any> | Type<any>, options?: { data?: T; config?: OverlayConfig; }): DialogOverlayRef<R>; createInjector(ref: DialogOverlayRef, inj: Injector): Injector; static ɵfac: i0.ɵɵFactoryDeclaration<DialogService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<DialogService>; } interface OverlayConfigExt extends OverlayConfig { /** external option to add some own data to modal */ data?: any; } /** * A simple dialog wrapper to use with ng-content to make a job done * * @example * * <obl-dialog-wrapper header="I want to play a game" #dialogWrapper> * <div style="padding: 10px">Life or die make your choice</div> * <div style="display: flex; justify-content: flex-end; padding: 10px; background-color: aliceblue;"> * <button oblButton (click)="dialogWrapper.close()">Life</button> * <button oblButton (click)="dialogWrapper.close()">Die</button> * </div> * </obl-dialog-wrapper> * * <button (click)="dialogWrapper.open()" oblButton>Open dialog things</button> */ declare class DialogWrapperComponent implements OnInit { private readonly dialog; header: i0.InputSignal<string>; closed: EventEmitter<any>; cancel: EventEmitter<any>; template: TemplateRef<any>; data: any; protected opened: boolean; protected dialogRef: DialogOverlayRef<any, any> | undefined; constructor(dialog: DialogService); ngOnInit(): void; ngOnDestroy(): void; open(config?: OverlayConfigExt): void; close(): void; static ɵfac: i0.ɵɵFactoryDeclaration<DialogWrapperComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<DialogWrapperComponent, "obl-dialog-wrapper", never, { "header": { "alias": "header"; "required": true; "isSignal": true; }; }, { "closed": "closed"; "cancel": "cancel"; }, never, ["*"], false, never>; } /** * Just message dialog that you can use by HTML: * * @example * * <obl-message-dialog header="I want to play a game" #message> * <ng-container message> * Live or die make your choice * </ng-container> * <ng-container buttons> * <button oblButton (click)="message.close()">Live</button> * <button oblButton (click)="message.close()">Die</button> * </ng-container> * </obl-message-dialog> * * <button (click)="message.open({ width: '600px' })" oblButton>Open dialog things</button> */ declare class MessageDialogComponent { header: i0.InputSignal<string>; protected dialog: DialogWrapperComponent; data: any; open(config?: OverlayConfigExt | undefined): void; close(): void; static ɵfac: i0.ɵɵFactoryDeclaration<MessageDialogComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<MessageDialogComponent, "obl-message-dialog", never, { "header": { "alias": "header"; "required": true; "isSignal": true; }; }, {}, never, ["[message]", "[buttons]"], false, never>; } declare class DialogsModule { static ɵfac: i0.ɵɵFactoryDeclaration<DialogsModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<DialogsModule, [typeof DialogComponent, typeof DialogHeaderComponent, typeof DialogWrapperComponent, typeof MessageDialogComponent], [typeof i5.CommonModule, typeof i6.OverlayModule, typeof i7.ButtonsModule, typeof i8.IconsModule], [typeof DialogComponent, typeof DialogHeaderComponent, typeof DialogWrapperComponent, typeof MessageDialogComponent]>; static ɵinj: i0.ɵɵInjectorDeclaration<DialogsModule>; } export { DialogComponent, DialogHeaderComponent, DialogService, DialogWrapperComponent, DialogsModule, MessageDialogComponent }; export type { OverlayConfigExt };