import * as _angular_core from '@angular/core'; import { Signal, ElementRef, WritableSignal, OnDestroy, Provider } from '@angular/core'; import { BooleanInput } from '@angular/cdk/coercion'; import * as ng_primitives_state from 'ng-primitives/state'; import { StateInjectionOptions, SetterOptions } from 'ng-primitives/state'; import * as ng_primitives_a11y from 'ng-primitives/a11y'; import { activeDescendantManager } from 'ng-primitives/a11y'; import * as ng_primitives_portal from 'ng-primitives/portal'; import { NgpOverlay, NgpPlacement, NgpFlip, NgpOffset, NgpFlipInput, NgpOffsetInput } from 'ng-primitives/portal'; import { Observable } from 'rxjs'; import * as ng_primitives_select from 'ng-primitives/select'; /** * Apply the `ngpNativeSelect` directive to a select element that you want to enhance. */ declare class NgpNativeSelect { /** * The id of the select. If not provided, a unique id will be generated. */ readonly id: _angular_core.InputSignal; /** * Whether the select is disabled. */ readonly disabled: _angular_core.InputSignalWithTransform; constructor(); static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare const injectNativeSelectState: { (): Signal<{ disabled: _angular_core.WritableSignal; setDisabled: (value: boolean) => void; }>; (options: ng_primitives_state.StateInjectionOptions): Signal<{ disabled: _angular_core.WritableSignal; setDisabled: (value: boolean) => void; } | null>; (options?: ng_primitives_state.StateInjectionOptions): Signal<{ disabled: _angular_core.WritableSignal; setDisabled: (value: boolean) => void; }> | Signal<{ disabled: _angular_core.WritableSignal; setDisabled: (value: boolean) => void; } | null>; }; declare const provideNativeSelectState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; declare class NgpSelectDropdown { /** The id of the dropdown. */ readonly id: _angular_core.InputSignal; constructor(); static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } interface NgpSelectDropdownState { /** * @internal Access the element reference. */ readonly elementRef: ElementRef; /** The id of the dropdown. */ readonly id: Signal; } interface NgpSelectDropdownProps { /** The id of the dropdown. */ readonly id?: Signal; } declare const NgpSelectDropdownStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<{ elementRef: ElementRef; id: Signal; }>>; declare const ngpSelectDropdown: ({ id: _id }: NgpSelectDropdownProps) => { elementRef: ElementRef; id: Signal; }; declare const provideSelectDropdownState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; declare function injectSelectDropdownState(options?: StateInjectionOptions): Signal; declare class NgpSelectInput { /** The id of the input. */ readonly id: _angular_core.InputSignal; /** Access the select input state. */ protected readonly state: { elementRef: _angular_core.ElementRef; id: _angular_core.Signal; focus: () => void; }; /** * Focus the input field. * @internal */ focus(): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } interface NgpSelectInputState { /** * @internal Access the element reference. */ readonly elementRef: ElementRef; /** The id of the input. */ readonly id: Signal; /** * Focus the input field. * @internal */ focus(): void; } interface NgpSelectInputProps { /** The id of the input. */ readonly id?: Signal; } declare const NgpSelectInputStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<{ elementRef: ElementRef; id: Signal; focus: () => void; }>>; declare const ngpSelectInput: ({ id }: NgpSelectInputProps) => { elementRef: ElementRef; id: Signal; focus: () => void; }; declare const provideSelectInputState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; declare function injectSelectInputState(options?: StateInjectionOptions): Signal; declare class NgpSelectList { /** The id of the list. */ readonly id: _angular_core.InputSignal; constructor(); static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } interface NgpSelectListState { /** * @internal Access the element reference. */ readonly elementRef: ElementRef; /** The id of the list. */ readonly id: Signal; } interface NgpSelectListProps { /** The id of the list. */ readonly id?: Signal; } declare const NgpSelectListStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<{ elementRef: ElementRef; id: Signal; }>>; declare const ngpSelectList: ({ id: _id }: NgpSelectListProps) => { elementRef: ElementRef; id: Signal; }; declare const provideSelectListState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; declare function injectSelectListState(options?: StateInjectionOptions): Signal; interface NgpSelectOptionState { /** * @internal Access the element reference. */ readonly elementRef: ElementRef; /** The id of the option. */ readonly id: Signal; /** The value of the option. */ readonly value: Signal; /** The disabled state of the option. */ readonly disabled: Signal; /** The index of the option in the list. */ readonly index: Signal; /** * Whether this option is the active descendant. * @internal */ readonly active: Signal; /** * Whether this option is selected. * @internal */ readonly selected: Signal; /** * Select the option. * @internal */ select(): void; /** * Scroll the option into view. * @internal */ scrollIntoView(): void; /** * Activate on pointer enter. * @internal */ activateOnPointerEnter(): void; /** * Deactivate on pointer leave. * @internal */ deactivateOnPointerLeave(): void; /** * Emit activated event. * @internal */ emitActivated(): void; } interface NgpSelectOptionProps { /** The id of the option. */ readonly id?: Signal; /** The value of the option. */ readonly value?: Signal; /** The disabled state of the option. */ readonly disabled?: Signal; /** The index of the option in the list. */ readonly index?: Signal; /** Callback when option is activated. */ readonly onActivated?: () => void; } declare const NgpSelectOptionStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<{ elementRef: ElementRef; id: Signal; value: Signal; disabled: Signal; index: Signal; active: Signal; selected: Signal; select: () => void; scrollIntoView: () => void; activateOnPointerEnter: () => void; deactivateOnPointerLeave: () => void; emitActivated: () => void | undefined; }>>; declare const ngpSelectOption: ({ id, value, disabled, index, onActivated, }: NgpSelectOptionProps) => { elementRef: ElementRef; id: Signal; value: Signal; disabled: Signal; index: Signal; active: Signal; selected: Signal; select: () => void; scrollIntoView: () => void; activateOnPointerEnter: () => void; deactivateOnPointerLeave: () => void; emitActivated: () => void | undefined; }; declare const provideSelectOptionState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; declare function injectSelectOptionState(options?: StateInjectionOptions): Signal; interface NgpSelectPortalState { /** * The overlay that manages the dropdown. * @internal */ readonly overlay: Signal | null>; /** * Show the portal. * @internal */ show(): Promise; /** * Hide the portal. * @internal */ hide(): void; /** * Destroy the overlay. The directive class calls this from ngOnDestroy so * the overlay's onClose callback fires while the parent NgpSelect's output * bindings are still attached — destroyRef.onDestroy callbacks fire after * Angular has already torn those bindings down, which would prevent * openChange(false) from reaching the consumer on fixture.destroy(). * @internal */ destroy(): void; } interface NgpSelectPortalProps { } declare const NgpSelectPortalStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal>; declare const ngpSelectPortal: ({}: NgpSelectPortalProps) => NgpSelectPortalState; declare const provideSelectPortalState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; declare function injectSelectPortalState(options?: StateInjectionOptions): Signal; interface NgpSelectOpenOptions { /** * 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'; } interface NgpSelectState { /** * @internal Access the select element. */ readonly elementRef: ElementRef; /** The unique id of the select. */ readonly id: Signal; /** The value of the select. */ readonly value: WritableSignal; /** Whether the select is multiple selection. */ readonly multiple: Signal; /** Whether the select is disabled. */ readonly disabled: WritableSignal; /** The comparator function used to compare options. */ readonly compareWith: Signal<(a: T | undefined, b: T | undefined) => boolean>; /** The position of the dropdown. */ readonly placement: Signal; /** The container for the dropdown. */ readonly container: WritableSignal; /** 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: Signal; /** * Define the offset of the select dropdown relative to the trigger. * Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis. */ readonly offset: Signal; /** * 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: Signal<((index: number) => void) | undefined>; /** * Provide all the option values to the select. 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 select with the full list of options. This list should match * the order of the options as they would appear in the DOM. */ readonly allOptions: Signal; /** * Store the select portal. * @internal */ readonly portal: WritableSignal; /** * Store the select dropdown. * @internal */ readonly dropdown: WritableSignal; /** * Store the select list, when a dedicated listbox wraps the options * (e.g. when the popup also contains a filter input). * @internal */ readonly list: Signal; /** * Store the select options. * @internal */ readonly options: WritableSignal; /** * Access the overlay * @internal */ readonly overlay: Signal | null | undefined>; /** * The open state of the select. * @internal */ readonly open: Signal; /** * The options sorted by their index or DOM position. * @internal */ readonly sortedOptions: Signal; /** * The active key descendant manager. * @internal */ readonly activeDescendantManager: ReturnType; /** * Open the dropdown. * @internal */ openDropdown(options?: NgpSelectOpenOptions): Promise; /** * Close the dropdown. * @internal */ closeDropdown(): void; /** * Handle the overlay being closed (e.g. via outside click or Escape). * Emits the openChange event and resets the active descendant. * @internal */ onOverlayClose(): void; /** * Toggle the dropdown. * @internal */ toggleDropdown(): Promise; /** * Select an option. * @param index The index of the option to select. * @internal */ selectOption(id: string): void; /** * Deselect an option. * @param option The option to deselect. * @internal */ deselectOption(option: NgpSelectOptionState): 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 select. * @param portal The dropdown portal. * @internal */ registerPortal(portal: NgpSelectPortalState): void; /** * Register the dropdown with the select. * @param dropdown The dropdown to register. * @internal */ registerDropdown(dropdown: NgpSelectDropdownState): void; /** * Register the input with the select. * @param input The input to register. * @internal */ registerInput(input: NgpSelectInputState): void; /** * Unregister the input from the select. * @param input The input to unregister. * @internal */ unregisterInput(input: NgpSelectInputState): void; /** * Register the list with the select. * @param list The list to register. * @internal */ registerList(list: NgpSelectListState): void; /** * Unregister the list from the select. * @param list The list to unregister. * @internal */ unregisterList(list: NgpSelectListState): void; /** * Register an option with the select. * @param option The option to register. * @internal */ registerOption(option: NgpSelectOptionState): void; /** * Unregister an option from the select. * @param option The option to unregister. * @internal */ unregisterOption(option: NgpSelectOptionState): void; /** * Focus the select. * @internal */ focus(): void; /** * Programmatically set the value of the select. Fires `onValueChange` and * emits on `valueChange` by default. Pass `{ emit: false }` for cases like * form `writeValue` where the internal state should sync without notifying. */ setValue(value: T | undefined, options?: SetterOptions): void; /** * Programmatically set the disabled state of the select. Used by the form * `setDisabledState` integration. */ setDisabled(disabled: boolean): void; /** * Set the container in which the dropdown should be attached. Takes effect the * next time the dropdown is opened; it does not move a dropdown that is already * open. * @param container - The new container */ setContainer(container: HTMLElement | string | null): void; /** * Observable that emits whenever the value changes. */ readonly valueChange: Observable; } interface NgpSelectProps { /** The unique id of the select. */ readonly id?: Signal; /** The value of the select. */ readonly value?: Signal; /** Event emitted when the value changes. */ readonly onValueChange?: (value: T) => void; /** Whether the select is multiple selection. */ readonly multiple?: Signal; /** Whether the select is disabled. */ readonly disabled?: Signal; /** Emit when the dropdown open state changes. */ readonly onOpenChange?: (open: boolean) => void; /** The comparator function used to compare options. */ readonly compareWith?: Signal<(a: T | undefined, b: T | undefined) => boolean>; /** The position of the dropdown. */ readonly placement?: Signal; /** The container for the dropdown. */ readonly container?: Signal; /** 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?: Signal; /** * Define the offset of the select dropdown relative to the trigger. * Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis. */ readonly offset?: Signal; /** * 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?: Signal<((index: number) => void) | undefined>; /** * Provide all the option values to the select. 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 select with the full list of options. This list should match * the order of the options as they would appear in the DOM. */ readonly allOptions?: Signal; } declare const NgpSelectStateToken: _angular_core.InjectionToken>>; declare const ngpSelect: ({ id, value: _value, multiple, disabled: _disabled, compareWith, placement, container: _container, flip, offset, scrollToOption, allOptions, onValueChange, onOpenChange, }: NgpSelectProps) => NgpSelectState; declare const provideSelectState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; declare function injectSelectState(options?: StateInjectionOptions): Signal>; declare class NgpSelectOption { /** Access the select state. */ protected readonly selectState: _angular_core.Signal>; /** 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 list. */ readonly index: _angular_core.InputSignal; /** * 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; /** Access the select option state */ protected readonly state: { elementRef: _angular_core.ElementRef; id: _angular_core.Signal; value: _angular_core.Signal; disabled: _angular_core.Signal; index: _angular_core.Signal; active: _angular_core.Signal; selected: _angular_core.Signal; select: () => void; scrollIntoView: () => void; activateOnPointerEnter: () => void; deactivateOnPointerLeave: () => void; emitActivated: () => void | undefined; }; /** * Select the option. * @internal */ select(): void; /** * Scroll the option into view. * @internal */ scrollIntoView(): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare class NgpSelectPortal implements OnDestroy { protected readonly state: NgpSelectPortalState; /** * Attach the portal. * @internal */ show(): Promise; /** * Detach the portal. * @internal */ detach(): void; ngOnDestroy(): void; 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 NgpSelect { /** Access the select configuration. */ protected readonly config: ng_primitives_select.NgpSelectConfig; /** The unique id of the select. */ readonly id: _angular_core.InputSignal; /** The value of the select. */ readonly value: _angular_core.InputSignal; /** Event emitted when the value changes. */ readonly valueChange: _angular_core.OutputEmitterRef; /** Whether the select is multiple selection. */ readonly multiple: _angular_core.InputSignalWithTransform; /** Whether the select is disabled. */ readonly disabled: _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 select 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 select. 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 select 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; /** The state of the select. */ protected readonly state: NgpSelectState; /** @internal Access the select element. */ readonly elementRef: _angular_core.ElementRef; /** * Store the select portal. * @internal */ readonly portal: _angular_core.WritableSignal; /** * Store the select dropdown. * @internal */ readonly dropdown: _angular_core.WritableSignal; /** * Store the select options. * @internal */ readonly options: _angular_core.WritableSignal; /** * Access the overlay * @internal */ readonly overlay: _angular_core.Signal | null | undefined>; /** * The open state of the select. * @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; }; /** * Open the dropdown. * @internal */ openDropdown(): Promise; /** * Close the dropdown. * @internal */ closeDropdown(): void; /** * Toggle the dropdown. * @internal */ toggleDropdown(): Promise; /** * Select an option. * @param id The id of the option to select. * @internal */ selectOption(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; /** * Focus the select. * @internal */ focus(): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } interface NgpSelectConfig { /** * The default placement for the select dropdown. * @default 'bottom' */ placement: NgpPlacement; /** * The container element or selector for the select dropdown. * This can be used to control where the dropdown is rendered in the DOM. * @default 'body' */ container: HTMLElement | string | null; /** * Whether the select 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 select 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 Select configuration * @param config The Select configuration * @returns The provider */ declare function provideSelectConfig(config: Partial): Provider[]; /** * Inject the Select configuration * @returns The global Select configuration */ declare function injectSelectConfig(): NgpSelectConfig; export { NgpNativeSelect, NgpSelect, NgpSelectDropdown, NgpSelectDropdownStateToken, NgpSelectInput, NgpSelectInputStateToken, NgpSelectList, NgpSelectListStateToken, NgpSelectOption, NgpSelectOptionStateToken, NgpSelectPortal, NgpSelectPortalStateToken, NgpSelectStateToken, injectNativeSelectState, injectSelectConfig, injectSelectDropdownState, injectSelectInputState, injectSelectListState, injectSelectOptionState, injectSelectPortalState, injectSelectState, ngpSelect, ngpSelectDropdown, ngpSelectInput, ngpSelectList, ngpSelectOption, ngpSelectPortal, provideNativeSelectState, provideSelectConfig, provideSelectDropdownState, provideSelectInputState, provideSelectListState, provideSelectOptionState, provideSelectPortalState, provideSelectState }; export type { NgpSelectConfig };