import { Type, ExistingProvider, Signal, DestroyRef, Injector } from '@angular/core'; import { BooleanInput, NumberInput } from '@angular/cdk/coercion'; import { MonoTypeOperatorFunction } from 'rxjs'; /** * A simple helper function to provide a value accessor for a given type. * @param type The type to provide the value accessor for */ declare function provideValueAccessor(type: Type): ExistingProvider; interface NgpControlStatus { valid: boolean | null; invalid: boolean | null; pristine: boolean | null; dirty: boolean | null; touched: boolean | null; pending: boolean | null; disabled: boolean | null; } declare function controlStatus(): Signal; /** * A utility type for Angular's onChange function. */ type ChangeFn = (value: T) => void; /** * A utility type for Angular's onTouched function. */ type TouchedFn = () => void; declare function booleanAttributeBinding(element: HTMLElement, attribute: string, value: Signal | undefined): void; /** * A number input `transform` for a two-way value that may be uncontrolled. * * `numberAttribute` coerces `undefined` to `NaN`, which `controlledState` reads * as a defined (controlled) value and latches the primitive into controlled * mode with a bogus number. This preserves `undefined` so an absent binding * stays uncontrolled, while coercing every other value as usual. */ declare function coerceNumberOrUndefined(value: NumberInput): number | undefined; /** * A boolean input `transform` for a two-way value that may be uncontrolled. * * `booleanAttribute` coerces `undefined` to `false`, which `controlledState` * reads as a defined (controlled) value and latches the primitive into * controlled mode. This preserves `undefined` so an absent binding stays * uncontrolled, while coercing every other value as usual. */ declare function coerceBooleanOrUndefined(value: BooleanInput): boolean | undefined; /** * Disposable functions are a way to manage timers, intervals, and event listeners * that should be cleared when a component is destroyed. * * Each disposable releases its DestroyRef registration as soon as the resource * is gone (the timer fires or the returned cleanup runs), so repeated calls - * e.g. rescheduling a timeout on every pointermove - don't accumulate destroy * callbacks for the lifetime of the host. * * This is heavily inspired by Headless UI disposables: * https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/utils/disposables.ts */ declare function injectDisposables(): { /** * Set a timeout that will be cleared when the component is destroyed. * @param callback The callback to execute * @param delay The delay before the callback is executed * @returns A function to clear the timeout */ setTimeout: (callback: () => void, delay: number) => () => void; /** * Add an event listener that will be removed when the component is destroyed. * @param target The event target * @param type The event type * @param listener The event listener * @param options The event listener options * @returns A function to remove the event listener */ addEventListener: (target: EventTarget, type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions) => () => void; /** * Set an interval that will be cleared when the component is destroyed. * @param callback The callback to execute * @param delay The delay between executions * @returns A function to clear the interval */ setInterval: (callback: () => void, delay: number) => () => void; /** * Set a requestAnimationFrame that will be cleared when the component is destroyed. * @param callback The callback to execute * @returns A function to clear the requestAnimationFrame */ requestAnimationFrame: (callback: FrameRequestCallback) => () => void; }; /** * Generate a unique id for an element * @param prefix - The prefix to use for the id * @returns The generated id */ declare function uniqueId(prefix: string): string; /** * Type validation utilities */ /** * Checks if a value is a string * @param value - The value to check * @returns true if the value is a string, false otherwise */ declare function isString(value: unknown): value is string; /** * Checks if a value is a number * @param value - The value to check * @returns true if the value is a number, false otherwise */ declare function isNumber(value: unknown): value is number; /** * Checks if a value is a boolean * @param value - The value to check * @returns true if the value is a boolean, false otherwise */ declare function isBoolean(value: unknown): value is boolean; /** * Checks if a value is a function * @param value - The value to check * @returns true if the value is a function, false otherwise */ declare function isFunction(value: unknown): value is CallableFunction; /** * Checks if a value is a plain object (but not null or array) * @param value - The value to check * @returns true if the value is a plain object, false otherwise */ declare function isObject(value: unknown): value is Record; /** * Checks if a value is undefined * @param value - The value to check * @returns true if the value is undefined, false otherwise */ declare function isUndefined(value: unknown): value is undefined; /** * Checks if a value is null or undefined * @param value - The value to check * @returns true if the value is null or undefined, false otherwise */ declare function isNil(value: unknown): value is null | undefined; /** * Checks if a value is not null and not undefined * @param value - The value to check * @returns true if the value is not null and not undefined, false otherwise */ declare function notNil(value: T | null | undefined): value is T; /** * The built-in `takeUntilDestroyed` operator does not handle the case when the component is destroyed before the source observable emits. * This operator ensures that the source observable completes gracefully without throwing an error. * https://github.com/angular/angular/issues/54527#issuecomment-2098254508 * * @internal */ declare function safeTakeUntilDestroyed(destroyRef?: DestroyRef): MonoTypeOperatorFunction; /** * Listen for changes to a signal and call a function when the signal changes. * @param source * @param fn * @param options * @param options.injector * @internal */ declare function onChange(source: Signal, fn: (value: T, previousValue: T | null | undefined) => void, options?: { injector: Injector; }): void; /** * Listen for changes to a boolean signal and call one of two functions when the signal changes. * @param source * @param onTrue * @param onFalse * @param options */ declare function onBooleanChange(source: Signal, onTrue?: () => void, onFalse?: () => void, options?: { injector: Injector; }): void; export { booleanAttributeBinding, coerceBooleanOrUndefined, coerceNumberOrUndefined, controlStatus, injectDisposables, isBoolean, isFunction, isNil, isNumber, isObject, isString, isUndefined, notNil, onBooleanChange, onChange, provideValueAccessor, safeTakeUntilDestroyed, uniqueId }; export type { ChangeFn, NgpControlStatus, TouchedFn };