obsidian-dev-utils
Version:
This is the collection of useful functions that you can use for your Obsidian plugin development
70 lines (69 loc) • 2.29 kB
text/typescript
/**
* @packageDocumentation
*
* Tri-state checkbox component.
*/
import type { Promisable } from 'type-fest';
import { ValueComponent } from 'obsidian';
import type { ValidatorElement } from '../../../HTMLElement.mjs';
import type { ValidatorComponent } from './ValidatorComponent.mjs';
import type { ValueComponentWithChangeTracking } from './ValueComponentWithChangeTracking.mjs';
/**
* A component that displays a tri-state checkbox.
*
* You can add this component using {@link SettingEx.addTriStateCheckbox}.
*
* In order to add the styles for the component, use {@link initPluginContext} in your plugin's `onload()` function.
*
* Alternatively, you can copy styles from {@link https://github.com/mnaoumov/obsidian-dev-utils/releases/latest/download/styles.css}.
*/
export declare class TriStateCheckboxComponent extends ValueComponent<boolean | null> implements ValidatorComponent, ValueComponentWithChangeTracking<boolean | null> {
/**
* The input element of the checkbox.
*/
readonly inputEl: HTMLInputElement;
/**
* The validator element of the checkbox.
*
* @returns The validator element.
*/
get validatorEl(): ValidatorElement;
private changeCallback?;
/**
* Creates a new tri-state checkbox component.
*
* @param containerEl - The container element.
*/
constructor(containerEl: HTMLElement);
/**
* Gets the value of the checkbox.
*
* @returns The value of the checkbox.
*/
getValue(): boolean | null;
/**
* Sets the callback to be called when the checkbox is changed.
*
* @param callback - The callback to be called when the checkbox is changed.
* @returns The component.
*/
onChange(callback: (newValue: boolean | null) => Promisable<void>): this;
/**
* Called when the checkbox is changed.
*/
onChanged(): void;
/**
* Sets the disabled state of the checkbox.
*
* @param disabled - The disabled state of the checkbox.
* @returns The component.
*/
setDisabled(disabled: boolean): this;
/**
* Sets the value of the checkbox.
*
* @param value - The value to set the checkbox to.
* @returns The component.
*/
setValue(value: boolean | null): this;
}