c9e870f93e538ec3df61ceb031ae9351.json 4.8 KB
{"ast":null,"code":"import { useRef, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport canUseDom from './Dom/canUseDom';\nvar Portal = forwardRef(function (props, ref) {\n  var didUpdate = props.didUpdate,\n      getContainer = props.getContainer,\n      children = props.children;\n  var containerRef = useRef(); // Ref return nothing, only for wrapper check exist\n\n  useImperativeHandle(ref, function () {\n    return {};\n  }); // Create container in client side with sync to avoid useEffect not get ref\n\n  var initRef = useRef(false);\n\n  if (!initRef.current && canUseDom()) {\n    containerRef.current = getContainer();\n    initRef.current = true;\n  } // [Legacy] Used by `rc-trigger`\n\n\n  useEffect(function () {\n    didUpdate === null || didUpdate === void 0 ? void 0 : didUpdate(props);\n  });\n  useEffect(function () {\n    return function () {\n      var _containerRef$current, _containerRef$current2; // [Legacy] This should not be handle by Portal but parent PortalWrapper instead.\n      // Since some component use `Portal` directly, we have to keep the logic here.\n\n\n      (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : (_containerRef$current2 = _containerRef$current.parentNode) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.removeChild(containerRef.current);\n    };\n  }, []);\n  return containerRef.current ? ReactDOM.createPortal(children, containerRef.current) : null;\n});\nexport default Portal;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-util/es/Portal.js"],"names":["useRef","useEffect","forwardRef","useImperativeHandle","ReactDOM","canUseDom","Portal","props","ref","didUpdate","getContainer","children","containerRef","initRef","current","_containerRef$current","_containerRef$current2","parentNode","removeChild","createPortal"],"mappings":"AAAA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,UAA5B,EAAwCC,mBAAxC,QAAmE,OAAnE;AACA,OAAOC,QAAP,MAAqB,WAArB;AACA,OAAOC,SAAP,MAAsB,iBAAtB;AACA,IAAIC,MAAM,GAAGJ,UAAU,CAAC,UAAUK,KAAV,EAAiBC,GAAjB,E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AAtB,EAAgCC,YAAY,CAACE,OAA7C,CAAvB,GAA+E,IAAtF;AACD,CA/BsB,CAAvB;AAgCA,eAAeR,MAAf","sourcesContent":["import { useRef, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport canUseDom from './Dom/canUseDom';\nvar Portal = forwardRef(function (props, ref) {\n  var didUpdate = props.didUpdate,\n      getContainer = props.getContainer,\n      children = props.children;\n  var containerRef = useRef(); // Ref return nothing, only for wrapper check exist\n\n  useImperativeHandle(ref, function () {\n    return {};\n  }); // Create container in client side with sync to avoid useEffect not get ref\n\n  var initRef = useRef(false);\n\n  if (!initRef.current && canUseDom()) {\n    containerRef.current = getContainer();\n    initRef.current = true;\n  } // [Legacy] Used by `rc-trigger`\n\n\n  useEffect(function () {\n    didUpdate === null || didUpdate === void 0 ? void 0 : didUpdate(props);\n  });\n  useEffect(function () {\n    return function () {\n      var _containerRef$current, _containerRef$current2;\n\n      // [Legacy] This should not be handle by Portal but parent PortalWrapper instead.\n      // Since some component use `Portal` directly, we have to keep the logic here.\n      (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : (_containerRef$current2 = _containerRef$current.parentNode) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.removeChild(containerRef.current);\n    };\n  }, []);\n  return containerRef.current ? ReactDOM.createPortal(children, containerRef.current) : null;\n});\nexport default Portal;"]},"metadata":{},"sourceType":"module"}