src/ui/dialog/smart-dialog.component.ts
A modal dialog component that supports remote templates and dynamic context
| changeDetection | ChangeDetectionStrategy.Eager |
| selector | smart-dialog |
| styleUrls | ./smart-dialog.component.css |
| templateUrl | ./smart-dialog.component.html |
| viewProviders |
|
Properties |
Methods |
Inputs |
Outputs |
HostListeners |
Accessors |
constructor(inj: Injector, dialogInstanceService: SmartDialogInstanceService, changeDetectorRef: ChangeDetectorRef)
|
||||||||||||
|
Parameters :
|
| altKeyPressed |
Type : boolean
|
| buttons |
Type : string | []
|
|
A comma delimited list of buttons that should be visible on the dialog. |
| component |
Type : any
|
| context |
Type : any
|
| cssClass |
Type : string
|
|
Sets a custom CSS class for the dialog. |
| height |
Type : number | string
|
| hideCloseButton |
Type : boolean
|
|
If set to true, the Smart Dialog will hide the close (X) button. |
| injector |
Type : Injector
|
| opened |
Type : boolean
|
|
Indicates whether the dialog is opened. Updating this property will also hide/show the dialog accordingly. |
| smart-dialog-dependencies |
Type : any[]
|
Default value : []
|
|
(optional) Allows for injecting additional modules as imports in the resulting dialog component. |
| submit-on-enter |
Type : string
|
| templateRef |
Type : TemplateRef<any>
|
| textContent |
Type : string
|
| textDetail |
Type : string
|
| title |
Type : string
|
|
The dialog title. |
| width |
Type : number | string
|
| dialogClosed |
Type : EventEmitter<DialogEvent>
|
| dialogOpened |
Type : EventEmitter<DialogEvent>
|
| keydown.alt | ||||
Arguments : '$event'
|
||||
keydown.alt(event: Event)
|
||||
|
Handles the alt key press event.
Parameters :
|
| keyup | ||||
Arguments : '$event'
|
||||
keyup(event: KeyboardEvent)
|
||||
|
Parameters :
|
| closeDialog | ||||||
closeDialog(button?: DialogButtons)
|
||||||
|
Closes the dialog. param button
Parameters :
Returns :
void
|
| onAltKeyPressed | ||||||
onAltKeyPressed(event: Event)
|
||||||
Decorators :
@HostListener('keydown.alt', ['$event'])
|
||||||
|
Handles the alt key press event.
Parameters :
Returns :
void
|
| onKeyPress | ||||||
onKeyPress(event: KeyboardEvent)
|
||||||
Decorators :
@HostListener('keyup', ['$event'])
|
||||||
|
Parameters :
Returns :
void
|
| onWindowResize |
onWindowResize()
|
Decorators :
@HostListener('window:resize')
|
|
Tracks viewport size so effective min width/height stay clamped to 90vw/90vh. Coalesces multiple resize events per frame via requestAnimationFrame to avoid recomputing the Kendo dialog dimensions on every resize tick.
Returns :
void
void |
| openDialog |
openDialog()
|
|
Displays the dialog. The returned promise resolves when the dialog has been closed, returning a DialogButtons value indicating which button has been clicked.
Returns :
Promise<DialogEvent>
|
| Public changeDetectorRef |
Type : ChangeDetectorRef
|
| closeButton |
Type : DialogButtons
|
| container |
Type : SmartDialogContainer
|
Decorators :
@ViewChild(SmartDialogContainer)
|
| dialogButtons |
Type : DialogButtons[]
|
Default value : []
|
|
The buttons displayed on the dialog, as objects. |
| Readonly dialogComponent |
Type : unknown
|
Default value : viewChild(DialogComponent)
|
| dialogContext |
Type : any
|
Default value : {
templateUrl: null,
template: null,
opened: false,
title: ''
}
|
| dummyTemplate |
Type : TemplateRef<any>
|
Decorators :
@ViewChild('dummyTemplate', {read: TemplateRef, static: true})
|
| hideCloseButton | ||||||
gethideCloseButton()
|
||||||
|
Indicates whether the close (X) button is hidden.
Returns :
boolean
|
||||||
sethideCloseButton(hide: boolean)
|
||||||
|
If set to true, the Smart Dialog will hide the close (X) button.
Parameters :
Returns :
void
|
| cssClass | ||||||||
getcssClass()
|
||||||||
|
Returns the custom CSS class applied to the dialog.
Returns :
string
|
||||||||
setcssClass(val: string)
|
||||||||
|
Sets a custom CSS class for the dialog.
Parameters :
Returns :
void
|
| classList |
getclassList()
|
|
Gets the computed CSS class map for the dialog container.
Returns :
any
|
| opened | ||||||
getopened()
|
||||||
|
Indicates whether the dialog is opened.
Returns :
boolean
|
||||||
setopened(value: boolean)
|
||||||
|
Indicates whether the dialog is opened. Updating this property will also hide/show the dialog accordingly.
Parameters :
Returns :
void
|
| title | ||||||
settitle(value: string)
|
||||||
|
The dialog title.
Parameters :
Returns :
void
|
| width | ||||||
getwidth()
|
||||||
|
Returns :
number | undefined
|
||||||
setwidth(value: number | string)
|
||||||
|
Parameters :
Returns :
void
|
| height | ||||||
getheight()
|
||||||
|
Returns :
number | undefined
|
||||||
setheight(value: number | string)
|
||||||
|
Parameters :
Returns :
void
|
| buttons | ||||||
getbuttons()
|
||||||
|
Returns :
string
|
||||||
setbuttons(buttons: string | DialogButtons[])
|
||||||
|
A comma delimited list of buttons that should be visible on the dialog.
Parameters :
Returns :
void
|
<!--
**************************************************************************
* Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") - *
* www.consultingwerk.com and other contributors as listed *
* below. All Rights Reserved. *
* *
* Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY *
* KIND, either express or implied. *
* *
* Contributors: *
* *
**************************************************************************
--------------------------------------------------------------------------
File : smart-dialog.component.html
Purpose : Template for Smart Dialog.
Author(s) : Radu Nicoara
Created : Dec 07, 2017
--------------------------------------------------------------------------
-->
@if (dialogContext.opened === true) {
<kendo-dialog
[ngClass]="classList"
autoFocusedElement=".k-input .k-input-inner"
[minWidth]="effectiveMinWidth()"
[minHeight]="effectiveMinHeight()"
[maxWidth]="'90vw'"
[maxHeight]="'90vh'"
class="position-relative"
[style.z-index]="99991"
[title]="dialogContext.title"
(close)="closeDialog(closeButton)">
<div class="p-3 smart-dialog-text-content">
@if (!!textContent && !templateRef) {
<p class="mb-3">{{textContent}}</p>
}
@if (!!textDetail && !templateRef) {
<p class="mb-2 text-muted">{{textDetail}}</p>
}
<div smartDialogContainer></div>
</div>
<kendo-dialog-actions class="d-flex justify-content-end gap-2">
@for (btn of dialogButtons; track btn.value) {
<button kendoButton
class="px-4"
[disabled]="btn.disabled ? btn.disabled : false"
[themeColor]="btn.primary ? 'primary' : 'base'"
(click)="closeDialog(btn)">
<span [ngClass]="{ 'mnemonic': btn.mnemonic && altKeyPressed}">{{btn.value.charAt(0)}}</span>
<span>{{btn.value.slice(1)}}</span>
</button>
}
</kendo-dialog-actions>
</kendo-dialog>
<ng-template #dummyTemplate></ng-template>
}
./smart-dialog.component.css
/**********************************************************************
* Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") - *
* www.consultingwerk.com and other contributors as listed *
* below. All Rights Reserved. *
* *
* Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY *
* KIND, either express or implied. *
* *
* Contributors: *
* *
**********************************************************************/
/*------------------------------------------------------------------------
File : smart-dialog.component.css
Purpose : Styles for Smart Dialog.
Author(s) : Radu Nicoara
Created : Dec 07, 2017
----------------------------------------------------------------------*/
::ng-deep kendo-dialog .padded {
padding-right: var(--kendo-spacing-5, 1.25rem) !important;
}
::ng-deep kendo-dialog .k-dialog-title {
overflow: visible !important;
}
::ng-deep .k-dialog.k-dialog-centered {
position: fixed !important;
transform: translate(-50%, -50%);
left: 50% !important;
top: 50% !important;
}
::ng-deep .no-close-btn .k-dialog .k-dialog-titlebar .k-dialog-titlebar-action.k-button[icon='close'] {
visibility: hidden !important;
}
::ng-deep kendo-dialog-actions button.k-button.k-disabled {
opacity: var(--kendo-disabled-opacity, 0.6);
}
::ng-deep smart-dialog kendo-dialog .smart-dialog-text-content {
white-space: pre-wrap;
line-height: var(--kendo-line-height-md, 1.5);
color: var(--kendo-color-on-app-surface, #3d3d3d);
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
}
::ng-deep .mnemonic {
text-decoration: underline !important;
text-decoration-color: var(--kendo-color-primary, #0078d4);
text-underline-offset: var(--kendo-spacing-0.5, 0.125rem);
}
::ng-deep .k-dialog .k-dialog-content {
display: flex;
flex-direction: column;
}
/*
* Dialog content area: flex column that grows the dialog with its content
* (between minHeight and maxHeight = 90vh) and scrolls when content exceeds
* the available height. Scoped to smart-dialog so it does not leak into
* Kendo dialogs created via DialogService or by other components.
*/
::ng-deep smart-dialog .k-dialog .k-dialog-content {
padding: var(--kendo-dialog-inner-padding-y, var(--kendo-spacing-4, 1rem)) var(--kendo-dialog-inner-padding-x, var(--kendo-spacing-4, 1rem));
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
overflow: auto;
}
/*
* Stretch only the dynamically projected component (inserted by
* SmartDialogContainer's ViewContainerRef as a sibling AFTER the host marker)
* so it fills the available content space. Static text nodes (textContent,
* textDetail) sit before the marker and keep their natural size.
*/
::ng-deep smart-dialog .smart-dialog-text-content > [smartDialogContainer] ~ * {
flex: 1;
min-height: 0;
}
/*
* Preserve line breaks in messages shown via DialogService (SmartMessageService
* passes plain-string content, which Kendo renders as a text node that would
* otherwise collapse the embedded \n). Scoped to the smart-message-dialog
* cssClass set on that dialog so it does not affect other DialogService dialogs.
*/
::ng-deep .smart-message-dialog .k-dialog-content {
white-space: pre-wrap;
}
::ng-deep .k-dialog-actions {
padding: var(--kendo-dialog-buttongroup-padding-y, var(--kendo-spacing-3, 0.75rem)) var(--kendo-dialog-buttongroup-padding-x,var(--kendo-spacing-4, 1rem));
gap: var(--kendo-dialog-buttongroup-spacing, var(--kendo-spacing-2, 0.5rem));
background-color: var(--kendo-color-surface-alt, #f8f9fa);
border-top: 1px solid var(--kendo-color-border, #d7d2d0);
}
/* Dialog button improvements */
::ng-deep kendo-dialog-actions button.k-button {
min-width: var(--kendo-spacing-20, 5rem);
padding: var(--kendo-spacing-2, 0.5rem) var(--kendo-spacing-4, 1rem);
}
/* Prevent layout displacement caused by dialog container positioning */
::ng-deep .k-dialog-wrapper {
position: fixed !important;
z-index: 99992 !important;
}
/* Ensure dialog backdrop doesn't interfere with main layout */
::ng-deep .k-overlay {
position: fixed !important;
top: 0 !important;
left: 0 !important;
width: 100% !important;
height: 100% !important;
z-index: 99989 !important;
}
/*
* Ensure the dialog itself appears above the overlay and uses a flex
* column layout so the .k-dialog-content area can flex within the dialog's
* (Kendo-managed) min/max height.
*/
::ng-deep .k-dialog {
z-index: 99991 !important;
display: flex;
flex-direction: column;
}
/* Prevent body scroll lock issues that can cause layout displacement */
::ng-deep body.k-dialog-open {
overflow: inherit !important;
}