| Server IP : 13.235.167.51 / Your IP : 216.73.217.116 Web Server : Apache System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64 User : root ( 0) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/control.machinox.in/node_modules/react-bootstrap/esm/ |
Upload File : |
"use client";
import * as React from 'react';
import { useContext } from 'react';
import classNames from 'classnames';
import AccordionContext, { isAccordionItemSelected } from './AccordionContext';
import AccordionItemContext from './AccordionItemContext';
import { useBootstrapPrefix } from './ThemeProvider';
import { jsx as _jsx } from "react/jsx-runtime";
export function useAccordionButton(eventKey, onClick) {
const {
activeEventKey,
onSelect,
alwaysOpen
} = useContext(AccordionContext);
return e => {
/*
Compare the event key in context with the given event key.
If they are the same, then collapse the component.
*/
let eventKeyPassed = eventKey === activeEventKey ? null : eventKey;
if (alwaysOpen) {
if (Array.isArray(activeEventKey)) {
if (activeEventKey.includes(eventKey)) {
eventKeyPassed = activeEventKey.filter(k => k !== eventKey);
} else {
eventKeyPassed = [...activeEventKey, eventKey];
}
} else {
// activeEventKey is undefined.
eventKeyPassed = [eventKey];
}
}
onSelect == null || onSelect(eventKeyPassed, e);
onClick == null || onClick(e);
};
}
const AccordionButton = /*#__PURE__*/React.forwardRef(({
// Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
as: Component = 'button',
bsPrefix,
className,
onClick,
...props
}, ref) => {
bsPrefix = useBootstrapPrefix(bsPrefix, 'accordion-button');
const {
eventKey
} = useContext(AccordionItemContext);
const accordionOnClick = useAccordionButton(eventKey, onClick);
const {
activeEventKey
} = useContext(AccordionContext);
if (Component === 'button') {
props.type = 'button';
}
return /*#__PURE__*/_jsx(Component, {
ref: ref,
onClick: accordionOnClick,
...props,
"aria-expanded": Array.isArray(activeEventKey) ? activeEventKey.includes(eventKey) : eventKey === activeEventKey,
className: classNames(className, bsPrefix, !isAccordionItemSelected(activeEventKey, eventKey) && 'collapsed')
});
});
AccordionButton.displayName = 'AccordionButton';
export default AccordionButton;