UNPKG

carbon-components-angular

Version:
124 lines (120 loc) 4.56 kB
/** * * carbon-angular v0.0.0 | dialog.component.d.ts * * Copyright 2014, 2025 IBM * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { EventEmitter, ElementRef, OnInit, AfterViewInit, OnDestroy } from "@angular/core"; import { Subscription } from "rxjs"; import { AbsolutePosition, Positions } from "@carbon/utils-position"; import { CloseMeta, DialogConfig } from "./dialog-config.interface"; import { AnimationFrameService, ElementService } from "carbon-components-angular/utils"; import * as i0 from "@angular/core"; /** * Implements a `Dialog` that can be positioned anywhere on the page. * Used to implement a popover or tooltip. */ export declare class Dialog implements OnInit, AfterViewInit, OnDestroy { protected elementRef: ElementRef; protected elementService: ElementService; protected animationFrameService: AnimationFrameService; /** * Emits event that handles the closing of a `Dialog` object. */ close: EventEmitter<CloseMeta>; /** * Receives `DialogConfig` interface object with properties of `Dialog` * explicitly defined. */ dialogConfig: DialogConfig; /** * Maintains a reference to the view DOM element of the `Dialog`. */ dialog: ElementRef; /** * Stores the data received from `dialogConfig`. */ data: {}; /** * The placement of the `Dialog` is received from the `Position` service. */ placement: string; protected visibilitySubscription: Subscription; protected animationFrameSubscription: Subscription; /** * Handles offsetting the `Dialog` item based on the defined position * to not obscure the content beneath. */ protected addGap: { left: (pos: any) => AbsolutePosition; right: (pos: any) => AbsolutePosition; top: (pos: any) => AbsolutePosition; bottom: (pos: any) => AbsolutePosition; "left-bottom": (pos: any) => AbsolutePosition; "right-bottom": (pos: any) => AbsolutePosition; }; /** * Extra placements. Child classes can add to this for use in `placeDialog`. */ protected placements: Positions; /** * Creates an instance of `Dialog`. * @param elementRef * @param elementService */ constructor(elementRef: ElementRef, elementService: ElementService, animationFrameService?: AnimationFrameService); /** * Initialize the `Dialog`, set the placement and gap, and add a `Subscription` to resize events. */ ngOnInit(): void; /** * After the DOM is ready, focus is set and dialog is placed * in respect to the parent element. */ ngAfterViewInit(): void; /** * Empty method to be overridden by consuming classes to run any additional initialization code. */ onDialogInit(): void; /** * Empty method to be overridden by consuming classes to run any additional initialization code after the view is available. * NOTE: this does _not_ guarantee the dialog will be positioned, simply that it will exist in the DOM */ afterDialogViewInit(): void; /** * Uses the position service to position the `Dialog` in screen space */ placeDialog(): void; /** * Sets up a KeyboardEvent to close `Dialog` with Escape key. * @param event */ escapeClose(event: KeyboardEvent): void; /** * Sets up a event Listener to close `Dialog` if click event occurs outside * `Dialog` object. * @param event */ clickClose(event: any): void; /** * Closes `Dialog` object by emitting the close event upwards to parents. */ doClose(meta?: CloseMeta): void; /** * At destruction of component, `Dialog` unsubscribes from all the subscriptions. */ ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration<Dialog, [null, null, { optional: true; }]>; static ɵcmp: i0.ɵɵComponentDeclaration<Dialog, "cds-dialog, ibm-dialog", never, { "dialogConfig": "dialogConfig"; }, { "close": "close"; }, never, never, false>; }