1 line
20 KiB
JSON
1 line
20 KiB
JSON
|
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport classNames from 'classnames';\nimport { useComposeRef } from \"rc-util/es/ref\";\nimport React, { useMemo, useRef } from 'react';\nimport { RefContext } from \"../../context\";\nimport MemoChildren from \"./MemoChildren\";\nimport pickAttrs from \"rc-util/es/pickAttrs\";\nvar sentinelStyle = {\n width: 0,\n height: 0,\n overflow: 'hidden',\n outline: 'none'\n};\nvar entityStyle = {\n outline: 'none'\n};\nvar Panel = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var prefixCls = props.prefixCls,\n className = props.className,\n style = props.style,\n title = props.title,\n ariaId = props.ariaId,\n footer = props.footer,\n closable = props.closable,\n closeIcon = props.closeIcon,\n onClose = props.onClose,\n children = props.children,\n bodyStyle = props.bodyStyle,\n bodyProps = props.bodyProps,\n modalRender = props.modalRender,\n onMouseDown = props.onMouseDown,\n onMouseUp = props.onMouseUp,\n holderRef = props.holderRef,\n visible = props.visible,\n forceRender = props.forceRender,\n width = props.width,\n height = props.height,\n modalClassNames = props.classNames,\n modalStyles = props.styles;\n\n // ================================= Refs =================================\n var _React$useContext = React.useContext(RefContext),\n panelRef = _React$useContext.panel;\n var mergedRef = useComposeRef(holderRef, panelRef);\n var sentinelStartRef = useRef();\n var sentinelEndRef = useRef();\n var entityRef = useRef();\n React.useImperativeHandle(ref, function () {\n return {\n focus: function focus() {\n var _entityRef$current;\n (_entityRef$current = entityRef.current) === null || _entityRef$current === void 0 || _entityRef$current.focus({\n preventScroll: true\n });\n },\n changeActive: function changeActive(next) {\n var _document = document,\n activeElement = _document.activeElement;\n if (next && activeElement === sentinelEndRef.current) {\n sentinelStartRef.current.focus({\n preventScroll: true\n });\n } else if (!next && activeElement === sentinelStartRef.current) {\n sentinelEndRef.current.focus({\n preventScroll: true\n });\n }\n }\n };\n });\n\n // ================================ Style =================================\n var contentStyle = {};\n if (width !== undefined) {\n contentStyle.width = width;\n }\n if (height !== undefined) {\n contentStyle.height = height;\n }\n // ================================ Render ================================\n var footerNode = footer ? /*#__PURE__*/React.createElement(\"div\", {\n className: classNames(\"\".concat(prefixCls, \"-footer\"), modalClassNames === null || modalClassNames === void 0 ? void 0 : modalClassNames.footer),\n style: _objectSpread({}, modalStyles === null || modalStyles === void 0 ? void 0 : modalStyles.footer)\n }, footer) : null;\n var headerNode = title ? /*#__PURE__*/React.createElement(\"div\", {\n className: classNames(\"\".concat(prefixCls, \"-header\"), modalClassNames === null || modalClassNames === void 0 ? void 0 : modalClassNames.header),\n style: _objectSpread({}, modalStyles === null || modalStyles === void 0 ? void 0 : modalStyles.header)\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-title\"),\n id: ariaId\n }, title)) : null;\n var closableObj = useMemo(function () {\n if (_typeof(closable) === 'object' && closable !== null) {\n return closable;\n }\n if (closable) {\n return {\n closeIcon: closeIcon !== null && closeIcon !== void 0 ? closeIcon : /*#__PURE__*/React.createElement(\"span\", {\n className: \"\".concat(prefixCls, \"-close-x\")\n })\n };\n }\n
|