@blox/material
Version:
Material Components for Angular
181 lines (180 loc) • 7.73 kB
TypeScript
import { AfterContentInit, ElementRef, EventEmitter, OnDestroy, OnInit, Renderer2 } from '@angular/core';
import { MdcEventRegistry } from '../../utils/mdc.event.registry';
import { AbstractMdcFocusInitial, AbstractMdcFocusTrap } from '../focus-trap/abstract.mdc.focus-trap';
import { HasId } from '../abstract/mixin.mdc.hasid';
declare class MdcDialogTitleDirectiveBase {
}
interface MdcDialogTitleDirectiveBase extends HasId {
}
/**
* Directive for the title of an `mdcDialog`.
* A title is optional. If used, it should be the first child of an `mdcDialogSurface`.
* Please note that there should be no whitespace separating the start/end tag and the title
* itself. (The easiest way to achieve this is to *not* set the `preserveWhitespaces` option to
* `true` the `angularCompilerOptions`).
*/
export declare class MdcDialogTitleDirective extends MdcDialogTitleDirectiveBase implements OnInit {
ngOnInit(): void;
}
declare class MdcDialogContentDirectiveBase {
}
interface MdcDialogContentDirectiveBase extends HasId {
}
/**
* Directive for the content part of an `mdcDialog`.
* This should be added as a child element of an `mdcDialogSurface`.
*/
export declare class MdcDialogContentDirective extends MdcDialogContentDirectiveBase implements OnInit {
_elm: ElementRef;
constructor(_elm: ElementRef);
ngOnInit(): void;
}
/**
* Directive for the actions (footer) of an `mdcDialog`.
* This is an (optional) last child of the `mdcDialogSurface` directive.
* This directive should contain buttons, for that should use the `mdcButton`
* directive.
*
* Action buttons should typically close the dialog, and should therefore
* also set a value for the `mdcDialogTrigger` directive.
*/
export declare class MdcDialogActionsDirective implements AfterContentInit {
private _rndr;
constructor(_rndr: Renderer2);
ngAfterContentInit(): void;
private initButtons;
}
/**
* Any element within a dialog may include this directive (and assigne a non empty value to it)
* to indicate that interacting with it should close the dialog with the specified action.
*
* This action is then reflected via the `action` field in the `closing` and `closed` events of
* the dialog. A value of `close` will also trigger the `cancel` event of the dialog, and a value of
* `accept` will trigger the `accept` event.
*
* Any action buttons within the dialog that equate to a dismissal with no further action should
* use set `mdcDialogTrigger="close"`. This will make it easy to handle all such interactions consistently
* (via either the `cancel`, `closing`, or `closed` events), while separately handling other actions.
*/
export declare class MdcDialogTriggerDirective {
_elm: ElementRef;
constructor(_elm: ElementRef);
/**
* Set the `action` value that should be send to `closing` and `closed` events when a user
* interacts with this element. (When set to an empty string the button/element will not be wired
* to close the dialog).
*/
mdcDialogTrigger: string | null;
}
/**
* This directive can be used to mark one of the dialogs action buttons as the default action.
* This action will then be triggered by pressing the enter key while the dialog has focus.
* The default action also will receive focus when the dialog is opened. Unless another
* element within the dialog has the `mdcFocusInitial` directive.
*/
export declare class MdcDialogDefaultDirective extends AbstractMdcFocusInitial {
_elm: ElementRef;
constructor(_elm: ElementRef);
}
/**
* Directive for the surface of a dialog. The surface contains the actual content of a dialog,
* wrapped in elements with the `mdcDialogHeader`, `mdcDialogContent`, and `mdcDialogActions`
* directives.
*
* # Accessibility
* * The role attribute will be set to `alertdialog` by default
* * The `aria-modal` attribute will be set to `true` by default
* * If there is an `mdcDialogTitle`, the `aria-labelledBy` attribute will be set to the id
* of that element (and a unique id will be assigned to it, if none was provided)
* * If there is an `mdcDialogContent`, the `aria-describedby` attribute will be set to the
* id of that element (and a unique id will be assigned to it, if none was provided)
*/
export declare class MdcDialogSurfaceDirective {
ngAfterContentInit(): void;
private setAriaLabels;
}
/**
* This directive should be the first child of an `mdcDialog`, and contains the `mdcDialogSurface`.
*/
export declare class MdcDialogContainerDirective {
}
/**
* Directive for the backdrop of a dialog. The backdrop provides the styles for overlaying the
* page content when the dialog is opened. This guides user attention to the dialog.
*/
export declare class MdcDialogScrimDirective {
}
/**
* Directive for creating a modal dialog with Material Design styling. The dialog should have two
* child elements: a surface (marked with the <code>mdcDialogSurface</code> directive), and a
* backdrop (marked with the <code>mdcDialogBackdrop</code> directive).
*
* When the dialog is opened, it will activate a focus trap on the elements within the dialog,
* so that the surface behind the dialog is not accessible. See `mdcFocusTrap` for more information.
*/
export declare class MdcDialogDirective implements AfterContentInit, OnDestroy {
private _elm;
private _rndr;
private _registry;
private _focusTrap;
/**
* Event emitted when the user accepts the dialog, e.g. by pressing enter or clicking the button
* with `mdcDialogTrigger="accept"`.
*/
readonly accept: EventEmitter<void>;
/**
* Event emitted when the user cancels the dialog, e.g. by clicking outside the dialog, pressing the escape key,
* or clicking an element with `mdcDialogTrigger="close"`.
*/
readonly cancel: EventEmitter<void>;
/**
* Event emitted when the dialog starts opening.
*/
readonly opening: EventEmitter<void>;
/**
* Event emitted when the dialog is opened.
*/
readonly opened: EventEmitter<void>;
/**
* Event emitted when the dialog starts closing. The 'action' field contains the reason for closing, see
* `mdcDialogTrigger` for more information.
*/
readonly closing: EventEmitter<{
action: string;
}>;
/**
* Event emitted when the dialog is closed. The 'action' field contains the reason for closing, see
* `mdcDialogTrigger` for more information.
*/
readonly closed: EventEmitter<{
action: string;
}>;
private _onDocumentKeydown;
private focusTrapHandle;
private mdcAdapter;
private foundation;
private document;
constructor(_elm: ElementRef, _rndr: Renderer2, _registry: MdcEventRegistry, _focusTrap: AbstractMdcFocusTrap, doc: any);
ngAfterContentInit(): void;
ngOnDestroy(): void;
/**
* Call this method to open the dialog.
*/
open(): void;
/**
* Call this method to close the dialog with the specified action, e.g. `accept` to indicate an acceptance action
* (and trigger the `accept` event), or `close` to indicate dismissal (and trigger the `cancel` event).
*/
close(action?: string): void;
/**
* Recalculates layout and automatically adds/removes modifier classes (for instance to detect if the dialog content
* should be scrollable)
*/
layout(): void;
private trapFocus;
private untrapFocus;
private get _content();
private closest;
}
export declare const DIALOG_DIRECTIVES: (typeof MdcDialogContentDirective | typeof MdcDialogActionsDirective | typeof MdcDialogTriggerDirective | typeof MdcDialogDefaultDirective | typeof MdcDialogContainerDirective | typeof MdcDialogDirective)[];
export {};