carbon-components-angular
Version:
Next generation components
199 lines (195 loc) • 6.4 kB
TypeScript
/**
*
* carbon-angular v0.0.0 | checkbox.component.d.ts
*
* Copyright 2014, 2025 IBM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter } from "@angular/core";
import { ControlValueAccessor } from "@angular/forms";
import { CheckboxValue } from "./checkbox.types";
import * as i0 from "@angular/core";
/**
* Defines the set of states for a checkbox component.
*/
export declare enum CheckboxState {
Init = 0,
Indeterminate = 1,
Checked = 2,
Unchecked = 3
}
/**
* Get started with importing the module:
*
* ```typescript
* import { CheckboxModule } from 'carbon-components-angular';
* ```
*
* [See demo](../../?path=/story/components-checkbox--basic)
*/
export declare class Checkbox implements ControlValueAccessor, AfterViewInit {
protected changeDetectorRef: ChangeDetectorRef;
/**
* Variable used for creating unique ids for checkbox components.
*/
static checkboxCount: number;
/**
* Set to `true` for a disabled checkbox.
*/
disabled: boolean;
/**
* Set to `true` for a loading checkbox.
*/
skeleton: boolean;
/**
* Set to `true` to hide the checkbox labels.
*/
hideLabel: boolean;
/**
* Sets the name attribute on the `input` element.
*/
name: string;
/**
* The unique id for the checkbox component.
*/
id: string;
/**
* Reflects the required attribute of the `input` element.
*/
required: boolean;
/**
* Sets the value attribute on the `input` element.
*/
value: CheckboxValue;
ariaLabel: string;
ariaLabelledby: string;
/**
* Set the checkbox's indeterminate state to match the parameter and transition the view to reflect the change.
*
* Allows double binding with the `indeterminateChange` Output.
*/
set indeterminate(indeterminate: boolean);
/**
* Reflects whether the checkbox state is indeterminate.
*/
get indeterminate(): boolean;
/**
* Sets the `checked` state. `true` for checked, `false` for unchecked
*
* Allows double binding with the `checkedChange` Output.
*/
set checked(checked: boolean);
/**
* Returns value `true` if state is selected for the checkbox.
*/
get checked(): boolean;
/**
* Emits click event.
*/
click: EventEmitter<void>;
/**
* Emits an event when the value of the checkbox changes.
*
* Allows double biding with the `checked` Input.
*/
checkedChange: EventEmitter<boolean>;
/**
* Emits event notifying other classes when a change in state occurs specifically
* on an indeterminate checkbox.
*/
indeterminateChange: EventEmitter<boolean>;
/**
* Set to `true` if the input checkbox is selected (or checked).
*/
_checked: boolean;
/**
* Set to `true` if the input checkbox is in state indeterminate.
*/
_indeterminate: boolean;
/**
* Keeps a reference to the checkboxes current state, as defined in `CheckboxState`.
*/
currentCheckboxState: CheckboxState;
/**
* Maintains a reference to the view DOM element of the `Checkbox`.
*/
inputCheckbox: ElementRef;
/**
* Creates an instance of `Checkbox`.
*/
constructor(changeDetectorRef: ChangeDetectorRef);
/**
* Toggle the selected state of the checkbox.
*/
toggle(): void;
/**
* Writes a value from `ngModel` to the component.
*
* In this case the value is the `checked` property.
*
* @param value boolean, corresponds to the `checked` property.
*/
writeValue(value: any): void;
/**
* Sets a method in order to propagate changes back to the form.
*/
registerOnChange(fn: any): void;
/**
* Registers a callback to be triggered when the control has been touched.
* @param fn Callback to be triggered when the checkbox is touched.
*/
registerOnTouched(fn: any): void;
/**
* `ControlValueAccessor` method to programmatically disable the checkbox.
*
* ex: `this.formGroup.get("myCheckbox").disable();`
*
* @param isDisabled `true` to disable the checkbox
*/
setDisabledState(isDisabled: boolean): void;
focusOut(): void;
/**
* Executes on the event of a change within `Checkbox` to block propagation.
*/
onChange(event: Event): void;
/**
* Handles click events on the `Checkbox` and emits changes to other classes.
*/
onClick(event: Event): void;
/**
* Called when checkbox is blurred. Needed to properly implement `ControlValueAccessor`.
*/
onTouched: () => any;
/**
* Handles changes between checkbox states.
*/
transitionCheckboxState(newState: CheckboxState): void;
/**
* Creates instance of `CheckboxChange` used to propagate the change event.
*/
emitChangeEvent(): void;
/**
* Updates the checkbox if it is in the indeterminate state.
*/
ngAfterViewInit(): void;
/**
* Method set in `registerOnChange` to propagate changes back to the form.
*/
propagateChange: (_: any) => void;
/**
* Sets checked state and optionally resets indeterminate state.
*/
private setChecked;
static ɵfac: i0.ɵɵFactoryDeclaration<Checkbox, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<Checkbox, "cds-checkbox, ibm-checkbox", never, { "disabled": "disabled"; "skeleton": "skeleton"; "hideLabel": "hideLabel"; "name": "name"; "id": "id"; "required": "required"; "value": "value"; "ariaLabel": "ariaLabel"; "ariaLabelledby": "ariaLabelledby"; "indeterminate": "indeterminate"; "checked": "checked"; }, { "click": "click"; "checkedChange": "checkedChange"; "indeterminateChange": "indeterminateChange"; }, never, ["*"], false>;
}