File

projects/ui-kit-lib/src/lib/v2/modals/dialog-ref.ts

Description

Strongly-typed wrapper around CDK's DialogRef with MEF/MD container integration.

Responsibilities:

  • Expose open/close lifecycle streams (afterOpened, beforeClosed, afterClosed).
  • Respect disableClose, ESC and backdrop click behavior.
  • Start/await container animations and provide a fallback close timeout.
  • Bridge size/position/panel class updates to the underlying CDK dialog.
  • Track the interaction type (mouse/keyboard) that triggered close for focus restoration.

Index

Properties
Methods

Constructor

constructor(_ref: DialogRef, _config: MefDevDialogConfig, _containerInstance: MDDialogContainer)
Parameters :
Name Type Optional
_ref DialogRef<R | T> No
_config MefDevDialogConfig No
_containerInstance MDDialogContainer No

Properties

Public _containerInstance
Type : MDDialogContainer

Reference to the container component that hosts animations and structure.

componentInstance
Type : T

Instance of the component hosted inside the dialog (if opened via component).

Readonly componentRef
Type : ComponentRef<T> | null

Low-level componentRef for advanced users (null for TemplateRef opens).

disableClose
Type : boolean | undefined

When true, ESC and backdrop click won't close the dialog.

id
Type : string

Dialog id (auto-generated unless provided in config).

Methods

addPanelClass
addPanelClass(classes: string | string[])

Adds one or more CSS classes to the overlay panel.

Parameters :
Name Type Optional
classes string | string[] No
Returns : unknown
afterClosed
afterClosed()

Stream that emits the result after the dialog is fully closed and disposed.

Returns : Observable<R | undefined>
afterOpened
afterOpened()

Stream that emits once the dialog is fully opened (after enter animation).

Returns : Observable<void>
backdropClick
backdropClick()

Backdrop click stream (useful for custom close logic / analytics).

Returns : Observable<MouseEvent>
beforeClosed
beforeClosed()

Stream that emits right before the dialog starts closing with the result (if any).

Returns : Observable<R | undefined>
close
close(dialogResult?: R)

Programmatically close the dialog with an optional result. Respects an optional closePredicate to veto the close.

Parameters :
Name Type Optional
dialogResult R Yes
Returns : void
getState
getState()

Returns the current lifecycle state of the dialog.

Returns : DialogState
keydownEvents
keydownEvents()

Keydown stream scoped to the dialog overlay (e.g., listen for ESC).

Returns : Observable<KeyboardEvent>
removePanelClass
removePanelClass(classes: string | string[])

Removes one or more CSS classes from the overlay panel.

Parameters :
Name Type Optional
classes string | string[] No
Returns : unknown
updatePosition
updatePosition(position?: DialogPosition)

Updates the dialog position. If top/bottom or left/right are not provided, the dialog will be centered on that axis.

Parameters :
Name Type Optional
position DialogPosition Yes
Returns : unknown
updateSize
updateSize(width: string, height: string)

Updates dialog width/height (CSS length values, e.g. '600px', '80vh').

Parameters :
Name Type Optional Default value
width string No ''
height string No ''
Returns : unknown

results matching ""

    No results matching ""