import * as i0 from '@angular/core'; import { InjectionToken, AfterContentInit, OnChanges, OnDestroy, OnInit, DoCheck, QueryList, ElementRef, EventEmitter, SimpleChanges } from '@angular/core'; import * as i2 from '@angular/cdk/overlay'; import { ScrollStrategy, Overlay, RepositionScrollStrategy, ConnectedPosition, CdkOverlayOrigin, CdkConnectedOverlay } from '@angular/cdk/overlay'; import * as i1 from '@sbb-esta/angular/core'; import { SbbOption, SbbOptgroup, SbbErrorStateMatcher, SbbOptionSelectionChange, TypeRef } from '@sbb-esta/angular/core'; import * as i3 from '@sbb-esta/angular/icon'; import { ActiveDescendantKeyManager } from '@angular/cdk/a11y'; import { SelectionModel } from '@angular/cdk/collections'; import { ControlValueAccessor, NgControl } from '@angular/forms'; import { SbbFormFieldControl } from '@sbb-esta/angular/form-field'; import { Subject, Observable } from 'rxjs'; import { AnimationTriggerMetadata } from '@angular/animations'; /** * The following style constants are necessary to save here in order * to properly calculate the alignment of the selected option over * the trigger element. */ /** Injection token that determines the scroll handling while a select is open. */ declare const SBB_SELECT_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>; /** * @docs-private * @deprecated Will be removed in 22.0.0. * @breaking-change 22.0.0 */ declare function SBB_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => RepositionScrollStrategy; /** Object that can be used to configure the default options for the select module. */ interface SbbSelectConfig { /** Time to wait in milliseconds after the last keystroke before moving focus to an item. */ typeaheadDebounceInterval?: number; /** Class or list of classes to be applied to the menu's overlay panel. */ overlayPanelClass?: string | string[]; /** * Whether nullable options can be selected by default. * See `MatSelect.canSelectNullableOptions` for more information. */ canSelectNullableOptions?: boolean; } /** Injection token that can be used to provide the default options the select module. */ declare const SBB_SELECT_CONFIG: InjectionToken; /** * @docs-private * @deprecated Will be removed in 22.0.0. * @breaking-change 22.0.0 */ declare const SBB_SELECT_SCROLL_STRATEGY_PROVIDER: { provide: InjectionToken<() => ScrollStrategy>; deps: (typeof Overlay)[]; useFactory: typeof SBB_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY; }; /** Change event object that is emitted when the select value has changed. */ declare class SbbSelectChange { /** Reference to the select that emitted the change event. */ source: SbbSelect; /** Current value of the select that emitted the event. */ value: T; constructor( /** Reference to the select that emitted the change event. */ source: SbbSelect, /** Current value of the select that emitted the event. */ value: T); } declare const _SbbSelectMixinBase: i1.AbstractConstructor & { new (_elementRef: ElementRef): { _elementRef: ElementRef; }; }; declare class SbbSelect extends _SbbSelectMixinBase implements AfterContentInit, OnChanges, OnDestroy, OnInit, DoCheck, ControlValueAccessor, SbbFormFieldControl { private _viewportRuler; private _changeDetectorRef; private _parentFormField; ngControl: NgControl; private _liveAnnouncer; private _defaultOptions; private _initialized; /** The scroll position of the overlay panel, calculated to center the selected option. */ private _scrollTop; /** The last measured value for the trigger's client bounding rect. */ private _triggerRect; /** The cached font-size of the trigger element. */ _triggerFontSize: number; /** The value of the select panel's transform-origin property. */ _transformOrigin: string; /** * The y-offset of the overlay panel in relation to the trigger's top start corner. * This must be adjusted to align the selected option text over the trigger text. * when the panel opens. Will change based on the y-position of the selected option. */ _offsetY: number; /** All of the defined select options. */ options: QueryList; /** All of the defined groups of options. */ optionGroups: QueryList; /** * This position config ensures that the top "start" corner of the overlay * is aligned with with the top "start" of the origin by default (overlapping * the trigger completely). If the panel cannot fit below the trigger, it * will fall back to a position above the trigger. */ _positions: ConnectedPosition[]; _overlayOrigin: CdkOverlayOrigin; /** Factory function used to create a scroll strategy for this select. */ private _scrollStrategyFactory; /** Whether or not the overlay panel is open. */ private _panelOpen; /** Comparison function to specify which option is displayed. Defaults to object equality. */ private _compareWith; /** Unique id for this input. */ private _uid; /** Current `aria-labelledby` value for the select trigger. */ private _triggerAriaLabelledBy; /** * Keeps track of the previous form control assigned to the select. * Used to detect if it has changed. */ private _previousControl; /** Emits whenever the component is destroyed. */ private readonly _destroy; /** Tracks the error state of the select. */ private _errorStateTracker; /** * Emits whenever the component state changes and should cause the parent * form-field to update. Implemented as part of `SbbFormFieldControl`. * @docs-private */ readonly stateChanges: Subject; /** * Disable the automatic labeling to avoid issues like #1918. * @docs-private */ readonly disableAutomaticLabeling = true; /** * Implemented as part of MatFormFieldControl. * @docs-private */ userAriaDescribedBy: string; /** Deals with the selection logic. */ _selectionModel: SelectionModel; /** Manages keyboard events for options in the panel. */ _keyManager: ActiveDescendantKeyManager; /** `View -> model callback called when value changes` */ _onChange: (value: any) => void; /** `View -> model callback called when select has been touched` */ _onTouched: () => void; /** ID for the DOM node containing the select's value. */ _valueId: string; /** Emits when the panel element is finished transforming in. */ readonly _panelDoneAnimatingStream: Subject; /** Strategy that will be used to handle scrolling while the select panel is open. */ _scrollStrategy: ScrollStrategy; _overlayPanelClass: string | string[]; /** Whether the select is focused. */ get focused(): boolean; private _focused; /** A name for this control that can be used by `sbb-form-field`. */ controlType: string; /** Panel containing the select options. */ panel: ElementRef; /** Overlay pane containing the options. */ overlayDir: CdkConnectedOverlay; /** Classes to be passed to the select panel. Supports the same syntax as `ngClass`. */ panelClass: string | string[] | Set | { [key: string]: any; }; /** Whether the select is disabled. */ disabled: boolean; /** Placeholder to be shown if no value has been selected. */ /** Tab index of the select. */ tabIndex: number; get placeholder(): string; set placeholder(value: string); private _placeholder; /** Whether the component is required. */ get required(): boolean; set required(value: boolean); private _required; /** Whether the user should be allowed to select multiple options. */ get multiple(): boolean; set multiple(value: boolean); private _multiple; /** Whether the element is readonly. */ get readonly(): boolean; set readonly(value: boolean); private _readonly; /** * Function to compare the option values with the selected values. The first argument * is a value from an option. The second is a value from the selection. A boolean * should be returned. */ get compareWith(): (o1: any, o2: any) => boolean; set compareWith(fn: (o1: any, o2: any) => boolean); /** Value of the select control. */ get value(): any; set value(newValue: any); private _value; /** Aria label of the select. If not specified, the placeholder will be used as label. */ ariaLabel: string; /** Input that can be used to specify the `aria-labelledby` attribute. */ ariaLabelledby: string; /** Object used to control when error messages are shown. */ get errorStateMatcher(): SbbErrorStateMatcher; set errorStateMatcher(value: SbbErrorStateMatcher); /** Time to wait in milliseconds after the last keystroke before moving focus to an item. */ typeaheadDebounceInterval: number; /** * Function used to sort the values in a select in multiple mode. * Follows the same logic as `Array.prototype.sort`. */ sortComparator: (a: SbbOption, b: SbbOption, options: SbbOption[]) => number; /** Unique id of the element. */ get id(): string; set id(value: string); private _id; /** Whether the select is in an error state. */ get errorState(): boolean; set errorState(value: boolean); /** * By default selecting an option with a `null` or `undefined` value will reset the select's * value. Enable this option if the reset behavior doesn't match your requirements and instead * the nullable options should become selected. The value of this input can be controlled app-wide * using the `MAT_SELECT_CONFIG` injection token. */ canSelectNullableOptions: boolean; /** Combined stream of all of the child options' change events. */ readonly optionSelectionChanges: Observable; /** Event emitted when the select panel has been toggled. */ readonly openedChange: EventEmitter; /** Event emitted when the select has been opened. */ readonly _openedStream: Observable; /** Event emitted when the select has been closed. */ readonly _closedStream: Observable; /** Event emitted when the selected value has been changed by the user. */ readonly selectionChange: EventEmitter; /** * Event that emits whenever the raw value of the select changes. This is here primarily * to facilitate the two-way binding for the `value` input. * @docs-private */ readonly valueChange: EventEmitter; constructor(...args: unknown[]); ngOnInit(): void; ngAfterContentInit(): void; ngDoCheck(): void; ngOnChanges(changes: SimpleChanges): void; ngOnDestroy(): void; /** Toggles the overlay panel open or closed. */ toggle(): void; /** Opens the overlay panel. */ open(): void; /** * Track which modal we have modified the `aria-owns` attribute of. When the combobox trigger is * inside an aria-modal, we apply aria-owns to the parent modal with the `id` of the options * panel. Track the modal we have changed so we can undo the changes on destroy. */ private _trackedModal; /** * If the select trigger is inside of an `aria-modal` element, connect * that modal to the options panel with `aria-owns`. * * For some browser + screen reader combinations, when navigation is inside * of an `aria-modal` element, the screen reader treats everything outside * of that modal as hidden or invisible. * * This causes a problem when the combobox trigger is _inside_ of a modal, because the * options panel is rendered _outside_ of that modal, preventing screen reader navigation * from reaching the panel. * * We can work around this issue by applying `aria-owns` to the modal with the `id` of * the options panel. This effectively communicates to assistive technology that the * options panel is part of the same interaction as the modal. * * At time of this writing, this issue is present in VoiceOver. * See https://github.com/angular/components/issues/20694 */ private _applyModalPanelOwnership; /** Clears the reference to the listbox overlay element from the modal it was added to. */ private _clearFromModal; /** Closes the overlay panel and focuses the host element. */ close(): void; /** * Sets the select's value. Part of the ControlValueAccessor interface * required to integrate with Angular's core forms API. * * @param value New value to be written to the model. */ writeValue(value: any): void; /** * Saves a callback function to be invoked when the select's value * changes from user input. Part of the ControlValueAccessor interface * required to integrate with Angular's core forms API. * * @param fn Callback to be triggered when the value changes. */ registerOnChange(fn: (value: any) => void): void; /** * Saves a callback function to be invoked when the select is blurred * by the user. Part of the ControlValueAccessor interface required * to integrate with Angular's core forms API. * * @param fn Callback to be triggered when the component has been touched. */ registerOnTouched(fn: () => {}): void; /** * Disables the select. Part of the ControlValueAccessor interface required * to integrate with Angular's core forms API. * * @param isDisabled Sets whether the component is disabled. */ setDisabledState(isDisabled: boolean): void; /** Whether or not the overlay panel is open. */ get panelOpen(): boolean; /** The currently selected option. */ get selected(): SbbOption | SbbOption[]; /** The value displayed in the trigger. */ get triggerValue(): string; /** Refreshes the error state of the select. */ updateErrorState(): void; /** Handles all keydown events on the select. */ _handleKeydown(event: TypeRef): void; /** Handles keyboard events while the select is closed. */ private _handleClosedKeydown; /** Handles keyboard events when the selected is open. */ private _handleOpenKeydown; _onFocus(): void; /** * Calls the touched callback only if the panel is closed. Otherwise, the trigger will * "blur" to the panel when it opens, causing a false positive. */ _onBlur(): void; /** Callback that is invoked when the overlay panel has been attached. */ _onAttached(): void; /** Whether the select has a value. */ get empty(): boolean; private _initializeSelection; /** * Sets the selected option based on a value. If no option can be * found with the designated value, the select trigger is cleared. */ private _setSelectionByValue; /** * Finds and selects and option based on its value. * @returns Option that has the corresponding value. */ private _selectOptionByValue; /** Assigns a specific value to the select. Returns whether the value has changed. */ private _assignValue; /** Sets up a key manager to listen to keyboard events on the overlay panel. */ private _initKeyManager; /** Drops current option subscriptions and IDs and resets from scratch. */ private _resetOptions; /** Invoked when an option is clicked. */ private _onSelect; /** Sorts the selected values in the selected based on their order in the panel. */ private _sortValues; /** Emits change event to set the model value. */ private _propagateChanges; /** * Highlights the selected item. If no option is selected, it will highlight * the first item instead. */ private _highlightCorrectOption; /** Whether the panel is allowed to open. */ private _canOpen; /** Focuses the select element. */ focus(options?: FocusOptions): void; /** Gets the aria-labelledby for the select panel. */ _getPanelAriaLabelledby(): string | null; /** Determines the `aria-activedescendant` to be set on the host. */ _getAriaActiveDescendant(): string | null; /** Gets the aria-labelledby of the select component trigger. */ private _getTriggerAriaLabelledby; /** Called when the overlay panel is done animating. */ _panelDoneAnimating(isOpen: boolean): void; protected _getOverlayMinWidth(): number; /** * Implemented as part of SbbFormFieldControl. * @docs-private */ setDescribedByIds(ids: string[]): void; /** * Forward focus if a user clicks on an associated label. * Implemented as part of SbbFormFieldControl. * @docs-private */ onContainerClick(): void; /** * Calculates the scroll position of the select's overlay panel. * * Attempts to center the selected option in the panel. If the option is * too high or too low in the panel to be scrolled to the center, it clamps the * scroll position to the min or max scroll positions respectively. */ _calculateOverlayScroll(selectedOption: SbbOption, scrollBuffer: number, maxScroll: number): number; /** Scrolls the active option into view. */ private _scrollOptionIntoView; private _positioningSettled; /** Calculates the scroll position */ private _calculateOverlayPosition; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; static ngAcceptInputType_disabled: unknown; static ngAcceptInputType_tabIndex: unknown; static ngAcceptInputType_required: unknown; static ngAcceptInputType_multiple: unknown; static ngAcceptInputType_readonly: unknown; static ngAcceptInputType_typeaheadDebounceInterval: unknown; static ngAcceptInputType_canSelectNullableOptions: unknown; } declare class SbbSelectModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } /** * The following are all the animations for the sbb-select component, with each * const containing the metadata for one animation. * * @docs-private */ declare const sbbSelectAnimations: { readonly transformPanel: AnimationTriggerMetadata; }; /** * Returns an exception to be thrown when attempting to change a select's `multiple` option * after initialization. * @docs-private */ declare function getSbbSelectDynamicMultipleError(): Error; /** * Returns an exception to be thrown when attempting to assign a non-array value to a select * in `multiple` mode. Note that `undefined` and `null` are still valid values to allow for * resetting the value. * @docs-private */ declare function getSbbSelectNonArrayValueError(): Error; /** * Returns an exception to be thrown when assigning a non-function value to the comparator * used to determine if a value corresponds to an option. Note that whether the function * actually takes two values and returns a boolean is not checked. * @docs-private */ declare function getSbbSelectNonFunctionValueError(): Error; export { SBB_SELECT_CONFIG, SBB_SELECT_SCROLL_STRATEGY, SBB_SELECT_SCROLL_STRATEGY_PROVIDER, SBB_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY, SbbSelect, SbbSelectChange, SbbSelectModule, getSbbSelectDynamicMultipleError, getSbbSelectNonArrayValueError, getSbbSelectNonFunctionValueError, sbbSelectAnimations }; export type { SbbSelectConfig };