import * as i2 from '@angular/common'; import { CommonModule } from '@angular/common'; import * as i0 from '@angular/core'; import { forwardRef, EventEmitter, booleanAttribute, numberAttribute, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ContentChildren, NgModule } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import * as i1 from 'primeng/api'; import { PrimeTemplate, SharedModule } from 'primeng/api'; import { CheckIcon } from 'primeng/icons/check'; import { TimesIcon } from 'primeng/icons/times'; import * as i3 from 'primeng/autofocus'; import { AutoFocusModule } from 'primeng/autofocus'; const TRISTATECHECKBOX_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => TriStateCheckbox), multi: true }; /** * TriStateCheckbox is used to select either 'true', 'false' or 'null' as the value. * @group Components */ class TriStateCheckbox { cd; config; constructor(cd, config) { this.cd = cd; this.config = config; } /** * When present, it specifies that the element should be disabled. * @group Props */ disabled; /** * Name of the component. * @group Props */ name; /** * Defines a string that labels the input for accessibility. * @group Props */ ariaLabel; /** * Establishes relationships between the component and label(s) where its value should be one or more element IDs. * @group Props */ ariaLabelledBy; /** * Specifies the input variant of the component. * @group Props */ variant = 'outlined'; /** * Index of the element in tabbing order. * @group Props */ tabindex; /** * Identifier of the focus input to match a label defined for the component. * @group Props */ inputId; /** * Inline style of the component. * @group Props */ style; /** * Style class of the component. * @group Props */ styleClass; /** * Label of the checkbox. * @group Props */ label; /** * When present, it specifies that the component cannot be edited. * @group Props */ readonly; /** * Specifies the icon for checkbox true value. * @group Props */ checkboxTrueIcon; /** * Specifies the icon for checkbox false value. * @group Props */ checkboxFalseIcon; /** * When present, it specifies that the component should automatically get focus on load. * @group Props */ autofocus; /** * Callback to invoke on value change. * @param {TriStateCheckboxChangeEvent} event - Custom change event. * @group Emits */ onChange = new EventEmitter(); templates; checkIconTemplate; uncheckIconTemplate; focused; value; onModelChange = () => { }; onModelTouched = () => { }; onClick(event, input) { if (!this.disabled && !this.readonly) { this.toggle(event); this.focused = true; input.focus(); } } onKeyDown(event) { if (event.key === 'Enter') { this.toggle(event); event.preventDefault(); } } toggle(event) { if (this.value == null || this.value == undefined) this.value = true; else if (this.value == true) this.value = false; else if (this.value == false) this.value = null; this.onModelChange(this.value); this.onChange.emit({ originalEvent: event, value: this.value }); } ngAfterContentInit() { this.templates.forEach((item) => { switch (item.getType()) { case 'checkicon': this.checkIconTemplate = item.template; break; case 'uncheckicon': this.uncheckIconTemplate = item.template; break; } }); } onFocus() { this.focused = true; } onBlur() { this.focused = false; this.onModelTouched(); } registerOnChange(fn) { this.onModelChange = fn; } registerOnTouched(fn) { this.onModelTouched = fn; } writeValue(value) { this.value = value; this.cd.markForCheck(); } setDisabledState(disabled) { this.disabled = disabled; this.cd.markForCheck(); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TriStateCheckbox, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.PrimeNGConfig }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: TriStateCheckbox, selector: "p-triStateCheckbox", inputs: { disabled: ["disabled", "disabled", booleanAttribute], name: "name", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy", variant: "variant", tabindex: ["tabindex", "tabindex", numberAttribute], inputId: "inputId", style: "style", styleClass: "styleClass", label: "label", readonly: ["readonly", "readonly", booleanAttribute], checkboxTrueIcon: "checkboxTrueIcon", checkboxFalseIcon: "checkboxFalseIcon", autofocus: ["autofocus", "autofocus", booleanAttribute] }, outputs: { onChange: "onChange" }, host: { classAttribute: "p-element" }, providers: [TRISTATECHECKBOX_VALUE_ACCESSOR], queries: [{ propertyName: "templates", predicate: PrimeTemplate }], ngImport: i0, template: `