carbon-components-angular
Version:
Next generation components
179 lines (175 loc) • 6.38 kB
TypeScript
/**
*
* carbon-angular v0.0.0 | dialog.directive.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, OnInit, OnDestroy, ElementRef, TemplateRef, ViewContainerRef, OnChanges, SimpleChanges, ComponentRef } from "@angular/core";
import { DialogService } from "./dialog.service";
import { CloseMeta, DialogConfig } from "./dialog-config.interface";
import { EventService } from "carbon-components-angular/utils";
import { Dialog } from "./dialog.component";
import * as i0 from "@angular/core";
/**
* A generic directive that can be inherited from to create dialogs (for example, a tooltip or popover)
*
* This class contains the relevant initialization code, specific templates, options, and additional inputs
* should be specified in the derived class.
*
* NOTE: All child classes should add `DialogService` as a provider, otherwise they will lose context that
* the service relies on.
*/
export declare class DialogDirective implements OnInit, OnDestroy, OnChanges {
protected elementRef: ElementRef;
protected viewContainerRef: ViewContainerRef;
protected dialogService: DialogService;
/**
* Deprecated as of v5
*/
protected eventService: EventService;
static dialogCounter: number;
/**
* Title for the dialog
*/
title: string;
/**
* @deprecated as of v5, use `cdsDialog` instead
* Dialog body content.
*/
set ibmDialog(body: string | TemplateRef<any>);
cdsDialog: string | TemplateRef<any>;
/**
* Defines how the Dialog is triggered.(Hover and click behave the same on mobile - both respond to a single tap).
* Do not add focusable elements if trigger is `hover` or `mouseenter`.
*/
trigger: "click" | "hover" | "mouseenter";
/**
* Defines how the Dialog close event is triggered.
*
* [See here](https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseleave_event)
* for more on the difference between `mouseleave` and `mouseout`.
*
* Defaults to `click` when `trigger` is set to `click`.
*/
closeTrigger: "mouseout" | "mouseleave";
/**
* Placement of the dialog, usually relative to the element the directive is on.
*/
placement: string;
/**
* This specifies any vertical and horizontal offset for the position of the dialog
*/
offset: {
x: number;
y: number;
};
/**
* Classes to add to the dialog container
*/
wrapperClass: string;
/**
* Spacing between the dialog and it's triggering element
*/
gap: number;
/**
* Set to `true` to open the dialog next to the triggering component
*/
appendInline: boolean;
/**
* Optional data for templates
*/
data: {};
isOpen: boolean;
/**
* This prevents the dialog from being toggled
*/
disabled: boolean;
/**
* This input allows explicit control over how the dialog should close
*/
shouldClose: (meta: CloseMeta) => boolean;
/**
* Config object passed to the rendered component
*/
dialogConfig: DialogConfig;
/**
* Emits an event when the dialog is closed
*/
onClose: EventEmitter<any>;
/**
* Emits an event when the dialog is opened
*/
onOpen: EventEmitter<any>;
/**
* Emits an event when the state of `isOpen` changes. Allows `isOpen` to be double bound
*/
isOpenChange: EventEmitter<boolean>;
role: string;
hasPopup: boolean;
get ariaOwns(): string;
/**
* Keeps a reference to the currently opened dialog
*/
protected dialogRef: ComponentRef<Dialog>;
private subscriptions;
/**
* Creates an instance of DialogDirective.
* @param elementRef
* @param viewContainerRef
* @param dialogService
* @param eventService
*/
constructor(elementRef: ElementRef, viewContainerRef: ViewContainerRef, dialogService: DialogService,
/**
* Deprecated as of v5
*/
eventService: EventService);
ngOnChanges(changes: SimpleChanges): void;
/**
* Sets the config object and binds events for hovering or clicking before
* running code from child class.
*/
ngOnInit(): void;
/**
* When the host dies, kill the popover.
* - Useful for use in a modal or similar.
*/
ngOnDestroy(): void;
/**
* Helper method to call dialogService 'open'.
* - Enforce accessibility by updating an aria attr for nativeElement.
*/
open(component?: any): ComponentRef<Dialog>;
/**
* Helper method to toggle the open state of the dialog
*/
toggle(meta?: CloseMeta): void;
/**
* Helper method to close the dialogRef.
*/
close(meta?: CloseMeta): void;
/**
* Empty method for child classes to override and specify additional init steps.
* Run after DialogDirective completes it's ngOnInit.
*/
protected onDialogInit(): void;
/**
* Empty method for child to override and specify additional on changes steps.
* run after DialogDirective completes it's ngOnChanges.
*/
protected onDialogChanges(_changes: SimpleChanges): void;
protected updateConfig(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<DialogDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<DialogDirective, "[cdsDialog], [ibmDialog]", ["dialog"], { "title": "title"; "ibmDialog": "ibmDialog"; "cdsDialog": "cdsDialog"; "trigger": "trigger"; "closeTrigger": "closeTrigger"; "placement": "placement"; "offset": "offset"; "wrapperClass": "wrapperClass"; "gap": "gap"; "appendInline": "appendInline"; "data": "data"; "isOpen": "isOpen"; "disabled": "disabled"; "shouldClose": "shouldClose"; }, { "onClose": "onClose"; "onOpen": "onOpen"; "isOpenChange": "isOpenChange"; }, never, never, false>;
}