97448827bc2623c8620ebc18a5aa8b38.json
4.2 KB
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nexport default (function (stretch) {\n var _React$useState = React.useState({\n width: 0,\n height: 0\n }),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n targetSize = _React$useState2[0],\n setTargetSize = _React$useState2[1];\n\n function measureStretch(element) {\n setTargetSize({\n width: element.offsetWidth,\n height: element.offsetHeight\n });\n } // Merge stretch style\n\n\n var style = React.useMemo(function () {\n var sizeStyle = {};\n\n if (stretch) {\n var width = targetSize.width,\n height = targetSize.height; // Stretch with target\n\n if (stretch.indexOf('height') !== -1 && height) {\n sizeStyle.height = height;\n } else if (stretch.indexOf('minHeight') !== -1 && height) {\n sizeStyle.minHeight = height;\n }\n\n if (stretch.indexOf('width') !== -1 && width) {\n sizeStyle.width = width;\n } else if (stretch.indexOf('minWidth') !== -1 && width) {\n sizeStyle.minWidth = width;\n }\n }\n\n return sizeStyle;\n }, [stretch, targetSize]);\n return [style, measureStretch];\n});","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-trigger/es/Popup/useStretchStyle.js"],"names":["_slicedToArray","React","stretch","_React$useState","useState","width","height","_React$useState2","targetSize","setTargetSize","measureStretch","element","offsetWidth","offsetHeight","style","useMemo","sizeStyle","indexOf","minHeight","minWidth"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,0CAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,gBAAgB,UAAUC,OAAV,EAAmB;AACjC,MAAIC,eAAe,GAAGF,KAAK,CAACG,QAAN,CAAe;AACnCC,IAAAA,KAAK,EAAE,CAD4B;AAEnCC,IAAAA,MAAM,EAAE;AAF2B,GAAf,CAAtB;AAAA,MAIIC,gBAAgB,GAAGP,cAAc,CAACG,eAAD,EAAkB,CAAlB,CAJrC;AAAA,MAKIK,UAAU,GAAGD,gBAAgB,CAAC,CAAD,CAL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/esm/slicedToArray\";\nimport * as React from 'react';\nexport default (function (stretch) {\n var _React$useState = React.useState({\n width: 0,\n height: 0\n }),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n targetSize = _React$useState2[0],\n setTargetSize = _React$useState2[1];\n\n function measureStretch(element) {\n setTargetSize({\n width: element.offsetWidth,\n height: element.offsetHeight\n });\n } // Merge stretch style\n\n\n var style = React.useMemo(function () {\n var sizeStyle = {};\n\n if (stretch) {\n var width = targetSize.width,\n height = targetSize.height; // Stretch with target\n\n if (stretch.indexOf('height') !== -1 && height) {\n sizeStyle.height = height;\n } else if (stretch.indexOf('minHeight') !== -1 && height) {\n sizeStyle.minHeight = height;\n }\n\n if (stretch.indexOf('width') !== -1 && width) {\n sizeStyle.width = width;\n } else if (stretch.indexOf('minWidth') !== -1 && width) {\n sizeStyle.minWidth = width;\n }\n }\n\n return sizeStyle;\n }, [stretch, targetSize]);\n return [style, measureStretch];\n});"]},"metadata":{},"sourceType":"module"}