Dialog

A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.

Installation

npx nx g @spartan-ng/cli:ui dialog

Usage

import { BrnDialogContentDirective, BrnDialogTriggerDirective } from '@spartan-ng/brain/dialog';
import {
  HlmDialog
  HlmDialogContent
  HlmDialogDescription
  HlmDialogFooter
  HlmDialogHeader
  HlmDialogTitle
} from '@spartan-ng/helm/dialog';
<hlm-dialog>
  <button brnDialogTrigger hlmBtn>Edit Profile</button>
  <hlm-dialog-content *brnDialogContent="let ctx">
    <hlm-dialog-header>
      <h3 brnDialogTitle hlm>Edit profile</h3>
      <p brnDialogDescription hlm>Make changes to your profile here. Click save when you're done.</p>
    </hlm-dialog-header>
    <hlm-dialog-footer>
      <button hlmBtn type="submit">Save changes</button>
    </hlm-dialog-footer>
  </hlm-dialog-content>
</hlm-dialog>

Brain API

BrnDialogClose

Selector: button[brnDialogClose]

Inputs

PropTypeDefaultDescription
delay number | undefined undefined -

BrnDialogContent

Selector: [brnDialogContent]

Inputs

PropTypeDefaultDescription
class string | null | undefined undefined -
context T | undefined undefined -

BrnDialogDescription

Selector: [brnDialogDescription]

BrnDialogOverlay

Selector: brn-dialog-overlay

Inputs

PropTypeDefaultDescription
class string | null | undefined undefined -

BrnDialogTitle

Selector: [brnDialogTitle]

BrnDialogTrigger

Selector: button[brnDialogTrigger],button[brnDialogTriggerFor]

ExportAs: brnDialogTrigger

Inputs

PropTypeDefaultDescription
id unknown `brn-dialog-trigger-${idSequence++}` -
brnDialogTriggerFor BrnDialog | undefined undefined -

BrnDialog

Selector: brn-dialog

ExportAs: brnDialog

Inputs

PropTypeDefaultDescription
state BrnDialogState | null null -
role BrnDialogOptions['role'] this._defaultOptions.role -
hasBackdrop unknown this._defaultOptions.hasBackdrop -
positionStrategy BrnDialogOptions['positionStrategy'] this._defaultOptions.positionStrategy -
scrollStrategy BrnDialogOptions['scrollStrategy'] | 'close' | 'reposition' | null this._defaultOptions.scrollStrategy -
restoreFocus BrnDialogOptions['restoreFocus'] this._defaultOptions.restoreFocus -
closeOnOutsidePointerEvents unknown this._defaultOptions.closeOnOutsidePointerEvents -
closeOnBackdropClick unknown this._defaultOptions.closeOnBackdropClick -
attachTo BrnDialogOptions['attachTo'] null -
attachPositions BrnDialogOptions['attachPositions'] this._defaultOptions.attachPositions -
autoFocus BrnDialogOptions['autoFocus'] this._defaultOptions.autoFocus -
closeDelay unknown this._defaultOptions.closeDelay -
disableClose unknown this._defaultOptions.disableClose -
aria-describedby BrnDialogOptions['ariaDescribedBy'] null -
aria-labelledby BrnDialogOptions['ariaLabelledBy'] null -
aria-label BrnDialogOptions['ariaLabel'] null -
aria-modal unknown true -

Outputs

PropTypeDefaultDescription
closed any --
stateChanged BrnDialogState --

Helm API

HlmDialogClose

Selector: [hlmDialogClose],[brnDialogClose][hlm]

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmDialogContent

Selector: hlm-dialog-content

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmDialogDescription

Selector: [hlmDialogDescription]

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmDialogFooter

Selector: hlm-dialog-footer

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmDialogHeader

Selector: hlm-dialog-header

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmDialogOverlay

Selector: [hlmDialogOverlay],brn-dialog-overlay[hlm]

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmDialogTitle

Selector: [hlmDialogTitle]

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmDialog

Selector: hlm-dialog

ExportAs: hlmDialog

Declarative Usage

Spartan's dialog supports declarative usage. Simply set it's state input to open or closed and let spartan handle the rest. This allows you to leverage the power of declarative code, like listening to changes in an input field, debouncing the value, and opening the dialog only if the user's enters the correct passphrase.

Enter passphrase to open dialog

Inside Menu

You can nest dialogs inside context or dropdown menus. Make sure to wrap the menu-item inside the brn-dialog component and apply the BrnDialogTrigger directive. Another option is to use the brnDialogTriggerFor alternative, which takes in a reference to the brn-dialog. That way you can avoid nesting the template.

Right click here

Dynamic Component

You can dynamically open a dialog with a component rendered as the content. The dialog context can be injected into the dynamic component using the provided injectBrnDialogContext function.

Close Dialog

You can close the dialog by using a directive, a template reference, or a viewchild/contentchild reference to the dialog.

Dropdown Menu Data Table