@alyle/ui
Version:
Minimal Design, a set of components for Angular
170 lines (169 loc) • 7.33 kB
TypeScript
import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnDestroy, OnInit, Renderer2 } from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
import { LyCoreStyles as LyCommonStyles, LyFocusState, LyTheme2, ThemeVariables, ThemeRef, StyleRenderer, StyleCollection, LyClasses, StyleTemplate, WithStyles } from '@alyle/ui';
import { Color } from '@alyle/ui/color';
import { Platform } from '@angular/cdk/platform';
import { BooleanInput } from '@angular/cdk/coercion';
import { LyCheckboxDefaultOptions } from './checkbox-config';
import * as i0 from "@angular/core";
/**
* Represents the different states that require custom transitions between them.
* @docs-private
*/
export declare const enum CheckboxState {
/** The initial state of the component before any user interaction. */
Init = "Init",
/** The state representing the component when it's becoming checked. */
Checked = "Checked",
/** The state representing the component when it's becoming unchecked. */
Unchecked = "Unchecked",
/** The state representing the component when it's becoming indeterminate. */
Indeterminate = "Indeterminate"
}
export interface LyCheckboxTheme {
/** Styles for Checkbox Component. */
root?: StyleCollection<((classes: LyClasses<typeof STYLES>) => StyleTemplate)> | ((classes: LyClasses<typeof STYLES>) => StyleTemplate);
/** Styles that apply when a color is set. */
color?: (classes: LyClasses<typeof STYLES>, color: Color) => StyleTemplate;
}
export interface LyCheckboxVariables {
checkbox?: LyCheckboxTheme;
}
export declare const STYLES: (theme: ThemeVariables & LyCheckboxVariables, ref: ThemeRef) => {
$name: string;
$priority: number;
root: () => (_className: string) => string;
layout: () => (_className: string) => string;
icon: (_className: string) => string;
label: (_className: string) => string;
unchecked: any;
checked: any;
indeterminate: any;
input: (_className: string) => string;
onFocusByKeyboard: any;
disabled: () => (_className: string) => string;
animations: () => (_className: string) => string;
indeterminateToUnchecked: any;
indeterminateToChecked: any;
checkedToUnChecked: any;
checkedToIndeterminate: any;
uncheckedToChecked: any;
uncheckedToIndeterminate: any;
};
/**
* This allows it to support [(ngModel)].
* @ignore
*/
export declare const LY_CHECKBOX_CONTROL_VALUE_ACCESSOR: any;
/** Change event object emitted by LyCheckbox. */
export declare class LyCheckboxChange {
/** The source LyCheckbox of the event. */
source: LyCheckbox;
/** The new `checked` value of the checkbox. */
checked: boolean;
}
/** @docs-private */
export declare class LyCheckboxBase {
_theme: LyTheme2;
_ngZone: NgZone;
_platform: Platform;
constructor(_theme: LyTheme2, _ngZone: NgZone, _platform: Platform);
}
/** @docs-private */
export declare const LyCheckboxMixinBase: import("@alyle/ui/src/common/constructor").Constructor<import("@alyle/ui/src/common/disable-ripple").CanDisableRipple> & typeof LyCheckboxBase;
/**
* @dynamic
*/
export declare class LyCheckbox extends LyCheckboxMixinBase implements WithStyles, ControlValueAccessor, OnInit, AfterViewInit, OnDestroy {
_commonStyles: LyCommonStyles;
private _el;
private _renderer;
private _changeDetectorRef;
private _focusState;
readonly sRenderer: StyleRenderer;
private _options?;
/** @ignore */
static readonly и = "LyCheckbox";
/**
* styles
* @ignore
*/
readonly classes: LyClasses<(theme: ThemeVariables & LyCheckboxVariables, ref: ThemeRef) => {
$name: string;
$priority: number;
root: () => (_className: string) => string;
layout: () => (_className: string) => string;
icon: (_className: string) => string;
label: (_className: string) => string;
unchecked: any;
checked: any;
indeterminate: any;
input: (_className: string) => string;
onFocusByKeyboard: any;
disabled: () => (_className: string) => string;
animations: () => (_className: string) => string;
indeterminateToUnchecked: any;
indeterminateToChecked: any;
checkedToUnChecked: any;
checkedToIndeterminate: any;
uncheckedToChecked: any;
uncheckedToIndeterminate: any;
}>;
protected _color: string;
protected _colorClass: string;
protected _checked: boolean;
protected _disabled: any;
private _onFocusByKeyboardState;
private _currentCheckState;
private _currentCheckStateClass;
readonly: any;
_innerContainer: ElementRef<HTMLDivElement>;
/** The value attribute of the native input element */
value: string;
name: string | null;
/** Checkbox color when checked */
color: string | null;
/**
* Whether the checkbox is checked.
*/
get checked(): boolean;
set checked(val: BooleanInput);
get indeterminate(): boolean;
set indeterminate(value: BooleanInput);
private _indeterminate;
get required(): BooleanInput;
set required(val: BooleanInput);
private _required;
get disabled(): BooleanInput;
set disabled(val: BooleanInput);
/** Event emitted when the checkbox's `checked` value changes. */
readonly change: EventEmitter<LyCheckboxChange>;
/** Event emitted when the checkbox's `indeterminate` value changes. */
readonly indeterminateChange: EventEmitter<boolean>;
/** The native `<input type="checkbox">` element */
_inputElement: ElementRef<HTMLInputElement>;
_onTouched: () => any;
private _controlValueAccessorChangeFn;
constructor(_commonStyles: LyCommonStyles, _theme: LyTheme2, _el: ElementRef, _renderer: Renderer2, _changeDetectorRef: ChangeDetectorRef, _focusState: LyFocusState, sRenderer: StyleRenderer, ngZone: NgZone, platform: Platform, _options?: LyCheckboxDefaultOptions);
ngOnInit(): void;
ngAfterViewInit(): void;
ngOnDestroy(): void;
/** @docs-private */
writeValue(value: any): void;
/** @docs-private */
registerOnChange(fn: (value: any) => void): void;
/** @docs-private */
registerOnTouched(fn: any): void;
/** @docs-private */
setDisabledState(isDisabled: boolean): void;
/** Toggles the `checked` state of the checkbox. */
toggle(): void;
_onInputClick(event: Event): void;
_onChange(event: Event): void;
private _emitChangeEvent;
private _updateCheckedState;
private _updateCheckboxState;
private _markForCheck;
static ɵfac: i0.ɵɵFactoryDeclaration<LyCheckbox, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<LyCheckbox, "ly-checkbox", ["lyCheckbox"], { "disableRipple": { "alias": "disableRipple"; "required": false; }; "value": { "alias": "value"; "required": false; }; "name": { "alias": "name"; "required": false; }; "color": { "alias": "color"; "required": false; }; "checked": { "alias": "checked"; "required": false; }; "indeterminate": { "alias": "indeterminate"; "required": false; }; "required": { "alias": "required"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "change": "change"; "indeterminateChange": "indeterminateChange"; }, never, ["*"], false, never>;
}