import * as _angular_core from '@angular/core'; import { ViewContainerRef, Injector, Provider, InjectOptions, OnDestroy, TemplateRef, Type, Signal } from '@angular/core'; import * as ng_primitives_portal from 'ng-primitives/portal'; import { NgpDismissGuard, ScrollStrategy, NgpOverlayRef, NgpPortalDetachOptions, NgpDismissGuardInput } from 'ng-primitives/portal'; import * as ng_primitives_dialog from 'ng-primitives/dialog'; import * as i1 from 'ng-primitives/internal'; import * as rxjs from 'rxjs'; import { Subject, Observable } from 'rxjs'; import { FocusOrigin } from '@angular/cdk/a11y'; import { BooleanInput } from '@angular/cdk/coercion'; import * as i1$1 from 'ng-primitives/focus-trap'; import * as ng_primitives_state from 'ng-primitives/state'; import { StateInjectionOptions } from 'ng-primitives/state'; /** Valid ARIA roles for a dialog. */ type NgpDialogRole = 'dialog' | 'alertdialog'; interface NgpDialogConfig { /** The view container to attach the dialog to. */ viewContainerRef?: ViewContainerRef; /** The injector to use for the dialog. Defaults to the view container's injector.*/ injector?: Injector; /** * The element the dialog is opened from, used to resolve the parent overlay and restore * focus. Defaults to whatever holds focus when `open()` is called. */ triggerElement?: HTMLElement; /** ID for the dialog. If omitted, a unique one will be generated. */ id?: string; /** The role of the dialog. */ role?: NgpDialogRole; /** Whether this is a modal dialog. Used to set the `aria-modal` attribute. */ modal?: boolean; /** * The container element or selector the dialog should be rendered into. * @default 'body' */ container?: HTMLElement | string | null; /** * Whether the dialog should close when the user navigates. This includes both browser history * navigation (back/forward) and programmatic route changes (e.g. router.navigate()). */ closeOnNavigation?: boolean; /** Whether the dialog should close when the user presses the escape key, or a guard function. */ closeOnEscape?: NgpDismissGuard; /** * Whether the dialog should close when clicking outside (on the overlay), or a guard function. */ closeOnOutsideClick?: NgpDismissGuard; /** * Whether the dialog should close when the user clicks the overlay. * @deprecated Use `closeOnOutsideClick` instead. */ closeOnClick?: boolean; /** Scroll strategy to be used for the dialog. */ scrollStrategy?: ScrollStrategy; data?: T; } /** * Provide the default Dialog configuration * @param config The Dialog configuration * @returns The provider */ declare function provideDialogConfig(config: Partial): Provider[]; /** * Inject the Dialog configuration * @returns The global Dialog configuration */ declare function injectDialogConfig(): NgpDialogConfig; declare class NgpDialogDescription { /** The id of the descriptions. */ readonly id: _angular_core.InputSignal; protected readonly state: { id: _angular_core.Signal; }; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare class NgpDialogOverlay { protected readonly dialogRef: ng_primitives_dialog.NgpDialogRef; /** * Whether the dialog should close on backdrop click. * @default `true` */ readonly closeOnClick: _angular_core.InputSignalWithTransform; protected readonly state: { closeOnClick: _angular_core.Signal | undefined>; }; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare class NgpDialogTitle { /** The id of the title. */ readonly id: _angular_core.InputSignal; protected readonly state: { id: _angular_core.Signal; }; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** Minimal portal interface needed by the dialog ref. */ interface NgpDialogPortalRef { getElements(): HTMLElement[]; detach(options?: NgpPortalDetachOptions): Promise; } /** * Reference to a dialog opened via the Dialog service. */ declare class NgpDialogRef implements NgpOverlayRef { readonly config: NgpDialogConfig; private readonly document; /** Whether the user is allowed to close the dialog. */ disableClose: boolean | undefined; /** Whether the escape key is allowed to close the dialog, or a guard function. */ closeOnEscape: NgpDismissGuard | undefined; /** Whether clicking outside (on the overlay) is allowed to close the dialog, or a guard function. */ closeOnOutsideClick: NgpDismissGuard | undefined; /** Emits when the dialog has been closed. */ readonly closed: Subject<{ focusOrigin?: FocusOrigin; result?: R; }>; /** @internal */ readonly afterClosed$: Subject<{ focusOrigin?: FocusOrigin; result?: R; }>; /** * Observable that emits the dialog result after exit animations have completed. */ readonly afterClosed: Observable; /** Data passed from the dialog opener. */ readonly data: T; /** Unique ID for the dialog. */ readonly id: string; /** @internal Store the injector */ injector: Injector | undefined; /** Whether the dialog is closing. */ private closing; /** @internal Portal reference for element access and detach. */ portal: NgpDialogPortalRef | null; /** Emits on keyboard events within the dialog. */ readonly keydownEvents: Observable; /** * Emits pointer events (click, auxclick, contextmenu) that happen outside of the dialog. * Fed by the NgpOverlayRegistry with CDK-compatible stacking awareness. * @internal */ readonly outsidePointerEvents$: Subject; /** Emits on pointer events that happen outside of the dialog. */ readonly outsidePointerEvents: Observable; constructor(config: NgpDialogConfig, document: Document); /** * Updates the position of the dialog. No-op since dialogs are CSS-centered. */ updatePosition(): this; /** * NgpOverlayRef implementation — called by the registry for escape-key dismiss. */ hide(options?: { immediate?: boolean; origin?: FocusOrigin; }): void; /** * NgpOverlayRef implementation — called by the registry for descendant cascade. * Skips exit animations and tears down immediately. */ hideImmediate(): Promise; /** * Close the dialog. * @param result Optional result to return to the dialog opener. * @param focusOrigin The origin of the focus event that triggered the close. */ close(result?: R, focusOrigin?: FocusOrigin): Promise; /** * @deprecated Access dialog methods directly instead (keydownEvents, outsidePointerEvents, * updatePosition, close). This shim will be removed in the next major version. */ get overlayRef(): { keydownEvents: () => Observable; outsidePointerEvents: () => Observable; updatePosition: () => NgpDialogRef; dispose: () => Promise; detachments: () => Observable<{ focusOrigin?: FocusOrigin; result?: R; }>; overlayElement: HTMLElement | undefined; }; /** * Get the portal elements. * @internal */ getElements(): HTMLElement[]; } declare function injectDialogRef(options?: InjectOptions & { optional?: false; }): NgpDialogRef; declare function injectDialogRef(options: InjectOptions & { optional: true; }): NgpDialogRef | null; /** * Originally based on Angular CDK Dialog service. * Re-implemented to use ng-primitives/portal instead of @angular/cdk/overlay. */ declare class NgpDialogManager implements OnDestroy { private readonly applicationRef; private readonly injector; private readonly document; private readonly focusMonitor; private readonly viewportRuler; private readonly registry; private readonly defaultOptions; private readonly parentDialogManager; private readonly router; private openDialogsAtThisLevel; private readonly afterAllClosedAtThisLevel; private readonly afterOpenedAtThisLevel; private ariaHiddenElements; private readonly closingDialogsAtThisLevel; private routerSubscription; /** Scroll blocking strategy — shared across all dialogs. */ private scrollStrategy; /** Keeps track of the currently-open dialogs. */ get openDialogs(): readonly NgpDialogRef[]; /** * The `aria-hidden` bookkeeping, shared with the parent so nested managers don't overwrite each * other's saved values, they act on the same list of open dialogs. */ private get hiddenElements(); /** Dialogs that have closed but are still in the DOM, running their exit animation. */ private get closingDialogs(); /** Stream that emits when a dialog has been opened. */ get afterOpened(): Subject; /** * Stream that emits when all open dialog have finished closing. * Will emit on subscribe if there are no open dialogs to begin with. */ readonly afterAllClosed: Observable; /** * Opens a modal dialog containing the given template or component. */ open(templateRefOrComponentType: TemplateRef | Type, config?: NgpDialogConfig): NgpDialogRef; /** * Opens a modal dialog containing the given template or component with typed data. */ open(templateRefOrComponentType: TemplateRef> | Type, config: NgpDialogConfig & { data: T; }): NgpDialogRef; /** * Opens a modal dialog with typed result but no data (explicit void for data type). */ open(templateRefOrComponentType: TemplateRef> | Type, config?: NgpDialogConfig): NgpDialogRef; /** * Closes all of the currently-open dialogs. */ closeAll(): void; /** * Finds an open dialog by its id. * @param id ID to use when looking up the dialog. */ getDialogById(id: string): NgpDialogRef | undefined; /** * Subscribe to router navigation events so that dialogs with `closeOnNavigation` * are closed when the user navigates. This handles both browser popstate events * and programmatic route changes (e.g. router.navigate()). */ private subscribeToRouterEvents; ngOnDestroy(): void; /** * Creates a custom injector to be used inside the dialog. This allows a component loaded inside * of a dialog to close itself and, optionally, to return a value. */ private createInjector; /** * Removes a dialog from the array of open dialogs. */ private removeOpenDialog; /** * Enable scroll blocking when the first dialog opens. */ private enableScrollBlocking; /** * Disable scroll blocking when the last dialog closes. */ private disableScrollBlocking; /** * Resolve the container element the dialog should be rendered into. */ private resolveContainer; /** * Recompute what is hidden from assistive technology for the currently open dialogs. * * Runs on every open and close rather than for the first dialog only: dialogs can render into * different containers, so a container hidden on behalf of one dialog may be the very container * the next one opens into. */ private refreshAssistiveTechnologyHiding; /** * Restore the `aria-hidden` values this manager overwrote. */ private restoreAssistiveTechnologyHiding; /** * Hides all of the content that isn't a dialog portal from assistive technology. */ private hideNonDialogContentFromAssistiveTechnology; /** * Hide a single element from assistive technology, remembering its previous value. */ private hideFromAssistiveTechnology; private getAfterAllClosed; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵprov: _angular_core.ɵɵInjectableDeclaration; } interface NgpDialogContext { $implicit: NgpDialogRef; close: (result?: R) => void; } declare class NgpDialogTrigger { /** Access the global configuration */ private readonly config; /** The template to launch. */ readonly template: _angular_core.InputSignal>>; /** * Whether the dialog should close on escape, or a guard function. * @default `true` */ readonly closeOnEscape: _angular_core.InputSignalWithTransform, NgpDismissGuardInput>; /** * Whether the dialog should close on outside click, or a guard function. * @default `true` */ readonly closeOnOutsideClick: _angular_core.InputSignalWithTransform, NgpDismissGuardInput>; /** * The container element or selector the dialog should be rendered into. `undefined` uses the * dialog configuration, `null` renders into the body. * @default 'body' */ readonly container: _angular_core.InputSignal; /** Emits whenever the dialog is closed with the given result. */ readonly closed: _angular_core.OutputEmitterRef; protected readonly state: { template: _angular_core.Signal>>; closeOnEscape: _angular_core.Signal>; closeOnOutsideClick: _angular_core.Signal>; container: _angular_core.Signal; closedChange: rxjs.Observable; }; static ɵfac: _angular_core.ɵɵFactoryDeclaration, never>; static ɵdir: _angular_core.ɵɵDirectiveDeclaration, "[ngpDialogTrigger]", ["ngpDialogTrigger"], { "template": { "alias": "ngpDialogTrigger"; "required": true; "isSignal": true; }; "closeOnEscape": { "alias": "ngpDialogTriggerCloseOnEscape"; "required": false; "isSignal": true; }; "closeOnOutsideClick": { "alias": "ngpDialogTriggerCloseOnOutsideClick"; "required": false; "isSignal": true; }; "container": { "alias": "ngpDialogTriggerContainer"; "required": false; "isSignal": true; }; }, { "closed": "ngpDialogTriggerClosed"; }, never, never, true, never>; } declare class NgpDialog { private readonly config; /** The id of the dialog */ readonly id: _angular_core.InputSignal; /** The dialog role. */ readonly role: _angular_core.InputSignal; /** Whether the dialog is a modal. */ readonly modal: _angular_core.InputSignalWithTransform; /** The dialog state */ protected readonly state: { id: _angular_core.Signal; role: _angular_core.Signal; modal: _angular_core.Signal; close: (result?: R | undefined) => void; setLabelledBy: (id: string) => void; setDescribedBy: (id: string) => void; removeLabelledBy: (id: string) => void; removeDescribedBy: (id: string) => void; }; /** Close the dialog. */ close(result?: R): void; /** @internal register a labelledby id */ setLabelledBy(id: string): void; /** @internal register a describedby id */ setDescribedBy(id: string): void; /** @internal remove a labelledby id */ removeLabelledBy(id: string): void; /** @internal remove a describedby id */ removeDescribedBy(id: string): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration, never>; static ɵdir: _angular_core.ɵɵDirectiveDeclaration, "[ngpDialog]", ["ngpDialog"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "role": { "alias": "ngpDialogRole"; "required": false; "isSignal": true; }; "modal": { "alias": "ngpDialogModal"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1$1.NgpFocusTrap; inputs: {}; outputs: {}; }, { directive: typeof i1.NgpExitAnimation; inputs: {}; outputs: {}; }]>; } interface NgpDialogDescriptionState { /** The id of the descriptions. */ readonly id: Signal; } interface NgpDialogDescriptionProps { /** The id of the descriptions. */ readonly id?: Signal; } declare const NgpDialogDescriptionStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<{ id: Signal; }>>; declare const ngpDialogDescription: ({ id }: NgpDialogDescriptionProps) => { id: Signal; }; declare const injectDialogDescriptionState: { (): Signal<{ id: Signal; }>; (options: ng_primitives_state.StateInjectionOptions): Signal<{ id: Signal; } | null>; (options?: ng_primitives_state.StateInjectionOptions): Signal<{ id: Signal; }> | Signal<{ id: Signal; } | null>; }; declare const provideDialogDescriptionState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; interface NgpDialogOverlayState { /** * Whether the dialog should close on backdrop click. * @default `true` */ readonly closeOnClick: Signal | undefined>; } interface NgpDialogOverlayProps { /** * Whether the dialog should close on backdrop click. * @default `true` */ readonly closeOnClick?: Signal | undefined>; } declare const NgpDialogOverlayStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<{ closeOnClick: Signal | undefined>; }>>; declare const ngpDialogOverlay: ({ closeOnClick, }: NgpDialogOverlayProps) => { closeOnClick: Signal | undefined>; }; declare const injectDialogOverlayState: { (): Signal<{ closeOnClick: Signal | undefined>; }>; (options: ng_primitives_state.StateInjectionOptions): Signal<{ closeOnClick: Signal | undefined>; } | null>; (options?: ng_primitives_state.StateInjectionOptions): Signal<{ closeOnClick: Signal | undefined>; }> | Signal<{ closeOnClick: Signal | undefined>; } | null>; }; declare const provideDialogOverlayState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; interface NgpDialogPanelState { } interface NgpDialogPanelProps { } declare const NgpDialogPanelStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<{}>>; declare const ngpDialogPanel: ({}: NgpDialogPanelProps) => {}; declare const injectDialogPanelState: { (): _angular_core.Signal<{}>; (options: ng_primitives_state.StateInjectionOptions): _angular_core.Signal<{} | null>; (options?: ng_primitives_state.StateInjectionOptions): _angular_core.Signal<{}> | _angular_core.Signal<{} | null>; }; declare const provideDialogPanelState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; interface NgpDialogTitleState { /** The id of the title. */ readonly id: Signal; } interface NgpDialogTitleProps { /** The id of the title. */ readonly id?: Signal; } declare const NgpDialogTitleStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<{ id: Signal; }>>; declare const ngpDialogTitle: ({ id }: NgpDialogTitleProps) => { id: Signal; }; declare const injectDialogTitleState: { (): Signal<{ id: Signal; }>; (options: ng_primitives_state.StateInjectionOptions): Signal<{ id: Signal; } | null>; (options?: ng_primitives_state.StateInjectionOptions): Signal<{ id: Signal; }> | Signal<{ id: Signal; } | null>; }; declare const provideDialogTitleState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; interface NgpDialogTriggerState { /** The template to launch. */ readonly template?: Signal>; /** * Whether the dialog should close on escape, or a guard function. * @default `true` */ readonly closeOnEscape?: Signal>; /** * Whether the dialog should close on outside click, or a guard function. * @default `true` */ readonly closeOnOutsideClick?: Signal>; /** * The container element or selector the dialog should be rendered into. `undefined` uses the * dialog configuration, `null` renders into the body. */ readonly container?: Signal; /** The event that is fired when the closed state changes. */ readonly closedChange: Observable; } interface NgpDialogTriggerProps { /** The template to launch. */ readonly template: Signal>; /** * Whether the dialog should close on escape, or a guard function. * @default `true` */ readonly closeOnEscape?: Signal>; /** * Whether the dialog should close on outside click, or a guard function. * @default `true` */ readonly closeOnOutsideClick?: Signal>; /** * The container element or selector the dialog should be rendered into. `undefined` uses the * dialog configuration, `null` renders into the body. */ readonly container?: Signal; readonly onClosedChange?: (value: T) => void; } declare const NgpDialogTriggerStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<{ template: Signal>>; closeOnEscape: Signal>; closeOnOutsideClick: Signal>; container: Signal; closedChange: Observable; }>>; declare const ngpDialogTrigger: ({ template, closeOnEscape, closeOnOutsideClick, container, onClosedChange, }: NgpDialogTriggerProps) => { template: Signal>>; closeOnEscape: Signal>; closeOnOutsideClick: Signal>; container: Signal; closedChange: Observable; }; declare const provideDialogTriggerState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; declare function injectDialogTriggerState(options?: StateInjectionOptions): Signal>; interface NgpDialogState { /** The id of the dialog */ readonly id?: Signal; /** The dialog role. */ readonly role?: Signal; /** Whether the dialog is a modal. */ readonly modal?: Signal; /** Close the dialog. */ close: (result?: R) => void; /** @internal register a labelledby id */ setLabelledBy: (id: string) => void; /** @internal register a describedby id */ setDescribedBy: (id: string) => void; /** @internal remove a labelledby id */ removeLabelledBy: (id: string) => void; /** @internal remove a describedby id */ removeDescribedBy: (id: string) => void; } interface NgpDialogProps { /** The id of the dialog */ readonly id?: Signal; /** The dialog role. */ readonly role?: Signal; /** Whether the dialog is a modal. */ readonly modal?: Signal; } declare const NgpDialogStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<{ id: Signal; role: Signal; modal: Signal; close: (result?: unknown) => void; setLabelledBy: (id: string) => void; setDescribedBy: (id: string) => void; removeLabelledBy: (id: string) => void; removeDescribedBy: (id: string) => void; }>>; declare const ngpDialog: ({ id, role, modal, }: NgpDialogProps) => { id: Signal; role: Signal; modal: Signal; close: (result?: R) => void; setLabelledBy: (id: string) => void; setDescribedBy: (id: string) => void; removeLabelledBy: (id: string) => void; removeDescribedBy: (id: string) => void; }; declare const provideDialogState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; declare function injectDialogState(options?: StateInjectionOptions): Signal>; export { NgpDialog, NgpDialogDescription, NgpDialogDescriptionStateToken, NgpDialogManager, NgpDialogOverlay, NgpDialogOverlayStateToken, NgpDialogPanelStateToken, NgpDialogRef, NgpDialogStateToken, NgpDialogTitle, NgpDialogTitleStateToken, NgpDialogTrigger, NgpDialogTriggerStateToken, injectDialogConfig, injectDialogDescriptionState, injectDialogOverlayState, injectDialogPanelState, injectDialogRef, injectDialogState, injectDialogTitleState, injectDialogTriggerState, ngpDialog, ngpDialogDescription, ngpDialogOverlay, ngpDialogPanel, ngpDialogTitle, ngpDialogTrigger, provideDialogConfig, provideDialogDescriptionState, provideDialogOverlayState, provideDialogPanelState, provideDialogState, provideDialogTitleState, provideDialogTriggerState }; export type { NgpDialogConfig, NgpDialogContext, NgpDialogDescriptionProps, NgpDialogDescriptionState, NgpDialogOverlayProps, NgpDialogOverlayState, NgpDialogPanelProps, NgpDialogPanelState, NgpDialogProps, NgpDialogState, NgpDialogTitleProps, NgpDialogTitleState, NgpDialogTriggerProps, NgpDialogTriggerState };