import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; import * as i0 from '@angular/core'; import { forwardRef, EventEmitter, numberAttribute, booleanAttribute, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ViewChild, NgModule } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import * as i2 from 'primeng/autofocus'; import { AutoFocusModule } from 'primeng/autofocus'; const INPUTSWITCH_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => InputSwitch), multi: true }; /** * InputSwitch is used to select a boolean value. * @group Components */ class InputSwitch { cd; /** * Inline style of the component. * @group Props */ style; /** * Style class of the component. * @group Props */ styleClass; /** * Index of the element in tabbing order. * @group Props */ tabindex; /** * Identifier of the input element. * @group Props */ inputId; /** * Name of the input element. * @group Props */ name; /** * When present, it specifies that the element should be disabled. * @group Props */ disabled; /** * When present, it specifies that the component cannot be edited. * @group Props */ readonly; /** * Value in checked state. * @group Props */ trueValue = true; /** * Value in unchecked state. * @group Props */ falseValue = false; /** * Used to define a string that autocomplete attribute the current element. * @group Props */ ariaLabel; /** * Establishes relationships between the component and label(s) where its value should be one or more element IDs. * @group Props */ ariaLabelledBy; /** * When present, it specifies that the component should automatically get focus on load. * @group Props */ autofocus; /** * Callback to invoke when the on value change. * @param {InputSwitchChangeEvent} event - Custom change event. * @group Emits */ onChange = new EventEmitter(); input; modelValue = false; focused = false; onModelChange = () => { }; onModelTouched = () => { }; constructor(cd) { this.cd = cd; } onClick(event) { if (!this.disabled && !this.readonly) { this.modelValue = this.checked() ? this.falseValue : this.trueValue; this.onModelChange(this.modelValue); this.onChange.emit({ originalEvent: event, checked: this.modelValue }); this.input.nativeElement.focus(); } } onFocus() { this.focused = true; } onBlur() { this.focused = false; this.onModelTouched(); } writeValue(value) { this.modelValue = value; this.cd.markForCheck(); } registerOnChange(fn) { this.onModelChange = fn; } registerOnTouched(fn) { this.onModelTouched = fn; } setDisabledState(val) { this.disabled = val; this.cd.markForCheck(); } checked() { return this.modelValue === this.trueValue; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: InputSwitch, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: InputSwitch, selector: "p-inputSwitch", inputs: { style: "style", styleClass: "styleClass", tabindex: ["tabindex", "tabindex", numberAttribute], inputId: "inputId", name: "name", disabled: ["disabled", "disabled", booleanAttribute], readonly: ["readonly", "readonly", booleanAttribute], trueValue: "trueValue", falseValue: "falseValue", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy", autofocus: ["autofocus", "autofocus", booleanAttribute] }, outputs: { onChange: "onChange" }, host: { classAttribute: "p-element" }, providers: [INPUTSWITCH_VALUE_ACCESSOR], viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true }], ngImport: i0, template: `