{"version":3,"file":"eui-components-eui-disable-content.mjs","sources":["../../eui-disable-content/eui-disable-content.component.ts","../../eui-disable-content/index.ts","../../eui-disable-content/eui-components-eui-disable-content.ts"],"sourcesContent":["import {\n\tafterNextRender,\n\tbooleanAttribute,\n\tComponent,\n\teffect,\n\tElementRef,\n\tHostListener,\n\tinject,\n\tinput,\n\tlinkedSignal,\n\tRenderer2,\n\tViewEncapsulation,\n} from '@angular/core';\nimport { EuiGrowlService } from '@eui/core';\nimport { BooleanInput } from '@angular/cdk/coercion';\n\n/**\n * @description\n * A component that disables content and displays a semi-transparent overlay with optional notification.\n * Manages focus state and provides visual feedback when content is temporarily unavailable.\n * Useful for indicating loading states, processing operations, or temporarily disabled sections.\n * \n * @usageNotes\n * ### Basic Usage\n * ```html\n * <eui-disable-content [isDisabled]=\"isProcessing\">\n *   <form>\n *     <!-- Form content -->\n *   </form>\n * </eui-disable-content>\n * ```\n * \n * ### With Notification\n * ```html\n * <eui-disable-content \n *   [isDisabled]=\"isSaving\" \n *   [disabledText]=\"'Please wait while we save your changes'\">\n *   <div class=\"content-section\">\n *     <!-- Content -->\n *   </div>\n * </eui-disable-content>\n * ```\n * \n * ### Conditional Disabling\n * ```typescript\n * // Component\n * isFormDisabled = false;\n * \n * submitForm(): void {\n *   this.isFormDisabled = true;\n *   this.api.submit().subscribe(() => {\n *     this.isFormDisabled = false;\n *   });\n * }\n * \n * // Template\n * <eui-disable-content [isDisabled]=\"isFormDisabled\">\n *   <button (click)=\"submitForm()\">Submit</button>\n * </eui-disable-content>\n * ```\n * \n * ### Accessibility\n * - Automatically sets `aria-disabled=\"true\"` on focused elements when disabled\n * - Manages focus state by storing and restoring last active element\n * - Sets `tabindex=\"-1\"` on disabled elements to prevent keyboard navigation\n * - Displays growl notification when clicking disabled content (if `disabledText` provided)\n * - Restores focus to previously active element when re-enabled\n * \n * ### Notes\n * - Wraps content with `<ng-content/>` for flexible composition\n * - Requires `EuiGrowlService` for notification functionality\n * - CSS class `eui-disable-content--disabled` applied when active\n * - Does not prevent programmatic interaction, only visual and focus management\n * - Use for temporary disabling; for permanent states, use native `disabled` attribute\n */\n@Component({\n    selector: 'eui-disable-content',\n    template: '<ng-content/>',\n    styleUrls: ['./eui-disable-content.scss'],\n    encapsulation: ViewEncapsulation.None,\n})\nexport class EuiDisableContentComponent {\n    /**\n     * Text to display in an eui-growl (type info) notification when clicking\n     * the disabled content.\n     */\n    disabledText = input('');\n\n    /**\n     * Controls whether the content is disabled. If disabled, a semi-transparent\n     * overlay with spinner is shown.\n     */\n    isDisabled = input<boolean, BooleanInput>(null, { transform: booleanAttribute });\n\n    /** Stores the last active element before disabling */\n    private lastActiveElement: HTMLElement = null;\n    /** Reference to the component's element */\n    private readonly elRef: ElementRef = inject(ElementRef);\n    /** Service for displaying growl notifications */\n    private readonly growlService: EuiGrowlService = inject(EuiGrowlService, { optional: true });\n    /** Renderer for DOM manipulations */\n    private readonly renderer: Renderer2 = inject(Renderer2);\n\t/**\n\t * Tracks when the component transitions from enabled to disabled state.\n\t * Returns true only when isDisabled changes from false to true. True if\n\t * the component is transitioning to blocked state.\n\t */\n\tprivate isBlocking = linkedSignal({\n\t\tsource: this.isDisabled,\n\t\tcomputation: (current, previous) => current && !previous?.source,\n\t});\n\n    /**\n     * Initializes the component and sets up an effect to handle disabled state changes\n     */\n    constructor() {\n\t\teffect(() => {\n\t\t\tconst disabled = this.isDisabled();\n\t\t\tif(disabled) {\n\t\t\t\tthis.renderer.addClass(this.elRef.nativeElement, 'eui-disable-content--disabled');\n\t\t\t} else {\n\t\t\t\tthis.renderer.removeClass(this.elRef.nativeElement, 'eui-disable-content--disabled');\n\t\t\t}\n\t\t});\n\n\t\teffect(() => {\n\t\t\tif (this.isBlocking()) {\n\t\t\t\tconst activeElement = this.getActiveElement();\n\t\t\t\tthis.deactivateElement(activeElement);\n\t\t\t} else if (!this.isDisabled()) {\n\t\t\t\tthis.reactivateElement();\n\t\t\t}\n\t\t});\n    }\n\n\t/**\n\t * Handles click events on the disabled content\n\t * Shows a growl notification if content is disabled and has disabled text\n\t * @internal\n\t */\n\t@HostListener('click')\n\tprotected onClick(): void {\n\t\tif (this.isDisabled() && this.disabledText() && this.growlService) {\n\t\t\tthis.growlService.growlInfo(this.disabledText());\n\t\t}\n\t}\n\n    /**\n     * Stores the currently active element before disabling\n     * @param activeElement The element to deactivate\n     * @internal\n     */\n    private deactivateElement(activeElement: HTMLElement): void {\n        if (activeElement) {\n            this.renderer.setAttribute(activeElement, 'disabled', 'true');\n            this.renderer.setAttribute(activeElement, 'tabindex', '-1');\n            this.renderer.setAttribute(activeElement, 'aria-disabled', 'true');\n            this.lastActiveElement = activeElement;\n        } else {\n            this.lastActiveElement = null;\n        }\n    }\n\n    /**\n     * Reactivates the last active element\n     * @internal\n     */\n    private reactivateElement(): void {\n        if (this.lastActiveElement) {\n            this.renderer.removeAttribute(this.lastActiveElement, 'disabled');\n            this.renderer.setAttribute(this.lastActiveElement, 'tabindex', '0');\n            this.renderer.setAttribute(this.lastActiveElement, 'aria-disabled', 'false');\n            this.lastActiveElement.focus();\n        }\n    }\n\n    /**\n     * Gets the currently focused element within the component\n     * @returns The focused HTML element or null\n     * @internal\n     */\n    private getActiveElement(): HTMLElement {\n        return this.elRef.nativeElement.querySelector(':focus');\n    }\n}\n","import { EuiDisableContentComponent } from './eui-disable-content.component';\n\nexport * from './eui-disable-content.component';\n\nexport const EUI_DISABLE_CONTENT = [\n    EuiDisableContentComponent,\n] as const;\n\n// export { EuiDisableContentComponent as EuiDisableContent } from './eui-disable-content.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DG;MAOU,0BAA0B,CAAA;AA+BnC;;AAEG;AACH,IAAA,WAAA,GAAA;AAjCA;;;AAGG;AACH,QAAA,IAAA,CAAA,YAAY,GAAG,KAAK,CAAC,EAAE,m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