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.
61 lines • 2.22 kB
text/typescript
export default TinyHtmlCheckboxInput;
/**
* TinyHtmlCheckboxInput is a helper class for managing <input type="checkbox"> elements.
* It allows configuring standard attributes such as name, value, checked, readonly, and required,
* with validation and getter/setter consistency.
*
* @example
* const checkbox = new TinyHtmlCheckboxInput({
* name: 'acceptTerms',
* checked: true,
* value: 'yes'
* });
*/
declare class TinyHtmlCheckboxInput extends TinyHtmlInput {
/**
* Creates a new TinyHtmlCheckboxInput instance.
* @param {Object} config - Configuration object.
* @param {boolean} [config.checked=false] - Whether the checkbox is checked.
* @param {string} config.name - Input name attribute.
* @param {string|number} [config.value] - Input value when checked.
* @param {boolean} [config.readonly=false] - Whether the checkbox is readonly.
* @param {boolean} [config.required=false] - Whether the checkbox 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({ checked, name, value, readonly, required, tags, mainClass, }: {
checked?: boolean | undefined;
name: string;
value?: string | number | undefined;
readonly?: boolean | undefined;
required?: boolean | undefined;
tags?: string | string[] | Set<string> | undefined;
mainClass?: string | undefined;
});
/** @param {boolean} checked */
set checked(checked: boolean);
/** @returns {boolean} */
get checked(): boolean;
/** @param {string|number} value */
set value(value: string | number);
/** @returns {string|null} */
get value(): string | null;
/**
* Checks the checkbox.
* @returns {this}
*/
check(): this;
/**
* Unchecks the checkbox.
* @returns {this}
*/
uncheck(): this;
/**
* Toggles the checkbox state.
* @returns {this}
*/
toggle(): this;
}
import TinyHtmlInput from '../../TinyHtmlInput.mjs';
//# sourceMappingURL=TinyHtmlCheckboxInput.d.mts.map