# API of `@koobiq/components/modal`

Documented on [Modal](https://koobiq.io/en/components/modal.md). NgModule: `KbqModalModule`.

## Components

### KbqModalCaption (component)

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`.

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

### KbqModalComponent (component)

```ts
@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;
}
```

- `[kbqModalType]`: `ModalType` — Layout the dialog renders.
- `[kbqComponent]`: `Type<T> | undefined` — The instance of component opened into the dialog.
- `[kbqContent]`: `string | TemplateRef<{}> | Type<T> | undefined` — Body of the dialog: text, a template or a component class. Falls back to `<ng-content>`.
- `[kbqFooter]`: `string | TemplateRef<{}> | IModalButtonOptions<T>[] | undefined` — Footer of the dialog: text, a template, or the buttons to render. Default modal ONLY.
- `[(kbqVisible)]`: `boolean` — Whether the dialog is shown. Two-way bindable as `[(kbqVisible)]`.
- `[kbqWidth]`: `number | string | undefined` — Explicit width, overriding the one `kbqSize` implies. A number is read as pixels.
- `[kbqSize]`: `ModalSize` — Width preset.
- `[kbqWrapClassName]`: `string | undefined` — Extra class names for the full-screen wrapper around the dialog.
- `[kbqClassName]`: `string | undefined` — Extra class names for the dialog element itself.
- `[kbqStyle]`: `object | undefined` — Inline styles for the dialog element.
- `[kbqTitle]`: `string | TemplateRef<{}> | undefined` — Heading of the dialog. Also becomes its accessible name.
- `[kbqCaption]`: `string | TemplateRef<{}> | undefined` — Secondary line under the heading. Also becomes the dialog's accessible description.
- `[kbqCloseByESC]`: `boolean` — Whether `Escape` cancels the dialog.
- `[kbqAutoFocus]`: `KbqModalAutoFocus` — Where focus lands when the dialog is shown.
- `[kbqAriaLabel]`: `string | undefined` — Accessible name for a dialog rendered without `kbqTitle` — a confirm or a header-less dialog.
- `[kbqClosable]`: `boolean` — Whether the header renders a close button.
- `[kbqMask]`: `boolean` — Whether the page behind the dialog is dimmed.
- `[kbqMaskClosable]`: `boolean` — Whether a click on the dim layer cancels the dialog.
- `[kbqMaskStyle]`: `object | undefined` — Inline styles for the dim layer.
- `[kbqBodyStyle]`: `object | undefined` — Inline styles for the body element.
- `[kbqOkText]`: `string | undefined` — Caption of the predefined OK button. The button is not rendered without it.
- `[kbqOkType]`: `KbqButtonColor` — Color of the predefined OK button.
- `[kbqRestoreFocus]`: `boolean` — Whether focus returns to the trigger when the dialog closes.
- `[kbqOkLoading]`: `boolean` — Whether the predefined OK button renders its progress state.
- `[kbqOkClick]`: `OnClickCallback<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.
- `[kbqCancelText]`: `string | undefined` — Caption of the predefined Cancel button. The button is not rendered without it.
- `[kbqCancelLoading]`: `boolean` — Whether the predefined Cancel button renders its progress state.
- `[kbqCancelClick]`: `OnClickCallback<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`.
- `[kbqGetContainer]`: `HTMLElement | OverlayRef | (() => HTMLElement | OverlayRef) | null` — Element or overlay the dialog is rendered into. Read once, on init.
- `[localeOverrides]`: `KbqPartialLocaleData | undefined` — Localized strings for this element and its subtree, keyed by locale section. Every key is optional at
  every depth.
- `kbqBeforeClose`: `EventEmitter<R | undefined>` — Emitted before the modal begins its closing animation.
- `kbqOnOk`: `EventEmitter<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.
- `kbqOnCancel`: `EventEmitter<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.
- `titleId`: `string` — Id of the element that names the dialog. Rendered on the title of a composed modal too.
- `captionId`: `string` — Id of the element that describes the dialog. Rendered on the caption of a composed modal too.
- `beforeClose`: `Observable<R | undefined>` — Observable alias for `kbqBeforeClose`
- `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 (component)

```ts
@Component({ selector: '[kbq-modal-title], kbq-modal-title, [kbqModalTitle]' })
class KbqModalTitle {}
```

- `[localeOverrides]`: `KbqPartialLocaleData | undefined` — Localized strings for this element and its subtree, keyed by locale section. Every key is optional at
  every depth.

## Directives

### KbqModalBody (directive)

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.

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

### KbqModalFooter (directive)

```ts
@Directive({
    selector: '[kbq-modal-footer], kbq-modal-footer, [kbqModalFooter]'
})
class KbqModalFooter {}
```

### KbqModalMainAction (directive)

```ts
@Directive({ selector: '[kbq-modal-main-action]' })
class KbqModalMainAction {}
```

## Pipes

### CssUnitPipe (pipe)

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

- `transform()`: `string | null` — Returns `null` for a value that was never set, so the style binding it feeds is cleared.

## Services

### KbqModalService (service)

```ts
@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()`: `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()`: `KbqModalRef<C, R>` — Opens a confirm dialog styled for a destructive action — the `warn` confirm type.

## Classes

### KbqModalRef (abstract class)

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

```ts
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()`: `void` — Runs the OK flow exactly as the predefined OK button does: the `kbqOkClick` handler when one
  is bound, the `kbqOnOk` emitter otherwise.
- `triggerCancel()`: `void` — Runs the cancel flow exactly as the predefined Cancel button does.
- `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()`: `HTMLElement` — Get the dom element of this Modal
- `getInstance()`: `KbqModalComponent` — Get the instance of the Modal itself
- `markForCheck()`: `any` — Call markForCheck for change detector

## Types

### AnimationState (type)

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

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

### ConfirmType (type)

```ts
type ConfirmType = 'confirm' | 'success' | 'warn';
```

### IModalButtonOptions (interface)

```ts
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 | {}>;
}
```

- `show?`: `boolean | ((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.
- `loading?`: `boolean | ((this: IModalButtonOptions<T>, contentComponentInstance?: T) => boolean)` — Whether the button renders its progress state. Re-evaluated per pass — see `IModalButtonOptions.show`.
- `disabled?`: `boolean | ((this: IModalButtonOptions<T>, contentComponentInstance?: T) => boolean)` — Whether the button is disabled. Re-evaluated per pass — see `IModalButtonOptions.show`.

### IModalOptionsForService (interface)

```ts
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;
}
```

- `injector?`: `Injector` — 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.
- `kbqModalType?`: `ModalType` — Layout the dialog renders. Default is `'default'`.
- `kbqVisible?`: `boolean` — Whether the dialog is shown. Managed by the service on the imperative path.
- `kbqWidth?`: `number | string` — Explicit width, overriding the one `kbqSize` implies. A number is read as pixels.
- `kbqSize?`: `ModalSize` — Width preset. Default is `ModalSize.Medium` (640px).
- `kbqWrapClassName?`: `string` — Extra class names for the full-screen wrapper around the dialog.
- `kbqClassName?`: `string` — Extra class names for the dialog element itself.
- `kbqStyle?`: `object` — Inline styles for the dialog element.
- `kbqTitle?`: `string | TemplateRef<{}>` — Heading of the dialog. Also becomes its accessible name.
- `kbqCaption?`: `string | TemplateRef<{}>` — Secondary line under the heading. Also becomes the dialog's accessible description.
- `kbqContent?`: `string | TemplateRef<{}> | Type<C>` — Body of the dialog: text, a template or a component class.
- `kbqComponent?`: `Type<C>` — The instance of component opened into the dialog.
- `kbqClosable?`: `boolean` — Whether the header renders a close button. Default is `true`.
- `kbqMask?`: `boolean` — Whether the page behind the dialog is dimmed. Default is `true`.
- `kbqMaskClosable?`: `boolean` — Whether a click on the dim layer cancels the dialog. Default is `false`.
- `kbqMaskStyle?`: `object` — Inline styles for the dim layer.
- `kbqBodyStyle?`: `object` — Inline styles for the body element.
- `kbqFooter?`: `string | TemplateRef<{}> | IModalButtonOptions<C>[]` — Footer of the dialog: text, a template, or the buttons to render. Default modal ONLY.
- `kbqGetContainer?`: `HTMLElement | OverlayRef | (() => HTMLElement | OverlayRef) | null` — Element or overlay the dialog is rendered into. STATIC — read once, on init.
- `kbqAfterOpen?`: `EventEmitter<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.
- `kbqAfterClose?`: `EventEmitter<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.
- `kbqCloseByESC?`: `boolean` — Whether `Escape` cancels the dialog. Default is `true`.
- `kbqRestoreFocus?`: `boolean` — Whether focus returns to the trigger when the dialog closes. Default is `true`.
- `kbqAutoFocus?`: `KbqModalAutoFocus` — Where focus lands when the dialog is shown. Default is `'first-tabbable'`.
- `kbqAriaLabel?`: `string` — Accessible name for a dialog rendered without `kbqTitle` — a confirm or a header-less dialog.
- `kbqOkText?`: `string` — Caption of the predefined OK button. The button is not rendered without it.
- `kbqOkType?`: `KbqButtonColor` — Color of the predefined OK button. Default is `KbqComponentColors.Contrast`.
- `kbqOkLoading?`: `boolean` — Whether the predefined OK button renders its progress state.
- `kbqOkClick?`: `OnClickCallback<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.
- `kbqOnOk?`: `EventEmitter<C>` — Emitter notified when the predefined OK button is activated. Pair of `kbqOkClick` — bind one.
- `kbqCancelText?`: `string` — Caption of the predefined Cancel button. The button is not rendered without it.
- `kbqCancelLoading?`: `boolean` — Whether the predefined Cancel button renders its progress state.
- `kbqCancelClick?`: `OnClickCallback<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.
- `kbqOnCancel?`: `EventEmitter<C>` — Emitter notified when the dialog is cancelled. Pair of `kbqCancelClick` — bind one.
- `data?`: `unknown` — Data being injected into the child component.

### KbqModal (interface)

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.

```ts
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;
}
```

- `kbqClosable`: `Signal<boolean>` — Whether the dialog renders a close button in its header.
- `componentColors`: `typeof KbqComponentColors` — Palette the composed header binds the close-icon color from.
- `titleId`: `string` — Id the dialog element points `aria-labelledby` at. Belongs on the rendered title element.
- `captionId`: `string` — Id the dialog element points `aria-describedby` at. Belongs on the rendered caption element.
- `bodyOverflow`: `Signal<KbqOverflowShadowState>` — Scroll-shadow state of the composed body, so the header and footer can render matching shadows.
- `afterOpen`: `Observable<void>` — Emits once the dialog is fully shown.
- `onClickCloseBtn()`: `void` — Runs the cancel flow, exactly as the templated close button does.
- `registerTitle()`: `void` — Announces that a composed title is rendered, so the dialog can use it as its accessible name.
- `registerCaption()`: `void` — Announces that a composed caption is rendered, so the dialog can use it as its description.
- `registerFooter()`: `void` — Announces that a composed footer is rendered, so the body keeps its normal bottom padding.
- `setBodyOverflow()`: `void` — Publishes the composed body's scroll-shadow state.

### KbqModalAutoFocus (type)

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.

```ts
type KbqModalAutoFocus = 'first-tabbable' | 'dialog' | 'first-heading' | false;
```

### ModalOptions (interface)

```ts
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;
}
```

- `kbqModalType?`: `ModalType` — Layout the dialog renders. Default is `'default'`.
- `kbqVisible?`: `boolean` — Whether the dialog is shown. Managed by the service on the imperative path.
- `kbqWidth?`: `number | string` — Explicit width, overriding the one `kbqSize` implies. A number is read as pixels.
- `kbqSize?`: `ModalSize` — Width preset. Default is `ModalSize.Medium` (640px).
- `kbqWrapClassName?`: `string` — Extra class names for the full-screen wrapper around the dialog.
- `kbqClassName?`: `string` — Extra class names for the dialog element itself.
- `kbqStyle?`: `object` — Inline styles for the dialog element.
- `kbqTitle?`: `string | TemplateRef<{}>` — Heading of the dialog. Also becomes its accessible name.
- `kbqCaption?`: `string | TemplateRef<{}>` — Secondary line under the heading. Also becomes the dialog's accessible description.
- `kbqContent?`: `string | TemplateRef<{}> | Type<C>` — Body of the dialog: text, a template or a component class.
- `kbqComponent?`: `Type<C>` — The instance of component opened into the dialog.
- `kbqClosable?`: `boolean` — Whether the header renders a close button. Default is `true`.
- `kbqMask?`: `boolean` — Whether the page behind the dialog is dimmed. Default is `true`.
- `kbqMaskClosable?`: `boolean` — Whether a click on the dim layer cancels the dialog. Default is `false`.
- `kbqMaskStyle?`: `object` — Inline styles for the dim layer.
- `kbqBodyStyle?`: `object` — Inline styles for the body element.
- `kbqFooter?`: `string | TemplateRef<{}> | IModalButtonOptions<C>[]` — Footer of the dialog: text, a template, or the buttons to render. Default modal ONLY.
- `kbqGetContainer?`: `HTMLElement | OverlayRef | (() => HTMLElement | OverlayRef) | null` — Element or overlay the dialog is rendered into. STATIC — read once, on init.
- `kbqAfterOpen?`: `EventEmitter<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.
- `kbqAfterClose?`: `EventEmitter<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.
- `kbqCloseByESC?`: `boolean` — Whether `Escape` cancels the dialog. Default is `true`.
- `kbqRestoreFocus?`: `boolean` — Whether focus returns to the trigger when the dialog closes. Default is `true`.
- `kbqAutoFocus?`: `KbqModalAutoFocus` — Where focus lands when the dialog is shown. Default is `'first-tabbable'`.
- `kbqAriaLabel?`: `string` — Accessible name for a dialog rendered without `kbqTitle` — a confirm or a header-less dialog.
- `kbqOkText?`: `string` — Caption of the predefined OK button. The button is not rendered without it.
- `kbqOkType?`: `KbqButtonColor` — Color of the predefined OK button. Default is `KbqComponentColors.Contrast`.
- `kbqOkLoading?`: `boolean` — Whether the predefined OK button renders its progress state.
- `kbqOkClick?`: `OnClickCallback<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.
- `kbqOnOk?`: `EventEmitter<C>` — Emitter notified when the predefined OK button is activated. Pair of `kbqOkClick` — bind one.
- `kbqCancelText?`: `string` — Caption of the predefined Cancel button. The button is not rendered without it.
- `kbqCancelLoading?`: `boolean` — Whether the predefined Cancel button renders its progress state.
- `kbqCancelClick?`: `OnClickCallback<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.
- `kbqOnCancel?`: `EventEmitter<C>` — Emitter notified when the dialog is cancelled. Pair of `kbqCancelClick` — bind one.
- `data?`: `unknown` — Data being injected into the child component.

### ModalType (type)

```ts
type ModalType = 'default' | 'confirm' | 'custom';
```

### OnClickCallback (type)

```ts
type OnClickCallback<T> = (instance: T) => (false | void | {}) | Promise<false | void | {}>;
```

## Enums

### ModalSize (enum)

```ts
enum ModalSize {
    Small = 'small',
    Medium = 'medium',
    Large = 'large'
}
```

## Constants

### KBQ_MODAL (const)

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

```ts
const KBQ_MODAL: InjectionToken<KbqModal>;
```

### KBQ_MODAL_DATA (const)

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

```ts
const KBQ_MODAL_DATA: InjectionToken<unknown>;
```
