import * as _angular_core from '@angular/core'; import { OnDestroy, Injector, Provider } from '@angular/core'; import * as ng_primitives_state from 'ng-primitives/state'; import * as ng_primitives_combobox from 'ng-primitives/combobox'; import * as ng_primitives_internal from 'ng-primitives/internal'; import * as ng_primitives_utils from 'ng-primitives/utils'; import { BooleanInput, NumberInput } from '@angular/cdk/coercion'; import * as ng_primitives_portal from 'ng-primitives/portal'; import { NgpOverlay, NgpPlacement, NgpFlip, NgpFlipInput, NgpOffset, NgpOffsetInput } from 'ng-primitives/portal'; import * as ng_primitives_a11y from 'ng-primitives/a11y'; declare class NgpComboboxButton { /** Access the combobox state. */ protected readonly state: _angular_core.Signal>; /** * Access the element reference. * @internal */ readonly elementRef: _angular_core.ElementRef; /** The id of the button. */ readonly id: _angular_core.InputSignal; /** The id of the dropdown. */ readonly dropdownId: _angular_core.Signal; constructor(); protected toggleDropdown(): Promise; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare class NgpComboboxDropdown { /** Access the combobox state. */ protected readonly state: _angular_core.Signal>; /** The dimensions of the combobox. */ protected readonly comboboxDimensions: _angular_core.Signal; /** The dimensions of the combobox. */ protected readonly inputDimensions: _angular_core.Signal; /** Store the combobox button dimensions. */ protected readonly buttonDimensions: _angular_core.Signal; /** * Access the element reference. * @internal */ readonly elementRef: _angular_core.ElementRef; /** The id of the dropdown. */ readonly id: _angular_core.InputSignal; constructor(); static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare class NgpComboboxInput { /** Access the combobox state. */ protected readonly state: _angular_core.Signal>; /** * Access the element reference. * @internal */ readonly elementRef: _angular_core.ElementRef; /** The id of the input. */ readonly id: _angular_core.InputSignal; /** The id of the dropdown. */ readonly dropdownId: _angular_core.Signal; /** The id of the active descendant. */ protected readonly activeDescendant: _angular_core.Signal; /** Determine if the pointer was used to focus the input. */ protected pointerFocused: boolean; /** * The control status - this is required as we apply them to the combobox element as well as the input element. * @internal */ readonly controlStatus: _angular_core.Signal; constructor(); /** Handle keydown events for accessibility. */ protected handleKeydown(event: KeyboardEvent): void; protected closeDropdown(event: FocusEvent): void; /** * Focus the input field * @internal */ focus(): void; protected highlightText(): void; protected handlePointerDown(): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare class NgpComboboxOption implements OnDestroy { /** Access the combobox state. */ protected readonly state: _angular_core.Signal>; /** * The element reference of the option. * @internal */ readonly elementRef: _angular_core.ElementRef; /** The id of the option. */ readonly id: _angular_core.InputSignal; /** @required The value of the option. */ readonly value: _angular_core.InputSignal; /** The disabled state of the option. */ readonly disabled: _angular_core.InputSignalWithTransform; /** * The index of the option in the combobox. This can be used to define the order of options * when virtual scrolling is used or when the order is not determined by DOM order. */ readonly index: _angular_core.InputSignalWithTransform; /** * Event emitted when the option is activated via click or keyboard. * This is useful for options without values that need custom behavior. */ readonly activated: _angular_core.OutputEmitterRef; /** * Whether this option is the active descendant. * @internal */ protected readonly active: _angular_core.Signal; /** Whether this option is selected. */ protected readonly selected: _angular_core.Signal; constructor(); ngOnDestroy(): void; /** * Select the option. * @internal */ select(): void; /** * Scroll the option into view. * @internal */ scrollIntoView(): void; /** * Whenever the pointer enters the option, activate it. * @internal */ protected onPointerEnter(): void; /** * Whenever the pointer leaves the option, deactivate it. * @internal */ protected onPointerLeave(): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare class NgpComboboxPortal implements OnDestroy { /** Access the combobox state. */ private readonly state; /** Access the view container reference. */ private readonly viewContainerRef; /** Access the template reference. */ private readonly templateRef; /** Access the injector. */ private readonly injector; /** * The overlay that manages the popover * @internal */ readonly overlay: _angular_core.WritableSignal | null>; constructor(); /** Cleanup the portal. */ ngOnDestroy(): void; /** * Attach the portal. * @internal */ show(): Promise; /** * Detach the portal. * @internal */ detach(): Promise; /** * Create the overlay that will contain the dropdown */ private createOverlay; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * Ideally we would use a generic type here, unfortunately, unlike in React, * we cannot infer the type based on another input. For example, if multiple * is true, we cannot infer that the value is an array of T. Using a union * type is not ideal either because it requires the user to handle multiple cases. * Using a generic also isn't ideal because we need to use T as both an array and * a single value. * * Any seems to be used by Angular Material, ng-select, and other libraries * so we will use it here as well. */ type T = any; declare class NgpCombobox { /** Access the combobox configuration. */ protected readonly config: ng_primitives_combobox.NgpComboboxConfig; /** @internal Access the combobox element. */ readonly elementRef: _angular_core.ElementRef; /** Access the injector. */ protected readonly injector: Injector; /** The value of the combobox. */ readonly value: _angular_core.InputSignal; /** Event emitted when the value changes. */ readonly valueChange: _angular_core.OutputEmitterRef; /** Whether the combobox is multiple selection. */ readonly multiple: _angular_core.InputSignalWithTransform; /** Whether the combobox is disabled. */ readonly disabled: _angular_core.InputSignalWithTransform; /** Whether the combobox allows deselection in single selection mode. */ readonly allowDeselect: _angular_core.InputSignalWithTransform; /** Emit when the dropdown open state changes. */ readonly openChange: _angular_core.OutputEmitterRef; /** The comparator function used to compare options. */ readonly compareWith: _angular_core.InputSignal<(a: T | undefined, b: T | undefined) => boolean>; /** The position of the dropdown. */ readonly placement: _angular_core.InputSignal; /** The container for the dropdown. */ readonly container: _angular_core.InputSignal; /** Whether the dropdown should flip when there is not enough space. Can be a boolean to enable/disable, or an object with padding and fallbackPlacements options. */ readonly flip: _angular_core.InputSignalWithTransform; /** * Define the offset of the combobox dropdown relative to the trigger. * Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis. * @default 0 */ readonly offset: _angular_core.InputSignalWithTransform; /** * A function that will scroll the active option into view. This can be overridden * for cases such as virtual scrolling where we cannot scroll the option directly because * it may not be rendered. */ readonly scrollToOption: _angular_core.InputSignal<((index: number) => void) | undefined>; /** * Provide all the option values to the combobox. This is useful for virtual scrolling scenarios * where not all options are rendered in the DOM. This is not an alternative to adding the options * in the DOM, it is only to provide the combobox with the full list of options. This list should match * the order of the options as they would appear in the DOM. */ readonly allOptions: _angular_core.InputSignal; /** * Store the combobox input * @internal */ readonly input: _angular_core.WritableSignal; /** * Store the combobox button. * @internal */ readonly button: _angular_core.WritableSignal; /** * Store the combobox portal. * @internal */ readonly portal: _angular_core.WritableSignal; /** * Store the combobox dropdown. * @internal */ readonly dropdown: _angular_core.WritableSignal; /** * Store the combobox options. * @internal */ readonly options: _angular_core.WritableSignal; /** * Access the overlay * @internal */ readonly overlay: _angular_core.Signal | null | undefined>; /** * Whether the dropdown has been dismissed and is only playing its exit animation. * The overlay keeps reporting itself open until that animation ends. */ private readonly closing; /** * The open state of the combobox. A dropdown that is closing counts as closed, so * input that arrives during its exit animation opens it again. * @internal */ readonly open: _angular_core.Signal; /** * The options sorted by their index or DOM position. * @internal */ readonly sortedOptions: _angular_core.Signal; /** * The active key descendant manager. * @internal */ readonly activeDescendantManager: { id: _angular_core.Signal; index: _angular_core.WritableSignal; activateByIndex: (index: number, { scroll, origin }?: ng_primitives_a11y.ActivationOptions) => void; activateById: (id: string, options?: ng_primitives_a11y.ActivationOptions) => void; first: (options?: ng_primitives_a11y.ActivationOptions) => void; last: (options?: ng_primitives_a11y.ActivationOptions) => void; next: (options?: ng_primitives_a11y.ActivationOptions) => void; previous: (options?: ng_primitives_a11y.ActivationOptions) => void; reset: ({ scroll, origin }?: ng_primitives_a11y.ActivationOptions) => void; validate: () => void; typeahead: (key: string, options?: ng_primitives_a11y.ActivationOptions) => void; }; /** * The form control status of the combobox host element itself. When the combobox is used as a * form control (e.g. via a `ControlValueAccessor` wrapper) the `NgControl` lives on an ancestor * element, so this resolves it even when there is no `ngpComboboxInput`. */ private readonly hostControlStatus; /** * The control status. When an input is present it can resolve the associated `NgControl` (whether * the control is on the input itself or an ancestor), so we use its status. Otherwise we fall back * to the combobox host's own control status so an input-less combobox still reflects validity. */ protected readonly controlStatus: _angular_core.Signal; /** The state of the combobox. */ protected readonly state: ng_primitives_state.CreatedState; constructor(); /** * Open the dropdown. * @internal */ openDropdown(options?: NgpComboboxOpenOptions): Promise; /** * Close the dropdown. * @internal */ closeDropdown(): void; /** * Handles the dropdown being closed. * Emits the openChange event and resets the active descendant. * @internal */ onOverlayClosed(): void; /** * Toggle the dropdown. * @internal */ toggleDropdown(): Promise; /** * Select an option. * @param option The option to select. * @internal */ selectOption(option: NgpComboboxOption | undefined): void; /** * Deselect an option. * @param option The option to deselect. * @internal */ deselectOption(option: NgpComboboxOption): void; /** * Toggle the selection of an option. * @param id The id of the option to toggle. * @internal */ toggleOption(id: string): void; /** * Determine if an option is selected. * @param option The option to check. * @internal */ isOptionSelected(option: T): boolean; /** * Activate the next option in the list if there is one. * If there is no option currently active, activate the selected option or the first option. * @internal */ activateNextOption(): void; /** * Activate the previous option in the list if there is one. * @internal */ activatePreviousOption(): void; /** * Register the dropdown portal with the combobox. * @param portal The dropdown portal. * @internal */ registerPortal(portal: NgpComboboxPortal): void; /** * Register the combobox input with the combobox. * @param input The combobox input. * @internal */ registerInput(input: NgpComboboxInput): void; /** * Register the combobox button with the combobox. * @param button The combobox button. * @internal */ registerButton(button: NgpComboboxButton): void; /** * Register the dropdown with the combobox. * @param dropdown The dropdown to register. * @internal */ registerDropdown(dropdown: NgpComboboxDropdown): void; /** * Register an option with the combobox. * @param option The option to register. * @internal */ registerOption(option: NgpComboboxOption): void; /** * Unregister an option from the combobox. * @param option The option to unregister. * @internal */ unregisterOption(option: NgpComboboxOption): void; /** * Focus the combobox. * When an input element is present, it will be focused. * Otherwise, the combobox element itself will be focused. * This enables keyboard navigation for comboboxes without input elements. * @internal */ focus(): void; /** * Handle keydown events for keyboard navigation and accessibility. * Supports: * - Arrow Down: Open dropdown or navigate to next option * - Arrow Up: Open dropdown or navigate to previous option * - Home: Navigate to first option * - End: Navigate to last option * - Enter: Select the currently active option * - Escape: Close the dropdown * @param event - The keyboard event * @internal */ protected handleKeydown(event: KeyboardEvent): void; /** * Handle blur events to manage dropdown closing behavior. * The dropdown will remain open if focus moves to: * - The dropdown itself * - The combobox button * - The combobox input * Otherwise, the dropdown will be closed. * @param event - The focus event * @internal */ protected onBlur(event: FocusEvent): void; private scrollTo; private getOptionAtIndex; private deferScrollTo; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * Where the combobox dropdown is placed relative to its trigger. * @deprecated Identical to `NgpPlacement` from `ng-primitives/portal` - use that instead. * Will be removed in a future major. */ type NgpComboboxPlacement = NgpPlacement; interface NgpComboboxOpenOptions { /** * Which option to activate once the dropdown has opened and its options have registered. * A selected option always wins over this preference. Defaults to `'first'`. */ readonly activate?: 'first' | 'last'; } /** * Provides the Combobox state. */ declare const provideComboboxState: (options?: ng_primitives_state.CreateStateProviderOptions) => _angular_core.FactoryProvider; /** * Injects the Combobox state. */ declare const injectComboboxState: (injectOptions?: _angular_core.InjectOptions) => _angular_core.Signal>; interface NgpComboboxConfig { /** * The default placement for the combobox dropdown. * @default 'bottom' */ placement: NgpPlacement; /** * The container element or selector for the combobox dropdown. * This can be used to control where the dropdown is rendered in the DOM. * @default 'body' */ container: HTMLElement | string | null; /** * Whether the combobox dropdown should flip when there is not enough space. * Can be a boolean to enable/disable, or an object with padding and fallbackPlacements options. * @default true */ flip: NgpFlip; /** * Define the offset of the combobox dropdown relative to the trigger. * Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis. * @default 0 */ offset: NgpOffset; } /** * Provide the default Combobox configuration * @param config The Combobox configuration * @returns The provider */ declare function provideComboboxConfig(config: Partial): Provider[]; export { NgpCombobox, NgpComboboxButton, NgpComboboxDropdown, NgpComboboxInput, NgpComboboxOption, NgpComboboxPortal, injectComboboxState, provideComboboxConfig, provideComboboxState }; export type { NgpComboboxConfig, NgpComboboxOpenOptions, NgpComboboxPlacement };