{"version":3,"file":"eui-components-eui-button-group.mjs","sources":["../../eui-button-group/eui-button-group.component.ts","../../eui-button-group/index.ts","../../eui-button-group/eui-components-eui-button-group.ts"],"sourcesContent":["import {\n    AfterContentInit,\n    Component,\n    ContentChildren,\n    EventEmitter,\n    forwardRef,\n    Input,\n    Output,\n    QueryList,\n    ChangeDetectionStrategy,\n    HostBinding,\n    booleanAttribute,\n} from '@angular/core';\n\nimport { EuiButtonComponent } from '@eui/components/eui-button';\n\n/**\n * @description\n * `eui-button-group` component for organizing multiple buttons with optional checkbox or radio button selection behavior.\n * Provides visual grouping and automatic state management for single or multiple selection modes.\n * Supports three modes: standard (no selection), checkbox (multiple selection), and radio (single selection).\n * Automatically manages checked state across buttons and emits events on button interactions.\n * Content is projected via ng-content expecting `eui-button` children.\n * \n * @usageNotes\n * #### Standard button group (no selection behavior)\n * ```html\n * <eui-button-group>\n *   <button euiButton id=\"btn1\">Action 1</button>\n *   <button euiButton id=\"btn2\">Action 2</button>\n *   <button euiButton id=\"btn3\">Action 3</button>\n * </eui-button-group>\n * ```\n *\n * #### Radio button group (single selection)\n * ```html\n * <eui-button-group [isRadioButtons]=\"true\" (buttonClick)=\"onSelection($event)\">\n *   <button euiButton id=\"left\" [isChecked]=\"true\">Left</button>\n *   <button euiButton id=\"center\">Center</button>\n *   <button euiButton id=\"right\">Right</button>\n * </eui-button-group>\n * ```\n *\n * #### Checkbox button group (multiple selection)\n * ```html\n * <eui-button-group [isCheckboxButtons]=\"true\">\n *   <button euiButton id=\"bold\">Bold</button>\n *   <button euiButton id=\"italic\">Italic</button>\n *   <button euiButton id=\"underline\">Underline</button>\n * </eui-button-group>\n * ```\n *\n * ```ts\n * onSelection(button: EuiButtonComponent): void {\n *   console.log('Selected button:', button.id, 'Checked:', button.isChecked);\n * }\n * ```\n *\n * ### Accessibility\n * - Buttons maintain native keyboard accessibility (Enter/Space)\n * - Visual grouping indicates related actions to all users\n * - Checked state is visually indicated and announced to screen readers\n * - Radio mode ensures only one selection, following standard radio button patterns\n * - Each button should have unique id for proper state management\n * - Consider adding aria-label to group for screen reader context\n *\n * ### Notes\n * - Must contain button[euiButton] children for proper functionality\n * - Three modes: standard (default), radio (isRadioButtons), checkbox (isCheckboxButtons)\n * - Standard mode: buttons act as regular action buttons without selection state\n * - Radio mode: only one button can be checked at a time, selecting one unchecks others\n * - Checkbox mode: multiple buttons can be checked independently\n * - Each button must have unique id attribute for state management\n * - isChecked property on buttons controls initial checked state\n * - buttonClick event emits after state is updated\n * - Buttons are visually grouped with connected borders\n * - Cannot enable both isRadioButtons and isCheckboxButtons simultaneously\n * - Use radio mode for mutually exclusive options (alignment, view mode)\n * - Use checkbox mode for independent toggles (text formatting, filters)\n */\n@Component({\n    selector: 'eui-button-group',\n    template: '<ng-content/>',\n    styleUrls: ['./eui-button-group.scss'],\n    changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class EuiButtonGroupComponent implements AfterContentInit {\n    /** CSS classes applied to the host element */\n    @HostBinding('class')\n    get cssClasses(): string {\n        return 'eui-button-group';\n    }\n\n    /**\n     * Enables checkbox behavior allowing multiple buttons to be selected simultaneously.\n     * When true, buttons can be independently toggled on/off.\n     * @default false\n     */\n    @Input({ transform: booleanAttribute }) isCheckboxButtons = false;\n\n    /**\n     * Enables radio button behavior allowing only one button to be selected at a time.\n     * When true, selecting a button automatically deselects others in the group.\n     * @default false\n     */\n    @Input({ transform: booleanAttribute }) isRadioButtons = false;\n\n    /**\n     * Emitted when any button in the group is clicked.\n     * Payload: EuiButtonComponent - the clicked button instance\n     * Triggered after button state is updated based on group configuration.\n     */\n    @Output() buttonClick: EventEmitter<EuiButtonComponent> = new EventEmitter<EuiButtonComponent>();\n\n    @ContentChildren(forwardRef(() => EuiButtonComponent)) buttons: QueryList<EuiButtonComponent>;\n\n    ngAfterContentInit(): void {\n        this.buttons.map((b: EuiButtonComponent) => {\n            b.buttonClick.subscribe(() => {\n                this.handleInnerButtonClick(b);\n            });\n            if (!b.isChecked) b.isChecked = false;\n        });\n    }\n\n    /**\n     * Handles button click events based on group configuration\n     * - For checkbox buttons: Toggles the clicked button's checked state\n     * - For radio buttons: Sets the clicked button as checked and unchecks others\n     * - Emits the buttonClick event with the clicked button instance\n     *\n     * @param button - The EuiButtonComponent that was clicked\n     * @internal\n     */\n    private handleInnerButtonClick(button: EuiButtonComponent): void {\n        try {\n            if (button.isChecked && this.isCheckboxButtons) {\n                button.isChecked = false;\n            } else {\n                if (this.isRadioButtons) {\n                    this.buttons.find((b) => b.id === button.id).isChecked = true;\n                    this.buttons.forEach((b) => {\n                        if (b.id !== button.id) {\n                            b.isChecked = false;\n                        }\n                    });\n                } else if (this.isCheckboxButtons) {\n                    this.buttons.find((b) => b.id === button.id).isChecked = true;\n                } else if (!this.isCheckboxButtons && !this.isRadioButtons && !button.isChecked) {\n                    button.isChecked = true;\n                } else {\n                    button.isChecked = false;\n                }\n            }\n\n            this.buttonClick.emit(button);\n        } catch (e) {\n            console.log(e);\n        }\n    }\n}\n","import { EuiButtonGroupComponent } from './eui-button-group.component';\n\nexport * from './eui-button-group.component';\n\nexport const EUI_BUTTON_GROUP = [\n    EuiButtonGroupComponent,\n] as const;\n\n// export { EuiButtonGroupComponent as EuiButtonGroup } from './eui-button-group.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DG;MAOU,uBAAuB,CAAA;AANpC,IAAA,WAAA,GAAA;AAaI;;;;AAIG;QACqC,IAAA,CAAA,iBAAiB,GAAG,KAAK;AAEjE;;;;AAIG;QACqC,IAAA,CAAA,cAAc,GAAG,KAAK;AAE9D;;;;AAIG;AACO,QAAA,IAAA,CAAA,WAAW,GAAqC,IAAI,YAAY,EAAsB;AAgDnG,IAAA;;AAxEG,IAAA,IACI,UAAU,GAAA;AACV,QAAA,OAAO,kBAAkB;IAC7B;IAyB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