1 line
14 KiB
JSON
1 line
14 KiB
JSON
|
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nvar _excluded = [\"showArrow\", \"headerClass\", \"isActive\", \"onItemClick\", \"forceRender\", \"className\", \"prefixCls\", \"collapsible\", \"accordion\", \"panelKey\", \"extra\", \"header\", \"expandIcon\", \"openMotion\", \"destroyInactivePanel\", \"children\"];\nimport classNames from 'classnames';\nimport CSSMotion from 'rc-motion';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport React from 'react';\nimport PanelContent from \"./PanelContent\";\nvar CollapsePanel = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var _props$showArrow = props.showArrow,\n showArrow = _props$showArrow === void 0 ? true : _props$showArrow,\n headerClass = props.headerClass,\n isActive = props.isActive,\n onItemClick = props.onItemClick,\n forceRender = props.forceRender,\n className = props.className,\n prefixCls = props.prefixCls,\n collapsible = props.collapsible,\n accordion = props.accordion,\n panelKey = props.panelKey,\n extra = props.extra,\n header = props.header,\n expandIcon = props.expandIcon,\n openMotion = props.openMotion,\n destroyInactivePanel = props.destroyInactivePanel,\n children = props.children,\n resetProps = _objectWithoutProperties(props, _excluded);\n var disabled = collapsible === 'disabled';\n var collapsibleHeader = collapsible === 'header';\n var collapsibleIcon = collapsible === 'icon';\n var ifExtraExist = extra !== null && extra !== undefined && typeof extra !== 'boolean';\n var handleItemClick = function handleItemClick() {\n onItemClick === null || onItemClick === void 0 || onItemClick(panelKey);\n };\n var handleKeyDown = function handleKeyDown(e) {\n if (e.key === 'Enter' || e.keyCode === KeyCode.ENTER || e.which === KeyCode.ENTER) {\n handleItemClick();\n }\n };\n\n // ======================== Icon ========================\n var iconNode = typeof expandIcon === 'function' ? expandIcon(props) : /*#__PURE__*/React.createElement(\"i\", {\n className: \"arrow\"\n });\n if (iconNode) {\n iconNode = /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-expand-icon\"),\n onClick: ['header', 'icon'].includes(collapsible) ? handleItemClick : undefined\n }, iconNode);\n }\n var collapsePanelClassNames = classNames(_defineProperty(_defineProperty(_defineProperty({}, \"\".concat(prefixCls, \"-item\"), true), \"\".concat(prefixCls, \"-item-active\"), isActive), \"\".concat(prefixCls, \"-item-disabled\"), disabled), className);\n var headerClassName = classNames(headerClass, _defineProperty(_defineProperty(_defineProperty({}, \"\".concat(prefixCls, \"-header\"), true), \"\".concat(prefixCls, \"-header-collapsible-only\"), collapsibleHeader), \"\".concat(prefixCls, \"-icon-collapsible-only\"), collapsibleIcon));\n\n // ======================== HeaderProps ========================\n var headerProps = {\n className: headerClassName,\n 'aria-expanded': isActive,\n 'aria-disabled': disabled,\n onKeyDown: handleKeyDown\n };\n if (!collapsibleHeader && !collapsibleIcon) {\n headerProps.onClick = handleItemClick;\n headerProps.role = accordion ? 'tab' : 'button';\n headerProps.tabIndex = disabled ? -1 : 0;\n }\n\n // ======================== Render ========================\n return /*#__PURE__*/React.createElement(\"div\", _extends({}, resetProps, {\n ref: ref,\n className: collapsePanelClassNames\n }), /*#__PURE__*/React.createElement(\"div\", headerProps, showArrow && iconNode, /*#__PURE__*/React.createElement(\"span\", {\n className: \"\".concat(prefixCls, \"-header-text\"),\n onClick: collapsible === 'header' ? handleItemClick : undefined\n }, header), ifExtraExist && /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-extra\")\n }, extra)), /*#__PURE
|