a782f8d4e906e6c3f826b3f9d4ebd63c.json
16.2 KB
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport * as React from 'react';\nimport findDOMNode from \"rc-util/es/Dom/findDOMNode\";\nimport toArray from \"rc-util/es/Children/toArray\";\nimport warning from \"rc-util/es/warning\";\nimport { composeRef, supportRef } from \"rc-util/es/ref\";\nimport ResizeObserver from 'resize-observer-polyfill';\nvar INTERNAL_PREFIX_KEY = 'rc-observer-key'; // Still need to be compatible with React 15, we use class component here\n\nvar ReactResizeObserver = /*#__PURE__*/function (_React$Component) {\n _inherits(ReactResizeObserver, _React$Component);\n\n var _super = _createSuper(ReactResizeObserver);\n\n function ReactResizeObserver() {\n var _this;\n\n _classCallCheck(this, ReactResizeObserver);\n\n _this = _super.apply(this, arguments);\n _this.resizeObserver = null;\n _this.childNode = null;\n _this.currentElement = null;\n _this.state = {\n width: 0,\n height: 0,\n offsetHeight: 0,\n offsetWidth: 0\n };\n\n _this.onResize = function (entries) {\n var onResize = _this.props.onResize;\n var target = entries[0].target;\n\n var _target$getBoundingCl = target.getBoundingClientRect(),\n width = _target$getBoundingCl.width,\n height = _target$getBoundingCl.height;\n\n var offsetWidth = target.offsetWidth,\n offsetHeight = target.offsetHeight;\n /**\n * Resize observer trigger when content size changed.\n * In most case we just care about element size,\n * let's use `boundary` instead of `contentRect` here to avoid shaking.\n */\n\n var fixedWidth = Math.floor(width);\n var fixedHeight = Math.floor(height);\n\n if (_this.state.width !== fixedWidth || _this.state.height !== fixedHeight || _this.state.offsetWidth !== offsetWidth || _this.state.offsetHeight !== offsetHeight) {\n var size = {\n width: fixedWidth,\n height: fixedHeight,\n offsetWidth: offsetWidth,\n offsetHeight: offsetHeight\n };\n\n _this.setState(size);\n\n if (onResize) {\n // defer the callback but not defer to next frame\n Promise.resolve().then(function () {\n onResize(_objectSpread(_objectSpread({}, size), {}, {\n offsetWidth: offsetWidth,\n offsetHeight: offsetHeight\n }));\n });\n }\n }\n };\n\n _this.setChildNode = function (node) {\n _this.childNode = node;\n };\n\n return _this;\n }\n\n _createClass(ReactResizeObserver, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.onComponentUpdated();\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.onComponentUpdated();\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n this.destroyObserver();\n }\n }, {\n key: \"onComponentUpdated\",\n value: function onComponentUpdated() {\n var disabled = this.props.disabled; // Unregister if disabled\n\n if (disabled) {\n this.destroyObserver();\n return;\n } // Unregister if element changed\n\n\n var element = findDOMNode(this.childNode || this);\n var elementChanged = element !== this.currentElement;\n\n if (elementChanged) {\n this.destroyObserver();\n this.currentElement = element;\n }\n\n if (!this.resizeObserver && element) {\n this.resizeObserver = new ResizeObserver(this.onResize);\n this.resizeObserver.observe(element);\n }\n }\n }, {\n key: \"destroyObserver\",\n value: function destroyObserver() {\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n this.resizeObserver = null;\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var children = this.props.children;\n var childNodes = toArray(children);\n\n if (childNodes.length > 1) {\n warning(false, 'Find more than one child node with `children` in ResizeObserver. Will only observe first one.');\n } else if (childNodes.length === 0) {\n warning(false, '`children` of ResizeObserver is empty. Nothing is in observe.');\n return null;\n }\n\n var childNode = childNodes[0];\n\n if (React.isValidElement(childNode) && supportRef(childNode)) {\n var ref = childNode.ref;\n childNodes[0] = React.cloneElement(childNode, {\n ref: composeRef(ref, this.setChildNode)\n });\n }\n\n return childNodes.length === 1 ? childNodes[0] : childNodes.map(function (node, index) {\n if (!React.isValidElement(node) || 'key' in node && node.key !== null) {\n return node;\n }\n\n return React.cloneElement(node, {\n key: \"\".concat(INTERNAL_PREFIX_KEY, \"-\").concat(index)\n });\n });\n }\n }]);\n\n return ReactResizeObserver;\n}(React.Component);\n\nReactResizeObserver.displayName = 'ResizeObserver';\nexport default ReactResizeObserver;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-resize-observer/es/index.js"],"names":["_objectSpread","_classCallCheck","_createClass","_inherits","_createSuper","React","findDOMNode","toArray","warning","composeRef","supportRef","ResizeObserver","INTERNAL_PREFIX_KEY","ReactResizeObserver","_React$Component","_super","_this","apply","arguments","resizeObserver","childNode","currentElement","state","width","height","offsetHeight","offsetWidth","onResize","entries","props","target","_target$getBoundingCl","getBoundingClientRect","fixedWidth","Math","floor","fixedHeight","size","setState","Promise","resolve","then","setChildNode","node","key","value","componentDidMount","onComponentUpdated","componentDidUpdate","componentWillUnmount","destroyObserver","disabled","element","elementChanged","observe","disconnect","render","children","childNodes","length","isValidElement","ref","cloneElement","map","index","concat","Component","displayName"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,0CAA1B;AACA,OAAOC,eAAP,MAA4B,2CAA5B;AACA,OAAOC,YAAP,MAAyB,wCAAzB;AACA,OAAOC,SAAP,MAAsB,qCAAtB;AACA,OAAOC,YAAP,MAAyB,wCAAzB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,WAAP,MAAwB,4BAAxB;AACA,OAAOC,OAAP,MAAoB,6BAApB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,SAASC,UAAT,EAAqBC,UAArB,QAAuC,gBAAvC;AACA,OAAOC,cAAP,MAA2B,0BAA3B;AACA,IAAIC,mBAAmB,GAAG,iBAA1B,C,CAA6C;;AAE7C,IAAIC,mBAAmB,GAAG,aAAa,UAAUC,gBAAV,EAA4B;AACjEX,EAAAA,SAAS,CAACU,mBAAD,EAAsBC,gBAAtB,CAAT;;AAEA,MAAIC,MAAM,GAAGX,YAAY,CAACS,mBAAD,CAA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DAAR,CAAP;AACA,eAAO,IAAP;AACD;;AAED,UAAIY,SAAS,GAAGsC,UAAU,CAAC,CAAD,CAA1B;;AAEA,UAAIrD,KAAK,CAACuD,cAAN,CAAqBxC,SAArB,KAAmCV,UAAU,CAACU,SAAD,CAAjD,EAA8D;AAC5D,YAAIyC,GAAG,GAAGzC,SAAS,CAACyC,GAApB;AACAH,QAAAA,UAAU,CAAC,CAAD,CAAV,GAAgBrD,KAAK,CAACyD,YAAN,CAAmB1C,SAAnB,EAA8B;AAC5CyC,UAAAA,GAAG,EAAEpD,UAAU,CAACoD,GAAD,EAAM,KAAKnB,YAAX;AAD6B,SAA9B,CAAhB;AAGD;;AAED,aAAOgB,UAAU,CAACC,MAAX,KAAsB,CAAtB,GAA0BD,UAAU,CAAC,CAAD,CAApC,GAA0CA,UAAU,CAACK,GAAX,CAAe,UAAUpB,IAAV,EAAgBqB,KAAhB,EAAuB;AACrF,YAAI,CAAC3D,KAAK,CAACuD,cAAN,CAAqBjB,IAArB,CAAD,IAA+B,SAASA,IAAT,IAAiBA,IAAI,CAACC,GAAL,KAAa,IAAjE,EAAuE;AACrE,iBAAOD,IAAP;AACD;;AAED,eAAOtC,KAAK,CAACyD,YAAN,CAAmBnB,IAAnB,EAAyB;AAC9BC,UAAAA,GAAG,EAAE,GAAGqB,MAAH,CAAUrD,mBAAV,EAA+B,GAA/B,EAAoCqD,MAApC,CAA2CD,KAA3C;AADyB,SAAzB,CAAP;AAGD,OARgD,CAAjD;AASD;AA/BA,GA/C+B,CAAtB,CAAZ;;AAiFA,SAAOnD,mBAAP;AACD,CAvJsC,CAuJrCR,KAAK,CAAC6D,SAvJ+B,CAAvC;;AAyJArD,mBAAmB,CAACsD,WAApB,GAAkC,gBAAlC;AACA,eAAetD,mBAAf","sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport * as React from 'react';\nimport findDOMNode from \"rc-util/es/Dom/findDOMNode\";\nimport toArray from \"rc-util/es/Children/toArray\";\nimport warning from \"rc-util/es/warning\";\nimport { composeRef, supportRef } from \"rc-util/es/ref\";\nimport ResizeObserver from 'resize-observer-polyfill';\nvar INTERNAL_PREFIX_KEY = 'rc-observer-key'; // Still need to be compatible with React 15, we use class component here\n\nvar ReactResizeObserver = /*#__PURE__*/function (_React$Component) {\n _inherits(ReactResizeObserver, _React$Component);\n\n var _super = _createSuper(ReactResizeObserver);\n\n function ReactResizeObserver() {\n var _this;\n\n _classCallCheck(this, ReactResizeObserver);\n\n _this = _super.apply(this, arguments);\n _this.resizeObserver = null;\n _this.childNode = null;\n _this.currentElement = null;\n _this.state = {\n width: 0,\n height: 0,\n offsetHeight: 0,\n offsetWidth: 0\n };\n\n _this.onResize = function (entries) {\n var onResize = _this.props.onResize;\n var target = entries[0].target;\n\n var _target$getBoundingCl = target.getBoundingClientRect(),\n width = _target$getBoundingCl.width,\n height = _target$getBoundingCl.height;\n\n var offsetWidth = target.offsetWidth,\n offsetHeight = target.offsetHeight;\n /**\n * Resize observer trigger when content size changed.\n * In most case we just care about element size,\n * let's use `boundary` instead of `contentRect` here to avoid shaking.\n */\n\n var fixedWidth = Math.floor(width);\n var fixedHeight = Math.floor(height);\n\n if (_this.state.width !== fixedWidth || _this.state.height !== fixedHeight || _this.state.offsetWidth !== offsetWidth || _this.state.offsetHeight !== offsetHeight) {\n var size = {\n width: fixedWidth,\n height: fixedHeight,\n offsetWidth: offsetWidth,\n offsetHeight: offsetHeight\n };\n\n _this.setState(size);\n\n if (onResize) {\n // defer the callback but not defer to next frame\n Promise.resolve().then(function () {\n onResize(_objectSpread(_objectSpread({}, size), {}, {\n offsetWidth: offsetWidth,\n offsetHeight: offsetHeight\n }));\n });\n }\n }\n };\n\n _this.setChildNode = function (node) {\n _this.childNode = node;\n };\n\n return _this;\n }\n\n _createClass(ReactResizeObserver, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.onComponentUpdated();\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.onComponentUpdated();\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n this.destroyObserver();\n }\n }, {\n key: \"onComponentUpdated\",\n value: function onComponentUpdated() {\n var disabled = this.props.disabled; // Unregister if disabled\n\n if (disabled) {\n this.destroyObserver();\n return;\n } // Unregister if element changed\n\n\n var element = findDOMNode(this.childNode || this);\n var elementChanged = element !== this.currentElement;\n\n if (elementChanged) {\n this.destroyObserver();\n this.currentElement = element;\n }\n\n if (!this.resizeObserver && element) {\n this.resizeObserver = new ResizeObserver(this.onResize);\n this.resizeObserver.observe(element);\n }\n }\n }, {\n key: \"destroyObserver\",\n value: function destroyObserver() {\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n this.resizeObserver = null;\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var children = this.props.children;\n var childNodes = toArray(children);\n\n if (childNodes.length > 1) {\n warning(false, 'Find more than one child node with `children` in ResizeObserver. Will only observe first one.');\n } else if (childNodes.length === 0) {\n warning(false, '`children` of ResizeObserver is empty. Nothing is in observe.');\n return null;\n }\n\n var childNode = childNodes[0];\n\n if (React.isValidElement(childNode) && supportRef(childNode)) {\n var ref = childNode.ref;\n childNodes[0] = React.cloneElement(childNode, {\n ref: composeRef(ref, this.setChildNode)\n });\n }\n\n return childNodes.length === 1 ? childNodes[0] : childNodes.map(function (node, index) {\n if (!React.isValidElement(node) || 'key' in node && node.key !== null) {\n return node;\n }\n\n return React.cloneElement(node, {\n key: \"\".concat(INTERNAL_PREFIX_KEY, \"-\").concat(index)\n });\n });\n }\n }]);\n\n return ReactResizeObserver;\n}(React.Component);\n\nReactResizeObserver.displayName = 'ResizeObserver';\nexport default ReactResizeObserver;"]},"metadata":{},"sourceType":"module"}