import * as rxjs from 'rxjs'; import { Highlightable } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import { ChangeDetectorRef, ElementRef } from '@angular/core'; /** * `OptionControl` is an abstract directive that serves as a base class for implementing selectable options in a dropdown * list or a similar component. It integrates with CDK's `Highlightable` interface to provide keyboard navigation support. * * @param {T} - The type of the value. * * This base class handles the visual feedback for active and selected states and provides a structure for defining * how an option is selected. * * Extend `OptionControl` to create a concrete option component: * @example * ```ts * @Component({ * selector: 'my-option', * templateUrl: './my-option.component.html', * providers: [{ provide: OptionControl, useExisting: forwardRef(() => MyOptionComponent) }], * }) * class MyOptionComponent extends OptionControl { * @Input() override value: MyDataType | null = null; * * protected override selectOption(): void { * // Custom logic for when this option is selected * } * } * ``` * * Implement `selectOption` in subclasses to define what happens when an option is selected, such as updating a model * or closing a dropdown. */ declare abstract class OptionControl implements Highlightable { protected readonly takeUntilDestroyed: () => rxjs.MonoTypeOperatorFunction; protected readonly cdr: ChangeDetectorRef; protected isActive: boolean; isSelected: boolean; /** * Represents the value of the option control. * * @type {T} - The type of the value. */ value: T | null; readonly element: ElementRef; /** * Sets the active styles for the option control. * * @returns {void} */ abstract setActiveStyles(): void; /** * Sets the inactive styles for the option control. * * @returns {void} */ setInactiveStyles(): void; /** * Retrieves the label of the option control. * * @returns {string} - The label of the option control. */ getLabel(): string; protected abstract selectOption(): void; protected select(event: Event): void; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵdir: i0.ɵɵDirectiveDeclaration, never, never, { "value": { "alias": "value"; "required": false; }; }, {}, never, never, true, never>; } export { OptionControl };