import { KbqModalModule } from '@koobiq/components/modal';

KbqModalCaption

componentCopy link to KbqModalCaption

Caption of a manually composed modal (kbqComponent). Projected into the header rendered by KbqModalTitle, below the title, and clamped to two lines. The resulting markup matches the header of a modal created via KbqModalService.create.

@Component({
    selector: '[kbq-modal-caption], kbq-modal-caption, [kbqModalCaption]'
})
class KbqModalCaption {}

KbqModalComponent

componentCopy link to KbqModalComponent
@Component({ selector: 'kbq-modal' })
class KbqModalComponent<T = any, R = any> extends KbqModalRef<T, R> implements KbqModal {
    readonly kbqModalType = input<ModalType>(
        this.options?.kbqModalType ?? 'default'
    );
    readonly kbqComponent = input<Type<T> | undefined>(
        this.options?.kbqComponent
    );
    readonly kbqContent = input<string | TemplateRef<{}> | Type<T> | undefined>(
        this.options?.kbqContent
    );
    readonly kbqFooter = input<string | TemplateRef<{}> | IModalButtonOptions<T>[] | undefined>(
        this.options?.kbqFooter
    );
    readonly kbqVisible = model<boolean>(
        this.options?.kbqVisible ?? false
    );
    readonly kbqWidth = input<number | string | undefined>(
        this.options?.kbqWidth
    );
    readonly kbqSize = input<ModalSize>(
        this.options?.kbqSize ?? ModalSize.Medium
    );
    readonly kbqWrapClassName = input<string | undefined>(
        this.options?.kbqWrapClassName
    );
    readonly kbqClassName = input<string | undefined>(
        this.options?.kbqClassName
    );
    readonly kbqStyle = input<object | undefined>(
        this.options?.kbqStyle
    );
    readonly kbqTitle = input<string | TemplateRef<{}> | undefined>(
        this.options?.kbqTitle
    );
    readonly kbqCaption = input<string | TemplateRef<{}> | undefined>(
        this.options?.kbqCaption
    );
    readonly kbqCloseByESC = input<boolean>(
        this.options?.kbqCloseByESC ?? true
    );
    readonly kbqAutoFocus = input<KbqModalAutoFocus>(
        this.options?.kbqAutoFocus ?? 'first-tabbable'
    );
    readonly kbqAriaLabel = input<string | undefined>(
        this.options?.kbqAriaLabel
    );
    readonly kbqClosable = input<boolean>(
        this.options?.kbqClosable ?? true
    );
    readonly kbqMask = input<boolean>(this.options?.kbqMask ?? true);
    readonly kbqMaskClosable = input<boolean>(
        this.options?.kbqMaskClosable ?? false
    );
    readonly kbqMaskStyle = input<object | undefined>(
        this.options?.kbqMaskStyle
    );
    readonly kbqBodyStyle = input<object | undefined>(
        this.options?.kbqBodyStyle
    );
    readonly kbqOkText = input<string | undefined>(
        this.options?.kbqOkText
    );
    readonly kbqOkType = input<KbqButtonColor>(
        this.options?.kbqOkType ?? KbqComponentColors.Contrast
    );
    readonly kbqRestoreFocus = input<boolean>(
        this.options?.kbqRestoreFocus ?? true
    );
    readonly kbqOkLoading = input<boolean>(
        this.options?.kbqOkLoading ?? false
    );
    readonly kbqOkClick = input<OnClickCallback<T> | undefined>(
        this.options?.kbqOkClick
    );
    readonly kbqCancelText = input<string | undefined>(
        this.options?.kbqCancelText
    );
    readonly kbqCancelLoading = input<boolean>(
        this.options?.kbqCancelLoading ?? false
    );
    readonly kbqCancelClick = input<OnClickCallback<T> | undefined>(
        this.options?.kbqCancelClick
    );
    readonly kbqGetContainer = input<HTMLElement | OverlayRef | (() => HTMLElement | OverlayRef) | null>(
        this.options ? (this.options.kbqGetContainer ?? null) : () => this.overlay.create()
    );
    componentColors: typeof KbqComponentColors;
    readonly kbqAfterOpen: EventEmitter<void>;
    readonly kbqAfterClose: EventEmitter<R | undefined>;
    readonly kbqBeforeClose: EventEmitter<R | undefined>;
    readonly kbqOnOk: EventEmitter<T>;
    readonly kbqOnCancel: EventEmitter<T>;
    readonly modalContainer: Signal<ElementRef<any>>;
    readonly bodyContainer: Signal<ViewContainerRef>;
    readonly titleId: string;
    readonly captionId: string;
    get afterOpen(): Observable<void>;
    get beforeClose(): Observable<R | undefined>;
    get afterClose(): Observable<R | undefined>;
    get hidden(): boolean;
    open(): void;
    close(result?: R): void;
    destroy(result?: R): void;
    markForCheck(): void;
    triggerOk(): void;
    triggerCancel(): void;
    getInstance(): KbqModalComponent;
    getContentComponentRef(): ComponentRef<T>;
    getContentComponent(): T;
    getElement(): HTMLElement;
    onClickCloseBtn(): void;
}
kbqModalTypeinputCopy link to kbqModalTypeModalType

Layout the dialog renders.

kbqComponentinputCopy link to kbqComponentType<T> | undefined

The instance of component opened into the dialog.

kbqContentinputCopy link to kbqContentstring | TemplateRef<{}> | Type<T> | undefined

Body of the dialog: text, a template or a component class. Falls back to <ng-content>.

kbqFooterinputCopy link to kbqFooterstring | TemplateRef<{}> | IModalButtonOptions<T>[] | undefined

Footer of the dialog: text, a template, or the buttons to render. Default modal ONLY.

kbqVisiblemodelCopy link to kbqVisibleboolean

Whether the dialog is shown. Two-way bindable as [(kbqVisible)].

kbqWidthinputCopy link to kbqWidthnumber | string | undefined

Explicit width, overriding the one kbqSize implies. A number is read as pixels.

kbqSizeinputCopy link to kbqSizeModalSize

Width preset.

kbqWrapClassNameinputCopy link to kbqWrapClassNamestring | undefined

Extra class names for the full-screen wrapper around the dialog.

kbqClassNameinputCopy link to kbqClassNamestring | undefined

Extra class names for the dialog element itself.

kbqStyleinputCopy link to kbqStyleobject | undefined

Inline styles for the dialog element.

kbqTitleinputCopy link to kbqTitlestring | TemplateRef<{}> | undefined

Heading of the dialog. Also becomes its accessible name.

kbqCaptioninputCopy link to kbqCaptionstring | TemplateRef<{}> | undefined

Secondary line under the heading. Also becomes the dialog's accessible description.

kbqCloseByESCinputCopy link to kbqCloseByESCboolean

Whether Escape cancels the dialog.

kbqAutoFocusinputCopy link to kbqAutoFocusKbqModalAutoFocus

Where focus lands when the dialog is shown.

kbqAriaLabelinputCopy link to kbqAriaLabelstring | undefined

Accessible name for a dialog rendered without kbqTitle — a confirm or a header-less dialog.

kbqClosableinputCopy link to kbqClosableboolean

Whether the header renders a close button.

kbqMaskinputCopy link to kbqMaskboolean

Whether the page behind the dialog is dimmed.

kbqMaskClosableinputCopy link to kbqMaskClosableboolean

Whether a click on the dim layer cancels the dialog.

kbqMaskStyleinputCopy link to kbqMaskStyleobject | undefined

Inline styles for the dim layer.

kbqBodyStyleinputCopy link to kbqBodyStyleobject | undefined

Inline styles for the body element.

kbqOkTextinputCopy link to kbqOkTextstring | undefined

Caption of the predefined OK button. The button is not rendered without it.

kbqOkTypeinputCopy link to kbqOkTypeKbqButtonColor

Color of the predefined OK button.

kbqRestoreFocusinputCopy link to kbqRestoreFocusboolean

Whether focus returns to the trigger when the dialog closes.

kbqOkLoadinginputCopy link to kbqOkLoadingboolean

Whether the predefined OK button renders its progress state.

kbqOkClickinputCopy link to kbqOkClickOnClickCallback<T> | undefined

Decision handler of the predefined OK button. Returning false — or a promise of false — keeps the dialog open; anything else closes it. Receives the body component instance when the body is a component.

Bind this or (kbqOnOk), never both: a handler decides the close itself, so the event has nothing left to report and is not emitted. Binding both is reported in development mode.

kbqCancelTextinputCopy link to kbqCancelTextstring | undefined

Caption of the predefined Cancel button. The button is not rendered without it.

kbqCancelLoadinginputCopy link to kbqCancelLoadingboolean

Whether the predefined Cancel button renders its progress state.

kbqCancelClickinputCopy link to kbqCancelClickOnClickCallback<T> | undefined

Decision handler of the predefined Cancel button, the close button, Escape and the dim layer. Returning false — or a promise of false — keeps the dialog open.

Bind this or (kbqOnCancel), never both — see kbqOkClick.

kbqGetContainerinputCopy link to kbqGetContainerHTMLElement | OverlayRef | (() => HTMLElement | OverlayRef) | null

Element or overlay the dialog is rendered into. Read once, on init.

localeOverridesinputCopy link to localeOverridesKbqPartialLocaleData | undefined

Localized strings for this element and its subtree, keyed by locale section. Every key is optional at every depth.

kbqBeforeCloseCopy link to kbqBeforeCloseEventEmitter<R | undefined>

Emitted before the modal begins its closing animation.

kbqOnOkCopy link to kbqOnOkEventEmitter<T>

Emits when the predefined OK button is activated. A notification, not a decision — the dialog closes either way. Bind [kbqOkClick] instead to decide whether it closes.

kbqOnCancelCopy link to kbqOnCancelEventEmitter<T>

Emits when the dialog is cancelled, by any of the controls kbqCancelClick covers. A notification, not a decision. Bind [kbqCancelClick] instead to decide whether it closes.

titleIdCopy link to titleIdstring

Id of the element that names the dialog. Rendered on the title of a composed modal too.

captionIdCopy link to captionIdstring

Id of the element that describes the dialog. Rendered on the caption of a composed modal too.

beforeCloseCopy link to beforeCloseObservable<R | undefined>

Observable alias for kbqBeforeClose

close()Copy link to close()void

Starts the closing animation and resolves the afterClose contract with result.

Closing an already closed dialog is a no-op: afterClose emits once per actual transition.

KbqModalTitle

componentCopy link to KbqModalTitle
@Component({ selector: '[kbq-modal-title], kbq-modal-title, [kbqModalTitle]' })
class KbqModalTitle {}
localeOverridesinputCopy link to localeOverridesKbqPartialLocaleData | undefined

Localized strings for this element and its subtree, keyed by locale section. Every key is optional at every depth.

KbqModalBody

directiveCopy link to KbqModalBody

Scrollable body of a manually composed modal (kbqComponent). Publishes its scroll-shadow state onto the modal instance so a sibling KbqModalTitle/KbqModalFooter can render the matching shadow, since they have no direct template reference to this element.

@Directive({ selector: '[kbq-modal-body], kbq-modal-body, [kbqModalBody]' })
class KbqModalBody {}

KbqModalFooter

directiveCopy link to KbqModalFooter
@Directive({
    selector: '[kbq-modal-footer], kbq-modal-footer, [kbqModalFooter]'
})
class KbqModalFooter {}

KbqModalMainAction

directiveCopy link to KbqModalMainAction
@Directive({ selector: '[kbq-modal-main-action]' })
class KbqModalMainAction {}

CssUnitPipe

pipeCopy link to CssUnitPipe
@Pipe({ name: 'toCssUnit' })
class CssUnitPipe implements PipeTransform {
    transform(
        value: number | string | null | undefined,
        defaultUnit?: string
    ): string | null;
}
transform()Copy link to transform()string | null

Returns null for a value that was never set, so the style binding it feeds is cleared.

KbqModalService

serviceCopy link to KbqModalService
@Injectable({ providedIn: 'root' })
class KbqModalService {
    get openModals(): KbqModalRef[];
    get afterAllClose(): Observable<void>;
    closeAll(): void;
    create<C, R = unknown>(
        options?: IModalOptionsForService<C>
    ): KbqModalRef<C, R>;
    confirm<C, R = unknown>(
        options?: IModalOptionsForService<C>,
        confirmType?: ConfirmType
    ): KbqModalRef<C, R>;
    open<C, R = unknown>(
        options?: IModalOptionsForService<C>
    ): KbqModalRef<C, R>;
    success<C, R = unknown>(
        options?: IModalOptionsForService<C>
    ): KbqModalRef<C, R>;
    delete<C, R = unknown>(
        options?: IModalOptionsForService<C>
    ): KbqModalRef<C, R>;
}
create()Copy link to create()KbqModalRef<C, R>

Opens a dialog. Its lifetime is bound to options.injector — the caller's injector when one is passed, the root environment injector otherwise — so destroying the opener closes it.

delete()Copy link to delete()KbqModalRef<C, R>

Opens a confirm dialog styled for a destructive action — the warn confirm type.

KbqModalRef

abstract classCopy link to KbqModalRef

API class that public to users to handle the modal instance. KbqModalRef is aim to avoid accessing to the modal instance directly by users.

abstract class KbqModalRef<C = any, R = unknown> {
    abstract afterOpen: Observable<void>;
    abstract beforeClose: Observable<R | undefined>;
    abstract afterClose: Observable<R | undefined>;
    abstract open(): void;
    abstract close(result?: R): void;
    abstract destroy(result?: R): void;
    abstract triggerOk(): void;
    abstract triggerCancel(): void;
    abstract getContentComponent(): C;
    abstract getElement(): HTMLElement;
    abstract getInstance(): KbqModalComponent;
    abstract markForCheck(): any;
}
triggerOk()Copy link to triggerOk()void

Runs the OK flow exactly as the predefined OK button does: the kbqOkClick handler when one is bound, the kbqOnOk emitter otherwise.

triggerCancel()Copy link to triggerCancel()void

Runs the cancel flow exactly as the predefined Cancel button does.

getContentComponent()Copy link to getContentComponent()C

Return the component instance of kbqContent when specify kbqContent as a Component Note: this method may return undefined if the Component has not ready yet. (it only available after Modal's ngOnInit)

getElement()Copy link to getElement()HTMLElement

Get the dom element of this Modal

getInstance()Copy link to getInstance()KbqModalComponent

Get the instance of the Modal itself

markForCheck()Copy link to markForCheck()any

Call markForCheck for change detector

AnimationState

typeCopy link to AnimationState

Phase of the open/close animation the dialog is in, or null between phases.

type AnimationState = 'enter' | 'leave' | null;

ConfirmType

typeCopy link to ConfirmType
type ConfirmType = 'confirm' | 'success' | 'warn';

IModalButtonOptions

interfaceCopy link to IModalButtonOptions
interface IModalButtonOptions<T = any> {
    label: string;
    type?: string;
    shape?: string;
    ghost?: boolean;
    size?: string;
    autoLoading?: boolean;
    show?: boolean | ((this: IModalButtonOptions<T>, contentComponentInstance?: T) => boolean);
    loading?: boolean | ((this: IModalButtonOptions<T>, contentComponentInstance?: T) => boolean);
    disabled?: boolean | ((this: IModalButtonOptions<T>, contentComponentInstance?: T) => boolean);
    autoFocus?: boolean;
    kbqModalMainAction?: boolean;
    onClick?(
        this: IModalButtonOptions<T>,
        contentComponentInstance?: T
    ): void | {} | Promise<void | {}>;
}
showoptionalCopy link to showboolean | ((this: IModalButtonOptions<T>, contentComponentInstance?: T) => boolean)

Whether the button is rendered.

The callable form is re-evaluated on every change-detection pass over the dialog, which is what lets it track state the dialog knows nothing about — so it must be cheap and free of side effects. contentComponentInstance is passed only when the body is a component.

loadingoptionalCopy link to loadingboolean | ((this: IModalButtonOptions<T>, contentComponentInstance?: T) => boolean)

Whether the button renders its progress state. Re-evaluated per pass — see IModalButtonOptions.show.

disabledoptionalCopy link to disabledboolean | ((this: IModalButtonOptions<T>, contentComponentInstance?: T) => boolean)

Whether the button is disabled. Re-evaluated per pass — see IModalButtonOptions.show.

IModalOptionsForService

interfaceCopy link to IModalOptionsForService
interface IModalOptionsForService<T = any> extends ModalOptions<T> {
    injector?: Injector;
    kbqModalType?: ModalType;
    kbqVisible?: boolean;
    kbqWidth?: number | string;
    kbqSize?: ModalSize;
    kbqWrapClassName?: string;
    kbqClassName?: string;
    kbqStyle?: object;
    kbqTitle?: string | TemplateRef<{}>;
    kbqCaption?: string | TemplateRef<{}>;
    kbqContent?: string | TemplateRef<{}> | Type<C>;
    kbqComponent?: Type<C>;
    kbqClosable?: boolean;
    kbqMask?: boolean;
    kbqMaskClosable?: boolean;
    kbqMaskStyle?: object;
    kbqBodyStyle?: object;
    kbqFooter?: string | TemplateRef<{}> | IModalButtonOptions<C>[];
    kbqGetContainer?: HTMLElement | OverlayRef | (() => HTMLElement | OverlayRef) | null;
    kbqAfterOpen?: EventEmitter<void>;
    kbqAfterClose?: EventEmitter<R>;
    kbqCloseByESC?: boolean;
    kbqRestoreFocus?: boolean;
    kbqAutoFocus?: KbqModalAutoFocus;
    kbqAriaLabel?: string;
    kbqOkText?: string;
    kbqOkType?: KbqButtonColor;
    kbqOkLoading?: boolean;
    kbqOkClick?: OnClickCallback<C>;
    kbqOnOk?: EventEmitter<C>;
    kbqCancelText?: string;
    kbqCancelLoading?: boolean;
    kbqCancelClick?: OnClickCallback<C>;
    kbqOnCancel?: EventEmitter<C>;
    data?: unknown;
}
injectoroptionalCopy link to injectorInjector

The injector used to create the component that will be attached. If specified, it overrides the injector provided by KbqModalService.

Its DestroyRef also owns the dialog: the modal is torn down when the injector is destroyed.

kbqModalTypeoptionalCopy link to kbqModalTypeModalType

Layout the dialog renders. Default is 'default'.

kbqVisibleoptionalCopy link to kbqVisibleboolean

Whether the dialog is shown. Managed by the service on the imperative path.

kbqWidthoptionalCopy link to kbqWidthnumber | string

Explicit width, overriding the one kbqSize implies. A number is read as pixels.

kbqSizeoptionalCopy link to kbqSizeModalSize

Width preset. Default is ModalSize.Medium (640px).

kbqWrapClassNameoptionalCopy link to kbqWrapClassNamestring

Extra class names for the full-screen wrapper around the dialog.

kbqClassNameoptionalCopy link to kbqClassNamestring

Extra class names for the dialog element itself.

kbqStyleoptionalCopy link to kbqStyleobject

Inline styles for the dialog element.

kbqTitleoptionalCopy link to kbqTitlestring | TemplateRef<{}>

Heading of the dialog. Also becomes its accessible name.

kbqCaptionoptionalCopy link to kbqCaptionstring | TemplateRef<{}>

Secondary line under the heading. Also becomes the dialog's accessible description.

kbqContentoptionalCopy link to kbqContentstring | TemplateRef<{}> | Type<C>

Body of the dialog: text, a template or a component class.

kbqComponentoptionalCopy link to kbqComponentType<C>

The instance of component opened into the dialog.

kbqClosableoptionalCopy link to kbqClosableboolean

Whether the header renders a close button. Default is true.

kbqMaskoptionalCopy link to kbqMaskboolean

Whether the page behind the dialog is dimmed. Default is true.

kbqMaskClosableoptionalCopy link to kbqMaskClosableboolean

Whether a click on the dim layer cancels the dialog. Default is false.

kbqMaskStyleoptionalCopy link to kbqMaskStyleobject

Inline styles for the dim layer.

kbqBodyStyleoptionalCopy link to kbqBodyStyleobject

Inline styles for the body element.

kbqFooteroptionalCopy link to kbqFooterstring | TemplateRef<{}> | IModalButtonOptions<C>[]

Footer of the dialog: text, a template, or the buttons to render. Default modal ONLY.

kbqGetContaineroptionalCopy link to kbqGetContainerHTMLElement | OverlayRef | (() => HTMLElement | OverlayRef) | null

Element or overlay the dialog is rendered into. STATIC — read once, on init.

kbqAfterOpenoptionalCopy link to kbqAfterOpenEventEmitter<void>

Emitter that mirrors the dialog's own open event. It is subscribed to the dialog, never substituted for it, so afterOpen on the returned KbqModalRef keeps working alongside.

kbqAfterCloseoptionalCopy link to kbqAfterCloseEventEmitter<R>

Emitter that mirrors the dialog's own close event. It is subscribed to the dialog, never substituted for it, so afterClose on the returned KbqModalRef keeps working alongside.

kbqCloseByESCoptionalCopy link to kbqCloseByESCboolean

Whether Escape cancels the dialog. Default is true.

kbqRestoreFocusoptionalCopy link to kbqRestoreFocusboolean

Whether focus returns to the trigger when the dialog closes. Default is true.

kbqAutoFocusoptionalCopy link to kbqAutoFocusKbqModalAutoFocus

Where focus lands when the dialog is shown. Default is 'first-tabbable'.

kbqAriaLabeloptionalCopy link to kbqAriaLabelstring

Accessible name for a dialog rendered without kbqTitle — a confirm or a header-less dialog.

kbqOkTextoptionalCopy link to kbqOkTextstring

Caption of the predefined OK button. The button is not rendered without it.

kbqOkTypeoptionalCopy link to kbqOkTypeKbqButtonColor

Color of the predefined OK button. Default is KbqComponentColors.Contrast.

kbqOkLoadingoptionalCopy link to kbqOkLoadingboolean

Whether the predefined OK button renders its progress state.

kbqOkClickoptionalCopy link to kbqOkClickOnClickCallback<C>

Decision handler of the predefined OK button. Returning false (or a promise of false) keeps the dialog open; anything else closes it. Pair of the kbqOnOk output — bind one.

kbqOnOkoptionalCopy link to kbqOnOkEventEmitter<C>

Emitter notified when the predefined OK button is activated. Pair of kbqOkClick — bind one.

kbqCancelTextoptionalCopy link to kbqCancelTextstring

Caption of the predefined Cancel button. The button is not rendered without it.

kbqCancelLoadingoptionalCopy link to kbqCancelLoadingboolean

Whether the predefined Cancel button renders its progress state.

kbqCancelClickoptionalCopy link to kbqCancelClickOnClickCallback<C>

Decision handler of the predefined Cancel button, the close button, Escape and the dim layer. Returning false (or a promise of false) keeps the dialog open. Pair of the kbqOnCancel output — bind one.

kbqOnCanceloptionalCopy link to kbqOnCancelEventEmitter<C>

Emitter notified when the dialog is cancelled. Pair of kbqCancelClick — bind one.

dataoptionalCopy link to dataunknown

Data being injected into the child component.

KbqModal

interfaceCopy link to KbqModal

The members of KbqModalComponent the composition directives (kbq-modal-title, kbq-modal-caption, kbq-modal-body, kbq-modal-footer) depend on. They are projected into the dialog, so they inject this token instead of the concrete host component.

interface KbqModal {
    readonly kbqClosable: Signal<boolean>;
    readonly componentColors: typeof KbqComponentColors;
    readonly titleId: string;
    readonly captionId: string;
    readonly bodyOverflow: Signal<KbqOverflowShadowState>;
    readonly afterOpen: Observable<void>;
    onClickCloseBtn(): void;
    registerTitle(): void;
    registerCaption(): void;
    registerFooter(): void;
    setBodyOverflow(state: KbqOverflowShadowState): void;
}
kbqClosableCopy link to kbqClosableSignal<boolean>

Whether the dialog renders a close button in its header.

componentColorsCopy link to componentColorstypeof KbqComponentColors

Palette the composed header binds the close-icon color from.

titleIdCopy link to titleIdstring

Id the dialog element points aria-labelledby at. Belongs on the rendered title element.

captionIdCopy link to captionIdstring

Id the dialog element points aria-describedby at. Belongs on the rendered caption element.

bodyOverflowCopy link to bodyOverflowSignal<KbqOverflowShadowState>

Scroll-shadow state of the composed body, so the header and footer can render matching shadows.

afterOpenCopy link to afterOpenObservable<void>

Emits once the dialog is fully shown.

onClickCloseBtn()Copy link to onClickCloseBtn()void

Runs the cancel flow, exactly as the templated close button does.

registerTitle()Copy link to registerTitle()void

Announces that a composed title is rendered, so the dialog can use it as its accessible name.

registerCaption()Copy link to registerCaption()void

Announces that a composed caption is rendered, so the dialog can use it as its description.

registerFooter()Copy link to registerFooter()void

Announces that a composed footer is rendered, so the body keeps its normal bottom padding.

setBodyOverflow()Copy link to setBodyOverflow()void

Publishes the composed body's scroll-shadow state.

KbqModalAutoFocus

typeCopy link to KbqModalAutoFocus

Where focus lands when the dialog is shown.

[cdkFocusInitial] and autofocus inside the dialog win over every value but false.

  • first-tabbable — the first tabbable control, which for a titled dialog is the close button;
  • dialog — the dialog element itself, so a long scrollable body is read from its start;
  • first-heading — the dialog title, falling back to the dialog element;
  • false — nothing is focused, and the caller is responsible for moving focus into the dialog.
type KbqModalAutoFocus = 'first-tabbable' | 'dialog' | 'first-heading' | false;

ModalOptions

interfaceCopy link to ModalOptions
interface ModalOptions<C = any, R = any> {
    kbqModalType?: ModalType;
    kbqVisible?: boolean;
    kbqWidth?: number | string;
    kbqSize?: ModalSize;
    kbqWrapClassName?: string;
    kbqClassName?: string;
    kbqStyle?: object;
    kbqTitle?: string | TemplateRef<{}>;
    kbqCaption?: string | TemplateRef<{}>;
    kbqContent?: string | TemplateRef<{}> | Type<C>;
    kbqComponent?: Type<C>;
    kbqClosable?: boolean;
    kbqMask?: boolean;
    kbqMaskClosable?: boolean;
    kbqMaskStyle?: object;
    kbqBodyStyle?: object;
    kbqFooter?: string | TemplateRef<{}> | IModalButtonOptions<C>[];
    kbqGetContainer?: HTMLElement | OverlayRef | (() => HTMLElement | OverlayRef) | null;
    kbqAfterOpen?: EventEmitter<void>;
    kbqAfterClose?: EventEmitter<R>;
    kbqCloseByESC?: boolean;
    kbqRestoreFocus?: boolean;
    kbqAutoFocus?: KbqModalAutoFocus;
    kbqAriaLabel?: string;
    kbqOkText?: string;
    kbqOkType?: KbqButtonColor;
    kbqOkLoading?: boolean;
    kbqOkClick?: OnClickCallback<C>;
    kbqOnOk?: EventEmitter<C>;
    kbqCancelText?: string;
    kbqCancelLoading?: boolean;
    kbqCancelClick?: OnClickCallback<C>;
    kbqOnCancel?: EventEmitter<C>;
    data?: unknown;
}
kbqModalTypeoptionalCopy link to kbqModalTypeModalType

Layout the dialog renders. Default is 'default'.

kbqVisibleoptionalCopy link to kbqVisibleboolean

Whether the dialog is shown. Managed by the service on the imperative path.

kbqWidthoptionalCopy link to kbqWidthnumber | string

Explicit width, overriding the one kbqSize implies. A number is read as pixels.

kbqSizeoptionalCopy link to kbqSizeModalSize

Width preset. Default is ModalSize.Medium (640px).

kbqWrapClassNameoptionalCopy link to kbqWrapClassNamestring

Extra class names for the full-screen wrapper around the dialog.

kbqClassNameoptionalCopy link to kbqClassNamestring

Extra class names for the dialog element itself.

kbqStyleoptionalCopy link to kbqStyleobject

Inline styles for the dialog element.

kbqTitleoptionalCopy link to kbqTitlestring | TemplateRef<{}>

Heading of the dialog. Also becomes its accessible name.

kbqCaptionoptionalCopy link to kbqCaptionstring | TemplateRef<{}>

Secondary line under the heading. Also becomes the dialog's accessible description.

kbqContentoptionalCopy link to kbqContentstring | TemplateRef<{}> | Type<C>

Body of the dialog: text, a template or a component class.

kbqComponentoptionalCopy link to kbqComponentType<C>

The instance of component opened into the dialog.

kbqClosableoptionalCopy link to kbqClosableboolean

Whether the header renders a close button. Default is true.

kbqMaskoptionalCopy link to kbqMaskboolean

Whether the page behind the dialog is dimmed. Default is true.

kbqMaskClosableoptionalCopy link to kbqMaskClosableboolean

Whether a click on the dim layer cancels the dialog. Default is false.

kbqMaskStyleoptionalCopy link to kbqMaskStyleobject

Inline styles for the dim layer.

kbqBodyStyleoptionalCopy link to kbqBodyStyleobject

Inline styles for the body element.

kbqFooteroptionalCopy link to kbqFooterstring | TemplateRef<{}> | IModalButtonOptions<C>[]

Footer of the dialog: text, a template, or the buttons to render. Default modal ONLY.

kbqGetContaineroptionalCopy link to kbqGetContainerHTMLElement | OverlayRef | (() => HTMLElement | OverlayRef) | null

Element or overlay the dialog is rendered into. STATIC — read once, on init.

kbqAfterOpenoptionalCopy link to kbqAfterOpenEventEmitter<void>

Emitter that mirrors the dialog's own open event. It is subscribed to the dialog, never substituted for it, so afterOpen on the returned KbqModalRef keeps working alongside.

kbqAfterCloseoptionalCopy link to kbqAfterCloseEventEmitter<R>

Emitter that mirrors the dialog's own close event. It is subscribed to the dialog, never substituted for it, so afterClose on the returned KbqModalRef keeps working alongside.

kbqCloseByESCoptionalCopy link to kbqCloseByESCboolean

Whether Escape cancels the dialog. Default is true.

kbqRestoreFocusoptionalCopy link to kbqRestoreFocusboolean

Whether focus returns to the trigger when the dialog closes. Default is true.

kbqAutoFocusoptionalCopy link to kbqAutoFocusKbqModalAutoFocus

Where focus lands when the dialog is shown. Default is 'first-tabbable'.

kbqAriaLabeloptionalCopy link to kbqAriaLabelstring

Accessible name for a dialog rendered without kbqTitle — a confirm or a header-less dialog.

kbqOkTextoptionalCopy link to kbqOkTextstring

Caption of the predefined OK button. The button is not rendered without it.

kbqOkTypeoptionalCopy link to kbqOkTypeKbqButtonColor

Color of the predefined OK button. Default is KbqComponentColors.Contrast.

kbqOkLoadingoptionalCopy link to kbqOkLoadingboolean

Whether the predefined OK button renders its progress state.

kbqOkClickoptionalCopy link to kbqOkClickOnClickCallback<C>

Decision handler of the predefined OK button. Returning false (or a promise of false) keeps the dialog open; anything else closes it. Pair of the kbqOnOk output — bind one.

kbqOnOkoptionalCopy link to kbqOnOkEventEmitter<C>

Emitter notified when the predefined OK button is activated. Pair of kbqOkClick — bind one.

kbqCancelTextoptionalCopy link to kbqCancelTextstring

Caption of the predefined Cancel button. The button is not rendered without it.

kbqCancelLoadingoptionalCopy link to kbqCancelLoadingboolean

Whether the predefined Cancel button renders its progress state.

kbqCancelClickoptionalCopy link to kbqCancelClickOnClickCallback<C>

Decision handler of the predefined Cancel button, the close button, Escape and the dim layer. Returning false (or a promise of false) keeps the dialog open. Pair of the kbqOnCancel output — bind one.

kbqOnCanceloptionalCopy link to kbqOnCancelEventEmitter<C>

Emitter notified when the dialog is cancelled. Pair of kbqCancelClick — bind one.

dataoptionalCopy link to dataunknown

Data being injected into the child component.

ModalType

typeCopy link to ModalType
type ModalType = 'default' | 'confirm' | 'custom';

OnClickCallback

typeCopy link to OnClickCallback
type OnClickCallback<T> = (instance: T) => (false | void | {}) | Promise<false | void | {}>;

ModalSize

enumCopy link to ModalSize
enum ModalSize {
    Small = 'small',
    Medium = 'medium',
    Large = 'large'
}

KBQ_MODAL

constCopy link to KBQ_MODAL

Injection token exposing the dialog to the directives composed inside it.

const KBQ_MODAL: InjectionToken<KbqModal>;

KBQ_MODAL_DATA

constCopy link to KBQ_MODAL_DATA

Injection token that can be used to access the data that was passed in to a modal.

const KBQ_MODAL_DATA: InjectionToken<unknown>;
Suggestions for improvement
If you found a mistake or want to improve the article, create an issue on GitHub.