/** * @license * Copyright 2023 Nuraly, Laabidi Aymen * SPDX-License-Identifier: MIT */ import { RadioButtonOption } from '../radio-group.types.js'; import { SelectionController, RadioHost } from '../interfaces/index.js'; /** * Controller that manages radio group state and selection logic * Implements type-safe selection operations with proper error handling * * @example * ```typescript * const controller = new RadioGroupController(hostElement); * controller.selectOption(option); // Type-safe selection * ``` */ export declare class RadioGroupController implements SelectionController { readonly host: RadioHost; constructor(host: RadioHost & { dispatchEvent: (event: Event) => void; }); /** * Called when the host element is connected to the DOM * Initializes the default selection if provided * * @fires change - When default value is set automatically */ hostConnected(): void; /** * Called when the host element is disconnected from the DOM * Performs cleanup operations */ hostDisconnected(): void; /** * Selects a radio option and dispatches change events * Implements proper error handling for disabled options * * @param option - The radio option to select * @throws {Error} When option is disabled or invalid * @fires change - When selection changes successfully * * @example * ```typescript * controller.selectOption({ value: 'option1', label: 'Option 1' }); * ``` */ selectOption(option: RadioButtonOption): void; /** * Gets the currently selected radio option * * @returns The selected option object or undefined if none selected * * @example * ```typescript * const selected = controller.getSelectedOption(); * console.log(selected?.label); // "Option 1" * ``` */ getSelectedOption(): RadioButtonOption | undefined; /** * Checks if a specific option is currently selected * * @param option - The option to check * @returns True if the option is selected, false otherwise * * @example * ```typescript * const isSelected = controller.isOptionSelected(option); * ``` */ isOptionSelected(option: RadioButtonOption): boolean; /** * Checks if a specific option is disabled * Takes into account both global disabled state and option-specific disabled state * * @param option - The option to check * @returns True if the option is disabled, false otherwise * * @example * ```typescript * if (!controller.isOptionDisabled(option)) { * controller.selectOption(option); * } * ``` */ isOptionDisabled(option: RadioButtonOption): boolean; /** * Gets form data for native form submission * Returns key-value pair suitable for FormData * * @returns Object with form field name and selected value * * @example * ```typescript * const formData = controller.getFormData(); * // { "radioGroup": "selectedValue" } * ``` */ getFormData(): { [key: string]: string; }; /** * Resets the radio group to its default value * Triggers re-render to update the UI * * @fires change - When reset changes the selected value * * @example * ```typescript * controller.reset(); // Resets to defaultValue or empty * ``` */ reset(): void; /** * Gets the currently selected value as a string * Convenience method for accessing the raw value * * @returns The selected value string, empty string if none selected * * @example * ```typescript * const value = controller.getSelectedValue(); * console.log(value); // "option1" * ``` */ getSelectedValue(): string; /** * Dispatches a change event when selection changes * Creates a custom event with detailed information about the change * * @param option - The newly selected option * @param oldValue - The previously selected value * @fires change - Custom event with selection details * * @private */ private dispatchChangeEvent; } //# sourceMappingURL=group.controller.d.ts.map