UNPKG

@ng-matero/extensions

Version:
118 lines (113 loc) 5.3 kB
import * as i0 from '@angular/core'; import { AfterViewInit, OnDestroy, QueryList, TrackByFunction, EventEmitter } from '@angular/core'; import * as i1 from '@angular/common'; import * as i2 from '@angular/forms'; import { ControlValueAccessor } from '@angular/forms'; import * as i3 from '@angular/material/checkbox'; import { MatCheckbox, MatCheckboxChange } from '@angular/material/checkbox'; import * as i4 from '@ng-matero/extensions/core'; interface MtxCheckboxGroupOption { ariaDescribedby?: string; ariaLabel?: string; ariaLabelledby?: string; label?: any; value?: any; color?: string; checked?: boolean; disabled?: boolean; disableRipple?: boolean; indeterminate?: boolean; labelPosition?: 'before' | 'after'; id?: string; name?: string | null; required?: boolean; [k: string]: any; } declare class MtxCheckboxBase { label?: any | undefined; value?: any | undefined; constructor(label?: any | undefined, value?: any | undefined); } declare class MtxCheckboxGroup implements AfterViewInit, OnDestroy, ControlValueAccessor { private _changeDetectorRef; private _focusMonitor; private _elementRef; _checkboxes: QueryList<MatCheckbox>; /** * Tracking function that will be used to check the differences in data changes. Used similarly * to `ngFor` `trackBy` function. Optimize row operations by identifying a row based on its data * relative to the function to know if a row should be added/removed/moved. * Accepts a function that takes two parameters, `index` and `item`. */ get trackBy(): TrackByFunction<any> | undefined; set trackBy(fn: TrackByFunction<any> | undefined); private _trackByFn?; get items(): any[]; set items(value: any[]); private _items; private _originalItems; bindLabel: string; bindValue: string; showSelectAll: boolean; selectAllLabel: string; get compareWith(): ((o1: any, o2: any) => boolean) | undefined; set compareWith(fn: ((o1: any, o2: any) => boolean) | undefined); private _compareWith?; disabled: boolean; change: EventEmitter<{ model: MtxCheckboxGroupOption[]; index: number; }>; selectAll: boolean; selectAllIndeterminate: boolean; selectedItems: MtxCheckboxGroupOption[]; _onChange: (value: MtxCheckboxGroupOption[]) => void; _onTouched: () => void; ngAfterViewInit(): void; ngOnDestroy(): void; /** * Finds and selects and option based on its value. * @returns Option that has the corresponding value. */ private _selectValue; /** * Sets the model value. Implemented as part of ControlValueAccessor. * @param value New value to be written to the model. */ writeValue(value: any[]): void; /** * Registers a callback to be triggered when the model value changes. * Implemented as part of ControlValueAccessor. * @param fn Callback to be registered. */ registerOnChange(fn: (value: MtxCheckboxGroupOption[]) => Record<string, unknown>): void; /** * Registers a callback to be triggered when the control is touched. * Implemented as part of ControlValueAccessor. * @param fn Callback to be registered. */ registerOnTouched(fn: () => Record<string, unknown>): void; /** * Sets the disabled state of the control. Implemented as a part of ControlValueAccessor. * @param isDisabled Whether the control should be disabled. */ setDisabledState(isDisabled: boolean): void; private _checkMasterCheckboxState; private _getSelectedItems; /** Handle normal checkbox toggle */ _updateNormalCheckboxState(e: MatCheckboxChange, index: number): void; /** Handle master checkbox toggle */ _updateMasterCheckboxState(e: MatCheckboxChange, index: number): void; _trackBy: (index: number, item: any) => any; static ɵfac: i0.ɵɵFactoryDeclaration<MtxCheckboxGroup, never>; static ɵcmp: i0.ɵɵComponentDeclaration<MtxCheckboxGroup, "mtx-checkbox-group", ["mtxCheckboxGroup"], { "trackBy": { "alias": "trackBy"; "required": false; }; "items": { "alias": "items"; "required": false; }; "bindLabel": { "alias": "bindLabel"; "required": false; }; "bindValue": { "alias": "bindValue"; "required": false; }; "showSelectAll": { "alias": "showSelectAll"; "required": false; }; "selectAllLabel": { "alias": "selectAllLabel"; "required": false; }; "compareWith": { "alias": "compareWith"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "change": "change"; }, ["_checkboxes"], never, true, never>; static ngAcceptInputType_showSelectAll: unknown; static ngAcceptInputType_disabled: unknown; } declare class MtxCheckboxGroupModule { static ɵfac: i0.ɵɵFactoryDeclaration<MtxCheckboxGroupModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<MtxCheckboxGroupModule, never, [typeof i1.CommonModule, typeof i2.FormsModule, typeof i3.MatCheckboxModule, typeof i4.MtxPipesModule, typeof MtxCheckboxGroup], [typeof MtxCheckboxGroup, typeof i4.MtxPipesModule]>; static ɵinj: i0.ɵɵInjectorDeclaration<MtxCheckboxGroupModule>; } export { MtxCheckboxBase, MtxCheckboxGroup, MtxCheckboxGroupModule }; export type { MtxCheckboxGroupOption };