UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

56 lines 2.15 kB
export default TinyHtmlRadioInput; /** * TinyHtmlRadioInput is a helper class for managing `<input type="radio">` elements. * It provides strict validation for attributes like `name`, `value`, `checked`, `readonly`, * and `required`, with convenient getters and setters. * * @example * const radio = new TinyHtmlRadioInput({ * name: 'gender', * value: 'female', * checked: true, * required: true * }); * * // Check state * radio.checked = false; * console.log(radio.checked); // false */ declare class TinyHtmlRadioInput extends TinyHtmlInput { /** * Creates a new TinyHtmlRadioInput instance. * @param {Object} config - Configuration object. * @param {string} config.name - Radio group name (required). * @param {string|number} [config.value] - Value for this radio option. * @param {boolean} [config.checked=false] - Whether this radio is selected. * @param {boolean} [config.readonly=false] - Whether the input is readonly. * @param {boolean} [config.required=false] - Whether the input is required. * @param {string|string[]|Set<string>} [config.tags=[]] - Initial CSS classes. * @param {string} [config.mainClass=''] - Main CSS class. * @throws {TypeError} If an attribute is of the wrong type. */ constructor({ name, value, checked, readonly, required, tags, mainClass, }: { name: string; value?: string | number | undefined; checked?: boolean | undefined; readonly?: boolean | undefined; required?: boolean | undefined; tags?: string | string[] | Set<string> | undefined; mainClass?: string | undefined; }); /** @param {string|number} value */ set value(value: string | number); /** @returns {string|null} */ get value(): string | null; /** @param {boolean} checked */ set checked(checked: boolean); /** @returns {boolean} */ get checked(): boolean; /** * Toggles the checked state of the radio. * @returns {this} */ toggle(): this; } import TinyHtmlInput from '../../TinyHtmlInput.mjs'; //# sourceMappingURL=TinyHtmlRadioInput.d.mts.map