"use strict"; 'use client'; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.AccordionPanel = void 0; var React = _interopRequireWildcard(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _useComponentRenderer = require("../../utils/useComponentRenderer"); var _useEnhancedEffect = require("../../utils/useEnhancedEffect"); var _warn = require("../../utils/warn"); var _CollapsibleRootContext = require("../../collapsible/root/CollapsibleRootContext"); var _useCollapsiblePanel = require("../../collapsible/panel/useCollapsiblePanel"); var _AccordionRootContext = require("../root/AccordionRootContext"); var _AccordionItemContext = require("../item/AccordionItemContext"); var _styleHooks = require("../item/styleHooks"); var _AccordionPanelCssVars = require("./AccordionPanelCssVars"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /** * A collapsible panel with the accordion item contents. * Renders a `
` element. * * Documentation: [Base UI Accordion](https://base-ui.com/react/components/accordion) */ const AccordionPanel = exports.AccordionPanel = /*#__PURE__*/React.forwardRef(function AccordionPanel(props, forwardedRef) { const { className, hiddenUntilFound: hiddenUntilFoundProp, keepMounted: keepMountedProp, id: idProp, render, style: styleProp, ...otherProps } = props; const { hiddenUntilFound: contextHiddenUntilFound, keepMounted: contextKeepMounted } = (0, _AccordionRootContext.useAccordionRootContext)(); const hiddenUntilFound = hiddenUntilFoundProp ?? contextHiddenUntilFound; if (process.env.NODE_ENV !== 'production') { // eslint-disable-next-line react-hooks/rules-of-hooks (0, _useEnhancedEffect.useEnhancedEffect)(() => { if (keepMountedProp === false && hiddenUntilFound) { (0, _warn.warn)('The `keepMounted={false}` prop on a Accordion.Panel will be ignored when using `contextHiddenUntilFound` on the Panel or the Root since it requires the panel to remain mounted when closed.'); } }, [hiddenUntilFound, keepMountedProp]); } const { mounted, open, panelId, setPanelId, setMounted, setOpen } = (0, _CollapsibleRootContext.useCollapsibleRootContext)(); const keepMounted = keepMountedProp ?? contextKeepMounted; const { getRootProps, height, width, isOpen } = (0, _useCollapsiblePanel.useCollapsiblePanel)({ hiddenUntilFound, panelId: idProp ?? panelId, keepMounted, mounted, open, ref: forwardedRef, setPanelId, setMounted, setOpen }); const { state, triggerId } = (0, _AccordionItemContext.useAccordionItemContext)(); const { renderElement } = (0, _useComponentRenderer.useComponentRenderer)({ propGetter: getRootProps, render: render ?? 'div', state, className, extraProps: { ...otherProps, 'aria-labelledby': triggerId, role: 'region', style: { [_AccordionPanelCssVars.AccordionPanelCssVars.accordionPanelHeight]: height ? `${height}px` : undefined, [_AccordionPanelCssVars.AccordionPanelCssVars.accordionPanelWidth]: width ? `${width}px` : undefined, ...styleProp } }, customStyleHookMapping: _styleHooks.accordionStyleHookMapping }); if (!isOpen && !keepMounted && !hiddenUntilFound) { return null; } return renderElement(); }); process.env.NODE_ENV !== "production" ? AccordionPanel.propTypes /* remove-proptypes */ = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * @ignore */ children: _propTypes.default.node, /** * CSS class applied to the element, or a function that * returns a class based on the component’s state. */ className: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]), /** * Allows the browser’s built-in page search to find and expand the panel contents. * * Overrides the `keepMounted` prop and uses `hidden="until-found"` * to hide the element without removing it from the DOM. * @default false */ hiddenUntilFound: _propTypes.default.bool, /** * @ignore */ id: _propTypes.default.string, /** * Whether to keep the element in the DOM while the panel is closed. * This prop is ignored when `hiddenUntilFound` is used. * @default false */ keepMounted: _propTypes.default.bool, /** * Allows you to replace the component’s HTML element * with a different tag, or compose it with another component. * * Accepts a `ReactElement` or a function that returns the element to render. */ render: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]), /** * @ignore */ style: _propTypes.default.object } : void 0;