{"version":3,"file":"eui-components-eui-input-checkbox.mjs","sources":["../../eui-input-checkbox/eui-input-checkbox.component.ts","../../eui-input-checkbox/index.ts","../../eui-input-checkbox/eui-components-eui-input-checkbox.ts"],"sourcesContent":["import {\n    DoCheck,\n    ElementRef,\n    HostBinding,\n    Input,\n    OnChanges,\n    Renderer2,\n    SimpleChanges,\n    OnInit,\n    HostListener,\n    Component,\n    Output,\n    EventEmitter,\n    inject,\n} from '@angular/core';\nimport { ControlValueAccessor, NgControl } from '@angular/forms';\nimport { InputDirective } from '@eui/components/shared';\nimport { coerceBooleanProperty, BooleanInput } from '@angular/cdk/coercion';\n\n/**\n * @description\n * Checkbox input field that allows users to select or deselect a boolean value.\n * Supports standard checked state, disabled and readonly modes, validation feedback, and an optional indeterminate (mixed) state.\n * \n * Angular component that provides a custom checkbox input implementation.\n * Extends {@link InputDirective} and implements form control functionality.\n *\n * @usageNotes\n * ### Basic Usage\n * ```html\n * <input euiInputCheckBox id=\"terms\" [(ngModel)]=\"acceptTerms\" />\n * <label for=\"terms\">I accept the terms and conditions</label>\n * ```\n *\n * ### With Indeterminate State\n * ```typescript\n * <input euiInputCheckBox [indeterminate]=\"someItemsSelected\" />\n * ```\n *\n * ### Accessibility\n * - Always associate checkbox with a label using `for` attribute or wrap in `<label>`\n * - Component automatically provides `aria-label` based on checked state\n * - Supports keyboard interaction (Space key to toggle)\n * - Use `isInvalid` to communicate validation errors to screen readers\n *\n * ### Notes\n * - Indeterminate state is automatically cleared when checkbox is clicked\n * - Works seamlessly with Angular Forms (both template-driven and reactive)\n * - Readonly state prevents interaction but maintains visual appearance\n *\n * @component\n * @selector input[euiInputCheckBox]\n * @implements {@link OnInit}\n * @implements {@link DoCheck}\n * @implements {@link OnChanges}\n * @implements {@link ControlValueAccessor}\n */\n@Component({\n    // eslint-disable-next-line @angular-eslint/component-selector\n    selector: 'input[euiInputCheckBox]',\n    styleUrls: ['./eui-input-checkbox.scss'],\n    template: '',\n})\nexport class EuiInputCheckboxComponent extends InputDirective implements OnInit, DoCheck, OnChanges, ControlValueAccessor {\n    /**\n     * Gets the CSS classes for the checkbox component.\n     * Combines base classes with validation state classes.\n     *\n     * @returns {string} Space-separated list of CSS classes\n     */\n    @HostBinding('class')\n    public get cssClasses(): string {\n        return [this.getCssClasses('eui-input-checkbox'), this._isInvalid ? 'eui-input-checkbox--invalid' : ''].join(' ').trim();\n    }\n    /**\n     * Event emitter that fires when the indeterminate state changes.\n     *\n     * @event indeterminateChange\n     * @type {EventEmitter<boolean>}\n     */\n    @Output() readonly indeterminateChange: EventEmitter<boolean> = new EventEmitter<boolean>();\n\n    /**\n     * Controls the indeterminate (mixed) state of the checkbox.\n     * When true, the checkbox appears in an indeterminate state.\n     * This state is automatically cleared when the checkbox is clicked.\n     *\n     * @property {boolean} indeterminate\n     */\n    @Input()\n    get indeterminate(): boolean {\n        return this._indeterminate;\n    }\n    set indeterminate(value: BooleanInput) {\n        const changed = value != this._indeterminate;\n        this._indeterminate = coerceBooleanProperty(value);\n\n        if (changed) {\n            this.indeterminateChange.emit(this._indeterminate);\n        }\n\n        this._syncIndeterminate(this._checked ? false : this._indeterminate);\n    }\n\n    /**\n     * Controls the invalid state of the checkbox. Used for displaying validation errors.\n     *\n     * @property {boolean} isInvalid\n     */\n    @Input()\n    public get isInvalid(): boolean {\n        return this._isInvalid || null;\n    }\n\n    // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    public set isInvalid(state: any) {\n        this.setInvalid(state);\n    }\n\n    protected _isInvalid: boolean;\n\n    @HostBinding('attr.type') protected type = 'checkbox';\n\n    /**\n     * Controls the checked state of the checkbox.\n     *\n     * @property {boolean} checked\n     */\n    @HostBinding('attr.checked')\n    @Input()\n    public get checked(): boolean {\n        return this._checked;\n    }\n\n    public set checked(value: BooleanInput) {\n        this._checked = coerceBooleanProperty(value) ? true : undefined;\n    }\n\n    /**\n     * Attaches an aria-label attribute based on the checked state.\n     *\n     * @property {string} ariaLabel\n     */\n    @HostBinding('attr.aria-label')\n    public get ariaLabel(): string {\n        return this._checked ? 'Input Checked' : 'Input Unchecked';\n    }\n\n    protected ngControl = inject(NgControl, { optional: true, self: true })!;\n    protected _elementRef: ElementRef<HTMLInputElement> = inject<ElementRef<HTMLInputElement>>(ElementRef);\n    protected _renderer: Renderer2 = inject(Renderer2);\n    protected _checked: boolean;\n    private _indeterminate = false;\n\n    constructor() {\n        super();\n\n        // if there's no id attribute set one\n        if (!this._elementRef.nativeElement.id) {\n            this.setIdAttribute();\n        }\n\n        // register control valueAccessor\n        if (this.ngControl) {\n            this.ngControl.valueAccessor = this;\n        }\n    }\n\n    /**\n     * Lifecycle hook that is called after data-bound properties are initialized.\n     * Sets the default control value if needed.\n     */\n    ngOnInit(): void {\n        super.ngOnInit();\n\n        // in case control value is null set the default one (isChecked) and sync Control State\n        if (this.ngControl?.control?.value === null) {\n            this.ngControl.control.setValue(this._checked, { emitModelToViewChange: false });\n            // changing Model Expression after view checked, so detect changes\n            // TODO: check why although it's checked .checked returns false\n            // this.ngControl.viewToModelUpdate(this._checked);\n            // this._cd.detectChanges();\n        }\n    }\n\n    /**\n     * Lifecycle hook that performs custom change detection.\n     * Updates invalid state based on control status.\n     */\n    ngDoCheck(): void {\n        if (this.ngControl) {\n            this._isInvalid = this.ngControl.invalid && this.ngControl.touched;\n        }\n    }\n\n    /**\n     * Lifecycle hook that is called when data-bound properties change.\n     * Handles changes to checked and readonly states.\n     *\n     * @param {SimpleChanges} changes - Object containing changed properties\n     */\n    ngOnChanges(changes: SimpleChanges): void {\n        if (changes['checked']) {\n            const currentValue = coerceBooleanProperty(changes['checked']?.currentValue);\n            if (currentValue !== this?.ngControl?.control?.value) {\n                this._checked = currentValue;\n                this._elementRef.nativeElement.checked = currentValue;\n            }\n        }\n\n        if (changes['readonly']) {\n            const readonly = coerceBooleanProperty(changes['readonly']?.currentValue);\n            if (readonly) {\n                this._renderer.setAttribute(this._elementRef.nativeElement, 'readonly', null);\n            } else {\n                this._renderer.removeAttribute(this._elementRef.nativeElement, 'readonly');\n            }\n        }\n    }\n\n    /**\n     * Implements ControlValueAccessor writeValue method.\n     * Updates the checked state of the checkbox.\n     *\n     * @param {boolean} obj - The value to write\n     */\n    writeValue(obj: boolean): void {\n        this._checked = coerceBooleanProperty(obj) ? true : undefined;\n        this._elementRef.nativeElement.checked = this._checked ? true : undefined;\n    }\n\n    // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    registerOnChange(fn: any): void {\n        this.onChange = fn;\n    }\n\n    // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    registerOnTouched(fn: any): void {\n        this.onBlur = fn;\n    }\n\n    setDisabledState?(isDisabled: boolean): void {\n        this.disabled = isDisabled;\n    }\n\n    /**\n     * Event handler for checkbox change events.\n     *\n     * @param {boolean} checked - The new checked state\n     * @protected\n     */\n    @HostListener('change', ['$any($event.target).checked'])\n    protected onChanged(checked: boolean): void {\n        if (checked) {\n            this._renderer.setAttribute(this._elementRef.nativeElement, 'checked', 'true');\n            this._checked = true;\n        } else {\n            this._renderer.removeAttribute(this._elementRef.nativeElement, 'checked');\n            this._checked = undefined;\n        }\n        this.onChange(checked);\n    }\n\n    /**\n     * Event handler for space key press.\n     * Prevents space key action when checkbox is readonly.\n     *\n     * @param {KeyboardEvent} event - The keyboard event\n     * @protected\n     */\n    @HostListener('keydown.space', ['$any($event)'])\n    protected onSpacePressed(event: KeyboardEvent): void {\n        if (this.readonly) {\n            event.preventDefault();\n            event.stopPropagation();\n        }\n    }\n\n    protected onChange = <T>(_: T): void => {\n        /* Nothing to be Done so far */\n    };\n\n    // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    protected onBlur = (_: any): void => {\n        /* Nothing to be Done so far */\n    };\n\n    /**\n     * Sets the invalid state of the checkbox.\n     *\n     * @param {any} state - The invalid state to set (true/false)\n     * @protected\n     */\n    protected setInvalid(state?: boolean): void;\n    /**\n     * Sets the invalid state of the checkbox.\n     *\n     * @deprecated Use the boolean version instead\n     * @param state - The invalid state to set (true/false)\n     * @protected\n     */\n    // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    protected setInvalid(state?: any): void {\n        // in case it's controlled by NgControl override\n        this._isInvalid = this.control ? this.control.invalid && this.control.touched : coerceBooleanProperty(state);\n    }\n\n    /**\n     * Sets the indeterminate state of the checkbox. This is also known as \"mixed\" mode and can be used to\n     * represent a checkbox with three states, e.g. a checkbox that represents a nested list of\n     * check-able items.\n     *\n     * @param value\n     */\n    private _syncIndeterminate(value: boolean): void {\n        if (this._elementRef) {\n            this._elementRef.nativeElement.indeterminate = value;\n        }\n    }\n}\n","import { EuiInputCheckboxComponent } from './eui-input-checkbox.component';\n\nexport * from './eui-input-checkbox.component';\n\nexport const EUI_INPUT_CHECKBOX = [\n    EuiInputCheckboxComponent,\n] as const;\n\n// export { EuiInputCheckboxComponent as EuiInputCheckbox } from './eui-input-checkbox.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCG;AAOG,MAAO,yBAA0B,SAAQ,cAAc,CAAA;AACzD;;;;;AAKG;AACH,IAAA,IACW,UAAU,GAAA;AACjB,QAAA,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,UAAU,GAAG,6BAA6B,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;IAC5H;AASA;;;;;;AAMG;AACH,IAAA,IACI,aAAa,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