Files
ai-course/node_modules/.cache/babel-loader/09e21a5780b10dee68fd77b8133965a515a4ad53e10360ae497c0a8b7fa33a37.json

1 line
9.6 KiB
JSON
Raw Normal View History

{"ast":null,"code":"\"use client\";\n\nimport { jsx } from 'react/jsx-runtime';\nimport { isHTMLElement } from 'motion-dom';\nimport * as React from 'react';\nimport { useId, useRef, useContext, useInsertionEffect } from 'react';\nimport { MotionConfigContext } from '../../context/MotionConfigContext.mjs';\n\n/**\n * Measurement functionality has to be within a separate component\n * to leverage snapshot lifecycle.\n */\nclass PopChildMeasure extends React.Component {\n getSnapshotBeforeUpdate(prevProps) {\n const element = this.props.childRef.current;\n if (element && prevProps.isPresent && !this.props.isPresent) {\n const parent = element.offsetParent;\n const parentWidth = isHTMLElement(parent) ? parent.offsetWidth || 0 : 0;\n const size = this.props.sizeRef.current;\n size.height = element.offsetHeight || 0;\n size.width = element.offsetWidth || 0;\n size.top = element.offsetTop;\n size.left = element.offsetLeft;\n size.right = parentWidth - size.width - size.left;\n }\n return null;\n }\n /**\n * Required with getSnapshotBeforeUpdate to stop React complaining.\n */\n componentDidUpdate() {}\n render() {\n return this.props.children;\n }\n}\nfunction PopChild(_ref) {\n let {\n children,\n isPresent,\n anchorX\n } = _ref;\n const id = useId();\n const ref = useRef(null);\n const size = useRef({\n width: 0,\n height: 0,\n top: 0,\n left: 0,\n right: 0\n });\n const {\n nonce\n } = useContext(MotionConfigContext);\n /**\n * We create and inject a style block so we can apply this explicit\n * sizing in a non-destructive manner by just deleting the style block.\n *\n * We can't apply size via render as the measurement happens\n * in getSnapshotBeforeUpdate (post-render), likewise if we apply the\n * styles directly on the DOM node, we might be overwriting\n * styles set via the style prop.\n */\n useInsertionEffect(() => {\n const {\n width,\n height,\n top,\n left,\n right\n } = size.current;\n if (isPresent || !ref.current || !width || !height) return;\n const x = anchorX === \"left\" ? \"left: \".concat(left) : \"right: \".concat(right);\n ref.current.dataset.motionPopId = id;\n const style = document.createElement(\"style\");\n if (nonce) style.nonce = nonce;\n document.head.appendChild(style);\n if (style.sheet) {\n style.sheet.insertRule(\"\\n [data-motion-pop-id=\\\"\".concat(id, \"\\\"] {\\n position: absolute !important;\\n width: \").concat(width, \"px !important;\\n height: \").concat(height, \"px !important;\\n \").concat(x, \"px !important;\\n top: \").concat(top, \"px !important;\\n }\\n \"));\n }\n return () => {\n if (document.head.contains(style)) {\n document.head.removeChild(style);\n }\n };\n }, [isPresent]);\n return jsx(PopChildMeasure, {\n isPresent: isPresent,\n childRef: ref,\n sizeRef: size,\n children: React.cloneElement(children, {\n ref\n })\n });\n}\nexport { PopChild };","map":{"version":3,"names":["jsx","isHTMLElement","React","useId","useRef","useContext","useInsertionEffect","MotionConfigContext","PopChildMeasure","Component","getSnapshotBeforeUpdate","prevProps","element","props","childRef","current","isPresent","parent","offsetParent","parentWidth","offsetWidth","size","sizeRef","height","offsetHeight","width","top","offsetTop","left","offsetLeft","right","componentDidUpdate","render","children","PopChild","_ref","anchorX","id","ref","nonce","x","concat","dataset","motionPopId","style","document","createElement","head","appendChild","sheet","insertRule","contains","removeChild","cloneElement"],"sources":["/Users/apple/Documents/cursor/Web课件/AI课/education_web_多Agent协作系统/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs"],"sourcesContent":["\"use client\";\nimport { jsx } from 'react/jsx-runtime';\nimport { isHTMLElement } from 'motion-dom';\nimport