import * as i0 from '@angular/core'; import { OnChanges, OnDestroy, ChangeDetectorRef, Provider, InjectionToken, ElementRef, OnInit, EventEmitter, Type } from '@angular/core'; import * as rxjs from 'rxjs'; import { Observable } from 'rxjs'; import { NgChanges } from '@odx/angular/utils'; import * as i4 from '@angular/common'; /** * Sets up change detection for the provided controllers within the context of an Angular component or directive. * It listens for changes from the specified controllers and triggers Angular's change detection mechanism in response. * * @param {...Array} controllers - The controllers to monitor for changes. * @returns {Observable} An observable that emits whenever a change occurs in any of the provided controllers. */ declare function detectControllerChanges(...controllers: Array): Observable; /** * An abstract base class representing a controller that can notify observers of changes in its state. * It provides lifecycle hooks for ngOnChanges and ngOnDestroy to manage its internal change observable. */ declare abstract class Controller implements OnChanges, OnDestroy { private readonly change$$; /** * Represents an observable stream of changes. * @readonly */ readonly change$: Observable; /** * Sets up a controller instance to emit change events and trigger Angular change detection whenever * the controller's state changes. It is a utility method that can be used to initialize controllers * that are managed outside of Angular's DI system. * * @static * @param {Controller | null} controller - The controller instance to set up. * @param {ChangeDetectorRef} changeDetector - The Angular change detector reference to trigger change detection. * @returns {Controller | null} The same controller instance for chaining or null if the controller is not provided. */ static setup(controller: Controller | null, changeDetector: ChangeDetectorRef): Controller | null; ngOnChanges(): void; ngOnDestroy(): void; protected triggerControllerChange(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare const DISABLED_CONTROLLER: InjectionToken; declare const DISABLED_INTERNAL_CONTROLLER: InjectionToken; /** * Directive that provides hierarchical disabled state management for Angular components or directives. * It allows for a disabled state to be inherited from parent components, facilitating the propagation * of disabled states down component trees. This is particularly useful in forms or complex component * structures where nested components need to respond to disabled states dynamically. * * The `DisabledController` works by injecting itself or a parent `DisabledController` instance to determine * the effective disabled state, taking into account both its own state and that of its parents. * * Usage: * Apply the `disabled` attribute, potentially bound to a component property, to use this directive. * The directive can be automatically provided to the component's children by calling the `connect` * static method in the component's providers array. * * @example * ```ts * @Component({ * selector: 'app-custom-input', * templateUrl: './custom-input.component.html', * providers: [DisabledController.connect()], * standalone: true, * }) * export class CustomInputComponent { * constructor(private disabledCtrl: DisabledController) {} * } * ``` * ```html * * ``` */ declare class DisabledController extends Controller { private readonly parentController; private isDisabled; /** * A reactive representation of the current effective disabled state, considering both * the controller's own state and that of its parent controllers. * * @emits {boolean} - The current disabled state. */ readonly isDisabled$: rxjs.Observable; /** * Sets the disabled state of the current controller. If the state changes, updates the internal * flag. * * @param {boolean} value - The new disabled state to be applied. */ set disabled(value: boolean); /** * Gets a value indicating whether the controller is disabled. * * @returns {boolean} - `true` if the controller is disabled, `false` otherwise. */ get disabled(): boolean; /** * Retrieves an instance of the `DisabledController` class from the dependency injection container. * If the `DisabledController` is not registered in the container, it returns `null`. * * @static * @returns {DisabledController | null} An instance of the `DisabledController` class or `null` if not found. */ static inject(): DisabledController | null; /** * Static method to facilitate the injection of the `DisabledController` within Angular's DI system. * This method provides a way to connect a component with its closest `DisabledController` parent, * allowing for disabled state inheritance. * * @static * @returns {Provider[]} An array of providers to enable disabled state management within a component. */ static connect(): Provider[]; /** * Sets the disabled state of the current controller and triggers change detection if the state changes. * * @param {boolean} state - The new disabled state to be applied. */ setDisabledState(state: boolean): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; static ngAcceptInputType_disabled: unknown; } declare const READONLY_CONTROLLER: InjectionToken; declare const READONLY_INTERNAL_CONTROLLER: InjectionToken; /** * Directive to manage and propagate the readonly state within Angular components or directives, * particularly useful for form elements like input, textarea, and select. It supports hierarchical * readonly state management, allowing a parent component's readonly state to be inherited by its children. * * The directive leverages Angular's dependency injection system to access parent readonly controllers, * enabling a cascading readonly state. This is beneficial in scenarios where a form or a part of it * should become readonly based on certain conditions. * * Usage: * Apply the `readonly` attribute, potentially bound to a component property, to use this directive. * The directive can automatically provide itself to the component's children by calling the `connect` * static method in the component's providers array. * * @example * ```ts * @Component({ * selector: 'app-custom-input', * templateUrl: './custom-input.component.html', * providers: [ReadonlyController.connect()], * standalone: true, * }) * export class CustomInputComponent { * constructor(private readonlyCtrl: ReadonlyController) {} * } * ``` * * Template for CustomInputComponent with conditional readonly state: * ```html * * ``` */ declare class ReadonlyController extends Controller { private readonly parentController; private readonly nodeName; private isReadonly; protected hasReadonlyAttribute: boolean; /** * An observable that emits the current value of the `isReadonly` property whenever it changes. * The emitted values are distinct and replayed to new subscribers. * * @emits {boolean} The current readonly state of the controller. */ readonly isReadonly$: rxjs.Observable; /** * Sets the readonly state of the current controller. If the state changes, updates the internal * flag that controls the rendering of the `readonly` attribute in the host element. * * @param {boolean} value - The new readonly state to be applied. */ set readonly(value: boolean); get readonly(): boolean; constructor(element?: ElementRef | null); /** * Returns an instance of the ReadonlyController or null if it cannot be found. * * @static * @returns {ReadonlyController | null} An instance of the ReadonlyController or null. */ static inject(): ReadonlyController | null; /** * Static method to facilitate the injection of the `ReadonlyController` within Angular's DI system. * This method provides a way to connect a component with its closest `ReadonlyController` parent, * allowing for readonly state inheritance. * * @static * @returns {Provider} An array of providers to enable readonly state management within a component. */ static connect(): Provider; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; static ngAcceptInputType_readonly: unknown; } /** * Directive to detect clicks outside of an element. When active, it listens for clicks outside * the host element and emits an event through the `odxClickOutside` EventEmitter. This is useful * for handling UI logic that depends on outside clicks, such as closing a dropdown or modal * when the user clicks elsewhere on the page. * * Apply `odxClickOutside` to an element and bind an event handler to react to outside clicks. * Optionally, use `[odxClickOutsideActive]="condition"` to enable or disable the detection dynamically. * * @example * ```html *
* *
* ``` */ declare class ClickOutsideDirective implements OnChanges, OnInit, OnDestroy { private listener?; private readonly element; private readonly renderer; private readonly onOutsideClick$; /** * Controls whether the outside click detection is active. When `true`, the directive listens for outside clicks. * * @type {boolean} * @default true */ odxClickOutsideActive: boolean; /** * EventEmitter that emits the native Event object when an outside click is detected. * * @emits {Event} */ readonly odxClickOutside: EventEmitter; ngOnInit(): void; ngOnChanges(changes: NgChanges): void; ngOnDestroy(): void; private destroy; private registerHandler; private registerEventHandler; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; static ngAcceptInputType_odxClickOutsideActive: unknown; } declare class CoreModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } /** * A directive to manage focus within components. It emits events when the host component is focused, * and dynamically updates the `tabindex` attribute to control focusability. This directive is particularly * useful for custom components that require explicit focus management, such as custom input components * or complex interactive components. * * The directive ensures that the component can be focused by setting `tabindex="0"`, making it reachable * via keyboard navigation. When the component gains focus (`focusin`), it becomes non-focusable (`tabindex="-1"`) * to manage focus delegation internally. It restores its focusability (`tabindex="0"`) when losing focus (`focusout`), * allowing it to be focused again in the future. */ declare class DelegateFocusDirective { protected tabindex: number; /** * Emits an event when the element is focused. */ focused: EventEmitter; protected handleFocus(): void; protected handleFocusIn(): void; protected handleFocusOut(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class WithDisabledState { protected readonly hasAriaRole: boolean; protected readonly hasDisabledAttribute: boolean; protected readonly disabledController: DisabledController | null; protected get isDisabled(): boolean; get ariaDisabled(): string | null; constructor(); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class WithTabIndex { private readonly isDisabled$; private readonly tabindex; private readonly tabindex$; constructor(); setTabindex(value: number | null): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } type Environment = typeof Environment[keyof typeof Environment]; declare const Environment: { readonly DEV: "dev"; readonly STAGE: "stage"; readonly PROD: "prod"; }; /** * A service that wraps window and document functionalities, providing Angular-friendly ways to interact with the browser's window object, * manage the document and its title, listen to online/offline events, and perform other browser-related operations. */ declare class WindowRef { private readonly title; /** * Accesses the document object, ensuring Angular compatibility and potential SSR friendliness. * * @type {Document} */ readonly document: Document; /** * Retrieves the native window object, with a fallback to the global window if necessary. * This approach helps ensure compatibility with Angular's SSR features. * * @type {Window} */ readonly nativeWindow: Window & typeof globalThis; /** * An observable that emits the online status of the browser, updating when the browser transitions * between online and offline states. * * @emits {boolean} True if the browser is online; otherwise, false. */ readonly isOnline$: rxjs.Observable; /** * An observable that emits the current page title upon navigation ends, * useful for updating document titles in SPA applications. * * @emits {string} The current page title. */ readonly pageTitle$: rxjs.Observable; /** * Gets the location object of the window. * * @returns {Location} The location object of the window. */ get location(): Location; /** * Determines if the browser is currently online. * * @returns {boolean} True if the browser is online; otherwise, false. */ isOnline(): boolean; /** * Retrieves the browser's current language setting, falling back through several browser-specific properties. * * @returns {string} The current language setting of the browser. */ getLanguage(): string; /** * Extracts the language code from the browser's current language setting. * * @returns {string} The language code part of the browser's language setting. */ getLanguageCode(): string; /** * Returns the origin of the current window location. * * @returns The origin of the current window location. */ getOrigin(): string; /** * Opens a new browser tab or window and navigates to the specified URL. * * @param {string | URL} [url] - The URL to open. * @param {string} [target] - The target window or tab. * @param {string} [features] - String that specifies the window features. * @returns {WindowProxy | null} A reference to the newly opened window or null if the call failed. */ openPage(url?: string | URL, target?: string, features?: string): WindowProxy | null; /** * Reloads the current page. */ reloadPage(): void; /** * Queries the DOM for an element associated with a specific Angular component type. * * @template T The component type to query for. * @param {Type} type - The Angular component type. * @returns {HTMLElement | null} The HTML element associated with the component, or null if not found. */ queryByComponent(type: Type): HTMLElement | null; /** * Retrieves the value of a CSS variable on a specified element. * * @param {string} name - The name of the CSS variable. * @param {HTMLElement} [element=this.document.body] - The element from which to retrieve the CSS variable. * @returns {string} The value of the CSS variable. */ getCSSVariable(name: string, element?: HTMLElement): string; /** * Extracts CSS color styles that match a specific filter from the document's stylesheets. * * @param {string} filter - The filter to apply to CSS variable names. * @param {string} [selector=':root'] - The CSS selector to filter by. * @returns {Record} A record containing the filtered CSS color styles. */ getCSSColorStyles(filter: string, selector?: string): Record; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * A function type that defines the logic to compare two items for identity. * It should return `true` if the items are considered identical, otherwise `false`. * * @template T The type of the items to be compared. * @param {T} item1 The first item to compare. * @param {T} item2 The second item to compare. * @returns {boolean} `true` if the items are identical, otherwise `false`. * * @example * ```ts * // A simple identity matcher for number types * const numberMatcher: IdentityMatcher = (n1, n2) => n1 === n2; * console.log(numberMatcher(1, 1)); // Outputs: true * console.log(numberMatcher(1, 2)); // Outputs: false * ``` */ type IdentityMatcher = (item1: T, item2: T) => boolean; /** * An Angular `InjectionToken` for the `IdentityMatcher` function, allowing for the provision * and injection of custom identity matching logic throughout the application. The token is * provided with a default factory function that returns the `ODX_DEFAULT_IDENTITY_MATCHER`, * which can be overridden with custom logic as needed. * * @type {InjectionToken>} * * @example * ```ts * // Providing a custom identity matcher in an Angular module * @NgModule({ * providers: [ * { provide: ODX_IDENTITY_MATCHER, useValue: (item1, item2) => item1.id === item2.id } * ] * }) * class AppModule {} * * // Injecting and using the custom provided identity matcher * constructor(@Inject(ODX_IDENTITY_MATCHER) private identityMatcher: IdentityMatcher) { * console.log(this.identityMatcher({ id: 1 }, { id: 1 })); // Depends on the custom logic provided * } * ``` */ declare const ODX_IDENTITY_MATCHER: InjectionToken>; /** * A function type that defines the logic to search within a string item using a query string. * It should return `true` if the item matches the query according to the implemented logic, otherwise `false`. * * @param {string} item - The string item to search within. * @param {string} query - The query string to search for. * @returns {boolean} `true` if the query matches the item, otherwise `false`. * * @example * ```ts * // A simple case-insensitive search * const searchHandler: StringSearchHandler = (item, query) => item.toLowerCase().includes(query.toLowerCase()); * console.log(searchHandler('Hello World', 'world')); // Outputs: true * ``` */ type StringSearchHandler = (item: string, query: string) => boolean; /** * An Angular `InjectionToken` for the `StringSearchHandler` function, allowing for the provision * and injection of custom string search logic throughout the application. This token is provided with * a default factory function that returns the `ODX_DEFAULT_STRING_SEARCH_HANDLER`, which can be overridden * with custom logic as needed. * * @type {InjectionToken} * * @example * ```ts * // Providing a custom string search handler in an Angular module * @NgModule({ * providers: [ * { provide: ODX_STRING_SEARCH_HANDLER, useValue: (item, query) => item.startsWith(query) } * ] * }) * class AppModule {} * * // Injecting and using the custom provided string search handler * constructor(@Inject(ODX_STRING_SEARCH_HANDLER) private searchHandler: StringSearchHandler) { * console.log(this.searchHandler('Angular', 'A')); // Depends on the custom logic provided * } * ``` */ declare const ODX_STRING_SEARCH_HANDLER: InjectionToken; /** * A function type that defines the logic to convert an item of any type into a string. * The function should handle various types gracefully, returning a meaningful string representation * for each. If the item is not present (null or undefined), an empty string should be returned. * * @template T The type of the item to be stringified. * @param {T} item - The item to stringify. * @returns {string} The string representation of the item. * * @example * ```ts * // A simple stringify function that handles null and undefined * const stringify: StringifyFn = (item) => (isPresent(item) ? String(item) : ''); * console.log(stringify(123)); // Outputs: "123" * console.log(stringify(null)); // Outputs: "" * ``` */ type StringifyFn = (item: T) => string; /** * An Angular `InjectionToken` for the `StringifyFn` function, allowing the injection of custom * stringification logic throughout an application. By default, it is provided with a factory * function that returns `ODX_DEFAULT_STRINGIFY`. This setup permits easy customization of * how items are converted to strings, facilitating different stringification strategies * for various application needs. * * @type {InjectionToken>} * * @example * ```ts * // Providing a custom stringify function in an Angular module * @NgModule({ * providers: [ * { provide: ODX_STRINGIFY, useValue: (item) => JSON.stringify(item) } * ] * }) * class AppModule {} * * // Injecting and using the custom provided stringify function * constructor(@Inject(ODX_STRINGIFY) private stringify: StringifyFn) { * console.log(this.stringify({ key: 'value' })); // Outputs: '{"key":"value"}' * } * ``` */ declare const ODX_STRINGIFY: InjectionToken>; export { ClickOutsideDirective, Controller, CoreModule, DISABLED_CONTROLLER, DISABLED_INTERNAL_CONTROLLER, DelegateFocusDirective, DisabledController, Environment, ODX_IDENTITY_MATCHER, ODX_STRINGIFY, ODX_STRING_SEARCH_HANDLER, READONLY_CONTROLLER, READONLY_INTERNAL_CONTROLLER, ReadonlyController, WindowRef, WithDisabledState, WithTabIndex, detectControllerChanges }; export type { IdentityMatcher, StringSearchHandler, StringifyFn };