import * as _odx_angular_components_modal from '@odx/angular/components/modal'; import * as i0 from '@angular/core'; import { ViewContainerRef, Type, Injector, AfterContentInit, ValueProvider, OnChanges, OnDestroy, TemplateRef, EventEmitter } from '@angular/core'; import { DynamicTextContent, DynamicContent } from '@odx/angular/cdk/dynamic-view'; import * as i1 from '@odx/angular/components/button'; import { ButtonVariant } from '@odx/angular/components/button'; import * as rxjs from 'rxjs'; import * as i13 from '@odx/angular'; import { Controller } from '@odx/angular'; import * as i14 from '@odx/angular/components/area-header'; import { AreaHeaderComponent } from '@odx/angular/components/area-header'; import * as _odx_angular_utils from '@odx/angular/utils'; import { NgChanges } from '@odx/angular/utils'; import * as i2 from '@odx/angular/components/button-group'; type ModalHeroVariant = (typeof ModalHeroVariant)[keyof typeof ModalHeroVariant]; declare const ModalHeroVariant: { readonly PRIMARY: "primary"; readonly SUCCESS: "success"; readonly CONFIRMATION: "confirmation"; readonly DANGER: "danger"; }; interface ModalAction { label: string; data?: Result; variant?: ButtonVariant; } type GetModalActionData = Exclude; interface BasicModalOptions { title: DynamicTextContent; actions: ModalAction[]; content?: DynamicContent; heroIcon?: string; heroVariant?: ModalHeroVariant; } type ModalSize = (typeof ModalSize)[keyof typeof ModalSize]; declare const ModalSize: { readonly XSMALL: "xsmall"; readonly SMALL: "small"; readonly MEDIUM: "medium"; readonly LARGE: "large"; }; type ModalVariant = typeof ModalVariant[keyof typeof ModalVariant]; declare const ModalVariant: { readonly DEFAULT: "default"; readonly SIDESHEET: "sidesheet"; }; interface ModalInstanceOptions { id: string; dismissable: boolean; interactiveBackdrop: boolean; size: ModalSize; variant: ModalVariant; } interface ModalOptionsExtras { data: Data; host: Element | ViewContainerRef; dismissOnNavigation: boolean; canClose?: (data: Data) => boolean; canDismiss?: (data: Data) => boolean; } type ModalOptions = ModalInstanceOptions & ModalOptionsExtras; /** * A reference to a dynamically created modal, providing methods to manipulate, close, or update the modal's state * and options. * This class extends the `Controller` base class from `@odx/angular`, adding modal-specific functionalities like * handling closures and dismissals. * * @template Data - The type of data passed to the modal. * @template Result - The type of the result emitted when the modal is closed. * * @see {Controller} */ declare class ModalRef extends Controller { private internalOptions; private readonly onClose$$; private readonly onDismiss$$; private readonly onDestroy$$; /** An observable that emits when the modal is closed with a result. */ readonly onClose$: rxjs.Observable; /** An observable that emits when the modal is dismissed without a result. */ readonly onDismiss$: rxjs.Observable; /** An observable that emits when modal is destroyed regardless of the trigger path. */ readonly onDestroy$: rxjs.Observable; /** A method that returns whether the modal is currently active. */ readonly isActive: () => boolean; /** Gets the unique identifier for the modal instance. * * @returns {string} The unique identifier for the modal instance. */ get id(): string; /** Gets the ARIA label ID for the modal title, based on the modal's ID. * * @returns {string} The ARIA label ID for the modal title. */ get modalTitleId(): string; /** Gets the data passed to the modal. This is useful for modal initialization. * * @returns {Data} The data passed to the modal. */ get data(): Data; /** Gets the current options for the modal. These options include configurations. * * @template Data - The type of data passed to the modal. * @returns {ModalOptions} The current options for the modal. */ get options(): ModalOptions; constructor(internalOptions: ModalOptions, isActive: (modalRef: ModalRef) => boolean); /** * Updates the modal's options. * * @param {Partial>} options A partial set of options to update. */ update(options: Partial>): void; /** * Dismisses the modal. This does not result in an output value. * * @param {boolean} [force=false] Whether to force dismissal regardless of the `canDismiss` condition. */ dismiss(force?: boolean): void; /** * Closes the modal with a result. * * @param {Result} result The result to emit when the modal closes. */ close(result: Result): void; /** Completes the onClose and onDismiss streams and cleans up resources. */ destroy(): void; } interface Modal { readonly modalRef?: ModalRef; } type ModalType = Type | { new (modalRef?: ModalRef): Modal; }; /** * Represents a basic modal component that can be used to display dynamic content, handle modal actions, and interact * with other components through dependency injection. It includes common modal features such as headers, footers, and dynamic content areas. * This component uses the `ModalRef` to manage its state and interactions. * * The `BasicModalComponent` is designed to be flexible and reusable for various modal dialog needs within an application. * * @template Result The expected result type that the modal might produce, typically used when the modal closes. */ declare class BasicModalComponent implements Modal, GetModalActionData>> { protected readonly injector: Injector; /** * The reference to the modal. * * @type {ModalRef>} */ readonly modalRef: _odx_angular_components_modal.ModalRef, Exclude>; protected get data(): BasicModalOptions; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵcmp: i0.ɵɵComponentDeclaration, "odx-basic-modal", never, {}, {}, never, never, true, never>; } /** * Represents the footer component of a modal. */ declare class ModalFooterComponent { readonly element: i0.ElementRef; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Represents the header component of a modal. */ declare class ModalHeaderComponent implements AfterContentInit { protected readonly modalRef: _odx_angular_components_modal.ModalRef; readonly element: i0.ElementRef; /** * The area header component associated with the modal header. * * @type {AreaHeaderComponent | undefined} */ areaHeaderComponent?: AreaHeaderComponent; constructor(); ngAfterContentInit(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Represents a modal hero component. */ declare class ModalHeroComponent { readonly element: i0.ElementRef; /** * The modal reference of the modal hero component. * * @type {ModalRef} */ readonly modalRef: _odx_angular_components_modal.ModalRef; /** * The icon of the modal hero component. * * @example `iconSet::iconName`. * @type {string} */ icon?: string | null; /** * The variant of the modal hero component. * * @type {ModalHeroVariant | null} */ variant?: ModalHeroVariant | null; constructor(); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * A directive that enables an element to close or dismiss a modal when clicked. * It can be used on any element within a modal to trigger the close or dismiss action, optionally passing a result back to the modal opener. * * The directive accepts an input value that determines the result to be passed back on modal close. If no value is provided, or it's explicitly set to `null`, * the modal is dismissed without sending a result. If the input value is `undefined`, the modal is dismissed via the `dismiss` method without passing any result. * * @template T - The type of the result to be emitted when the modal closes. Defaults to `unknown`. * * @example * Closing a modal and passing a result: * ```html * * ``` * * Simply dismissing a modal without passing a result: * ```html * * ``` */ declare class ModalCloseDirective { private readonly modalRef; /** * Represents the result to be passed back to the modal opener when the modal is closed. * @template T - The type of the result returned. */ result?: T | null; protected onClick(): void; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵdir: i0.ɵɵDirectiveDeclaration, "[odxModalClose]", never, { "result": { "alias": "odxModalClose"; "required": false; }; }, {}, never, never, true, never>; } /** * Represents a directive for the content of a modal. */ declare class ModalContentDirective { readonly element: i0.ElementRef; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * A directive that enables an element to dismiss a modal when clicked. This can be applied * to any clickable element within a modal, such as buttons or links, to provide a declarative * approach to dismissing the modal. * * Utilizes `injectModalRef` to access the modal reference associated with the containing modal, * enabling the directive to call the `dismiss` method on the modal reference upon the click event. * * @example * Dismissing a modal using the odxModalDismiss directive on a button: * ```html * * ``` * * This directive simplifies modal dismissal by removing the need for manually wiring click events * to dismiss methods in the component class, thereby enhancing template readability and maintainability. */ declare class ModalDismissDirective { private readonly modalRef; protected onClick(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Directive that prevents the default form method behavior on submit buttons inside an HTML Dialog form. */ declare class PreventFormMethodDialogDirective { protected onClick(event: Event): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Directive that prevents the default form submission behavior inside an HTML Dialog form. */ declare class PreventMethodDialogDirective { protected onFormSubmit(event: Event): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Utility function to inject a reference to a modal. This function simplifies the injection process by typing the `ModalRef` to the specific data and result expected by the consumer. * * This approach abstracts away Angular's inject function, providing direct access to the modal reference with the correct type. It is commonly used in components or services that interact with a modal dialog to manipulate its data, close it, or perform other related actions. * * @template Data The type of data passed to the modal. * @template Result The type of result expected when the modal closes. * @returns {ModalRef} A strongly typed reference to the modal. * * @example * ```ts * // Injecting a modal reference in a component or service: * const modalRef = injectModalRef(); * * // Using the modal reference to close the modal and return a result: * modalRef.close(someResult); * * // Accessing the data provided to the modal: * const modalData = modalRef.data; * ``` */ declare function injectModalRef(): ModalRef; /** * Provides a configuration for the Angular dependency injection system to inject a specific instance of `ModalRef`. * This function is particularly useful when you want to configure a provider for a `ModalRef` within an Angular module or component. * * @template D The data type expected by the modal. * @template R The result type that the modal will produce. * @param {ModalRef} modalRef An instance of `ModalRef` to be provided. * @returns {ValueProvider} An Angular value provider that can be used in module or component providers arrays. */ declare function provideModalRef(modalRef: ModalRef): ValueProvider; /** * A component that represents a modal dialog with dynamic content and customizable animations. * It supports both modal and sidesheet variants with configurable animations for each type. */ declare class ModalComponent implements OnChanges { protected readonly modalRef: _odx_angular_components_modal.ModalRef; protected readonly injector: Injector; protected readonly context: { $implicit: _odx_angular_components_modal.ModalRef; }; readonly element: i0.ElementRef; /** * Size of the modal as a CSS modifier based on modal options. * * @type {ModalSize} */ size: _odx_angular_components_modal.ModalSize; /** * Variant of the modal as a CSS modifier that influences animation choices. * * @type {ModalVariant} */ variant: _odx_angular_components_modal.ModalVariant; /** * Boolean that indicates if the content is a component type rather than a template. * * @type {boolean} * @default false */ withComponent: boolean; /** * Dynamic content to be loaded into the modal. Excludes simple textual content * to enable complex Angular components or templates. * * @type {Exclude} */ content: Exclude; constructor(); ngOnChanges(changes: NgChanges): void; protected preventNativeDismiss(event: Event): void; protected handleDialogClose({ target }: Event): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Utilizes `createConfigTokens` to create configuration tokens and utility functions for managing modal configurations. * This setup enables easy injection and provision of default global settings for modals throughout the application, * fostering consistency and ease of customization. * * The generated tokens and functions include: * - `ModalDefaultConfig`: The default configuration values for modals. * - `ModalConfig`: An Angular `InjectionToken` for injecting modal configuration into components or services. * - `injectModalConfig`: A utility function for retrieving the current modal configuration, considering any overrides. * - `provideModalConfig`: A function that allows specifying overrides to the default modal configuration. * * @example * ```ts * // Example of providing a custom modal configuration in an Angular module * @NgModule({ * providers: [ * provideModalConfig({ * size: ModalSize.LARGE, * dismissable: false * }) * ] * }) * class AppModule {} * * // Example of injecting modal configuration in a component * @Component({...}) * export class MyComponent { * constructor(@Inject(ModalConfig) private modalConfig: ModalConfig) { * console.log(this.modalConfig.size); // Outputs the size from the provided or default configuration * } * } * ``` */ declare const ModalDefaultConfig: ModalConfig; type ModalConfig = Omit; declare const ModalConfig: i0.InjectionToken>; declare const injectModalConfig: () => ModalConfig; declare const provideModalConfig: >>(config: _odx_angular_utils.ConfigProvider, D>) => i0.FactoryProvider | i0.ValueProvider; /** * A directive that simplifies the creation and management of modals directly from Angular templates. * It allows for declarative modal instantiation with full control over modal options, and supports * capturing modal close and dismiss events. * * Usage: * Apply `odxModal` to an `` element and bind it to modal options. */ declare class ModalDirective implements OnChanges, OnDestroy { private readonly modalService; private modalRef; protected readonly template: TemplateRef; /** * Options for the modal directive. * * @type {Partial | '' | null} */ modalOptions?: Partial | '' | null; /** * Event emitter for closing the modal. * * @emits {any} The result of the modal close event. */ modalClose: EventEmitter; /** * Event emitter for dismissing the modal. * * @emits {any} The result of the modal dismiss event. */ modalDismiss: EventEmitter; ngOnChanges(changes: NgChanges): void; ngOnDestroy(): void; /** * Opens the modal based on the provided template and options. Binds modal result and dismissal outputs to EventEmitter properties. */ open(): void; /** * Dismisses the currently opened modal. */ dismiss(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class ModalModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } /** * Service for managing modal dialogs within the application. It supports creating, opening, * and dismissing modals dynamically, with comprehensive options for customization and lifecycle management. * Utilizes Angular's dynamic view management to instantiate and render modals as needed. * * @example * ```ts * // Example of using ModalService to open a modal * constructor(private modalService: ModalService) {} * * openModal() { * const modalRef = this.modalService.open(MyModalContentComponent, { * data: { someData: 'test' }, * size: ModalSize.SMALL, * }); * * modalRef.onClose$.subscribe(result => { * console.log('Modal closed with result:', result); * }); * } * ``` */ declare class ModalService { private readonly config; private readonly openModals; private readonly injector; private readonly dynamicViewService; private readonly document; /** * An observable that emits the current value of the openModals subject. * * @emits {ModalRef[]} openModals$ - The current array of open modals. */ readonly openModals$: rxjs.Observable<(ModalRef & { id: string | number; })[]>; constructor(); /** * Dismisses all open modals. */ dismissAll(): void; /** * Retrieves the modal reference by its ID. * * @template Data The type of data passed to the modal. * @template Result The type of result returned by the modal. * @param {ModalOptions['id']} id The ID of the modal. * @returns {ModalRef | null} - The modal reference if found, otherwise null. */ getModalById(id: ModalOptions['id']): ModalRef | null; /** * Creates a modal with the specified options. * @template Data - The type of data passed to the modal for use in its content. * @template Result - The type of result expected when the modal is closed. * @param {Data} modal - The basic modal options. * @param {Partial> | undefined} options - Additional modal options. * @returns {ModalRef} The reference to the created modal. */ create>(modal: Data, options?: Partial>): ModalRef; /** * Creates and opens a new modal with the specified content and options. * * @template Data - The type of data passed to the modal for use in its content. * @template Result - The type of result expected when the modal is closed. * @template T - The content type of the modal, either a `TemplateRef` or a component. * @param {ModalType | TemplateRef} content - The content of the modal, either as a `TemplateRef` or a component type. * @param {Partial>} [options] - Optional configuration options for the modal. * @returns {ModalRef} A reference to the newly opened modal, allowing interaction with and control over the modal instance. */ open(content: TemplateRef, options?: Partial>): ModalRef; open(content: ModalType, options?: Partial>): ModalRef; private attachModal; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } export { BasicModalComponent, ModalCloseDirective, ModalComponent, ModalConfig, ModalContentDirective, ModalDefaultConfig, ModalDirective, ModalDismissDirective, ModalFooterComponent, ModalHeaderComponent, ModalHeroComponent, ModalHeroVariant, ModalModule, ModalRef, ModalService, ModalSize, ModalVariant, PreventFormMethodDialogDirective, PreventMethodDialogDirective, injectModalConfig, injectModalRef, provideModalConfig, provideModalRef }; export type { BasicModalOptions, GetModalActionData, Modal, ModalInstanceOptions, ModalOptions, ModalOptionsExtras, ModalType };