6566e94ae73d99f54ec5eb93319b9252.json
24.1 KB
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _typeof from \"@babel/runtime/helpers/typeof\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) {\n if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n }\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport ResizeObserver from 'rc-resize-observer';\nimport { composeRef } from \"rc-util/es/ref\";\nimport { ConfigContext } from '../config-provider';\nimport devWarning from '../_util/devWarning';\nimport { responsiveArray } from '../_util/responsiveObserve';\nimport useBreakpoint from '../grid/hooks/useBreakpoint';\nimport SizeContext from './SizeContext';\n\nvar InternalAvatar = function InternalAvatar(props, ref) {\n var _classNames, _classNames2;\n\n var groupSize = React.useContext(SizeContext);\n\n var _React$useState = React.useState(1),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n scale = _React$useState2[0],\n setScale = _React$useState2[1];\n\n var _React$useState3 = React.useState(false),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n mounted = _React$useState4[0],\n setMounted = _React$useState4[1];\n\n var _React$useState5 = React.useState(true),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n isImgExist = _React$useState6[0],\n setIsImgExist = _React$useState6[1];\n\n var avatarNodeRef = React.useRef();\n var avatarChildrenRef = React.useRef();\n var avatarNodeMergeRef = composeRef(ref, avatarNodeRef);\n\n var _React$useContext = React.useContext(ConfigContext),\n getPrefixCls = _React$useContext.getPrefixCls;\n\n var setScaleParam = function setScaleParam() {\n if (!avatarChildrenRef.current || !avatarNodeRef.current) {\n return;\n }\n\n var childrenWidth = avatarChildrenRef.current.offsetWidth; // offsetWidth avoid affecting be transform scale\n\n var nodeWidth = avatarNodeRef.current.offsetWidth; // denominator is 0 is no meaning\n\n if (childrenWidth !== 0 && nodeWidth !== 0) {\n var _props$gap = props.gap,\n gap = _props$gap === void 0 ? 4 : _props$gap;\n\n if (gap * 2 < nodeWidth) {\n setScale(nodeWidth - gap * 2 < childrenWidth ? (nodeWidth - gap * 2) / childrenWidth : 1);\n }\n }\n };\n\n React.useEffect(function () {\n setMounted(true);\n }, []);\n React.useEffect(function () {\n setIsImgExist(true);\n setScale(1);\n }, [props.src]);\n React.useEffect(function () {\n setScaleParam();\n }, [props.gap]);\n\n var handleImgLoadError = function handleImgLoadError() {\n var onError = props.onError;\n var errorFlag = onError ? onError() : undefined;\n\n if (errorFlag !== false) {\n setIsImgExist(false);\n }\n };\n\n var customizePrefixCls = props.prefixCls,\n shape = props.shape,\n customSize = props.size,\n src = props.src,\n srcSet = props.srcSet,\n icon = props.icon,\n className = props.className,\n alt = props.alt,\n draggable = props.draggable,\n children = props.children,\n others = __rest(props, [\"prefixCls\", \"shape\", \"size\", \"src\", \"srcSet\", \"icon\", \"className\", \"alt\", \"draggable\", \"children\"]);\n\n var size = customSize === 'default' ? groupSize : customSize;\n var screens = useBreakpoint();\n var responsiveSizeStyle = React.useMemo(function () {\n if (_typeof(size) !== 'object') {\n return {};\n }\n\n var currentBreakpoint = responsiveArray.find(function (screen) {\n return screens[screen];\n });\n var currentSize = size[currentBreakpoint];\n return currentSize ? {\n width: currentSize,\n height: currentSize,\n lineHeight: \"\".concat(currentSize, \"px\"),\n fontSize: icon ? currentSize / 2 : 18\n } : {};\n }, [screens, size]);\n devWarning(!(typeof icon === 'string' && icon.length > 2), 'Avatar', \"`icon` is using ReactNode instead of string naming in v4. Please check `\".concat(icon, \"` at https://ant.design/components/icon\"));\n var prefixCls = getPrefixCls('avatar', customizePrefixCls);\n var sizeCls = classNames((_classNames = {}, _defineProperty(_classNames, \"\".concat(prefixCls, \"-lg\"), size === 'large'), _defineProperty(_classNames, \"\".concat(prefixCls, \"-sm\"), size === 'small'), _classNames));\n var hasImageElement = /*#__PURE__*/React.isValidElement(src);\n var classString = classNames(prefixCls, sizeCls, (_classNames2 = {}, _defineProperty(_classNames2, \"\".concat(prefixCls, \"-\").concat(shape), shape), _defineProperty(_classNames2, \"\".concat(prefixCls, \"-image\"), hasImageElement || src && isImgExist), _defineProperty(_classNames2, \"\".concat(prefixCls, \"-icon\"), icon), _classNames2), className);\n var sizeStyle = typeof size === 'number' ? {\n width: size,\n height: size,\n lineHeight: \"\".concat(size, \"px\"),\n fontSize: icon ? size / 2 : 18\n } : {};\n var childrenToRender;\n\n if (typeof src === 'string' && isImgExist) {\n childrenToRender = /*#__PURE__*/React.createElement(\"img\", {\n src: src,\n draggable: draggable,\n srcSet: srcSet,\n onError: handleImgLoadError,\n alt: alt\n });\n } else if (hasImageElement) {\n childrenToRender = src;\n } else if (icon) {\n childrenToRender = icon;\n } else if (mounted || scale !== 1) {\n var transformString = \"scale(\".concat(scale, \") translateX(-50%)\");\n var childrenStyle = {\n msTransform: transformString,\n WebkitTransform: transformString,\n transform: transformString\n };\n var sizeChildrenStyle = typeof size === 'number' ? {\n lineHeight: \"\".concat(size, \"px\")\n } : {};\n childrenToRender = /*#__PURE__*/React.createElement(ResizeObserver, {\n onResize: setScaleParam\n }, /*#__PURE__*/React.createElement(\"span\", {\n className: \"\".concat(prefixCls, \"-string\"),\n ref: function ref(node) {\n avatarChildrenRef.current = node;\n },\n style: _extends(_extends({}, sizeChildrenStyle), childrenStyle)\n }, children));\n } else {\n childrenToRender = /*#__PURE__*/React.createElement(\"span\", {\n className: \"\".concat(prefixCls, \"-string\"),\n style: {\n opacity: 0\n },\n ref: function ref(node) {\n avatarChildrenRef.current = node;\n }\n }, children);\n } // The event is triggered twice from bubbling up the DOM tree.\n // see https://codesandbox.io/s/kind-snow-9lidz\n\n\n delete others.onError;\n delete others.gap;\n return /*#__PURE__*/React.createElement(\"span\", _extends({}, others, {\n style: _extends(_extends(_extends({}, sizeStyle), responsiveSizeStyle), others.style),\n className: classString,\n ref: avatarNodeMergeRef\n }), childrenToRender);\n};\n\nvar Avatar = /*#__PURE__*/React.forwardRef(InternalAvatar);\nAvatar.displayName = 'Avatar';\nAvatar.defaultProps = {\n shape: 'circle',\n size: 'default'\n};\nexport default Avatar;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/avatar/avatar.js"],"names":["_extends","_defineProperty","_typeof","_slicedToArray","__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","React","classNames","ResizeObserver","composeRef","ConfigContext","devWarning","responsiveArray","useBreakpoint","SizeContext","InternalAvatar","props","ref","_classNames","_classNames2","groupSize","useContext","_React$useState","useState","_React$useState2","scale","setScale","_React$useState3","_React$useState4","mounted","setMounted","_React$useState5","_React$useState6","isImgExist","setIsImgExist","avatarNodeRef","useRef","avatarChildrenRef","avatarNodeMergeRef","_React$useContext","getPrefixCls","setScaleParam","current","childrenWidth","offsetWidth","nodeWidth","_props$gap","gap","useEffect","src","handleImgLoadError","onError","errorFlag","undefined","customizePrefixCls","prefixCls","shape","customSize","size","srcSet","icon","className","alt","draggable","children","others","screens","responsiveSizeStyle","useMemo","currentBreakpoint","find","screen","currentSize","width","height","lineHeight","concat","fontSize","sizeCls","hasImageElement","isValidElement","classString","sizeStyle","childrenToRender","createElement","transformString","childrenStyle","msTransform","WebkitTransform","transform","sizeChildrenStyle","onResize","node","style","opacity","Avatar","forwardRef","displayName","defaultProps"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,gCAArB;AACA,OAAOC,eAAP,MAA4B,uCAA5B;AACA,OAAOC,OAAP,MAAoB,+BAApB;AACA,OAAOC,cAAP,MAA2B,sCAA3B;;AAEA,IAAIC,MAAM,GAAG,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B,GAA4BkD,IAA5B;AACD;AAPyD,KAA5B,EAQ7B5B,QAR6B,CAAhC;AASD,GAtJsD,CAsJrD;AACF;;;AAGA,SAAOC,MAAM,CAACd,OAAd;AACA,SAAOc,MAAM,CAAClB,GAAd;AACA,SAAO,aAAazC,KAAK,CAAC8E,aAAN,CAAoB,MAApB,EAA4BhG,QAAQ,CAAC,EAAD,EAAK6E,MAAL,EAAa;AACnE4B,IAAAA,KAAK,EAAEzG,QAAQ,CAACA,QAAQ,CAACA,QAAQ,CAAC,EAAD,EAAK8F,SAAL,CAAT,EAA0Bf,mBAA1B,CAAT,EAAyDF,MAAM,CAAC4B,KAAhE,CADoD;AAEnEhC,IAAAA,SAAS,EAAEoB,WAFwD;AAGnEhE,IAAAA,GAAG,EAAEqB;AAH8D,GAAb,CAApC,EAIhB6C,gBAJgB,CAApB;AAKD,CAjKD;;AAmKA,IAAIY,MAAM,GAAG,aAAazF,KAAK,CAAC0F,UAAN,CAAiBjF,cAAjB,CAA1B;AACAgF,MAAM,CAACE,WAAP,GAAqB,QAArB;AACAF,MAAM,CAACG,YAAP,GAAsB;AACpB1C,EAAAA,KAAK,EAAE,QADa;AAEpBE,EAAAA,IAAI,EAAE;AAFc,CAAtB;AAIA,eAAeqC,MAAf","sourcesContent":["import _extends from \"@babel/runtime/helpers/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _typeof from \"@babel/runtime/helpers/typeof\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) {\n if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n }\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport ResizeObserver from 'rc-resize-observer';\nimport { composeRef } from \"rc-util/es/ref\";\nimport { ConfigContext } from '../config-provider';\nimport devWarning from '../_util/devWarning';\nimport { responsiveArray } from '../_util/responsiveObserve';\nimport useBreakpoint from '../grid/hooks/useBreakpoint';\nimport SizeContext from './SizeContext';\n\nvar InternalAvatar = function InternalAvatar(props, ref) {\n var _classNames, _classNames2;\n\n var groupSize = React.useContext(SizeContext);\n\n var _React$useState = React.useState(1),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n scale = _React$useState2[0],\n setScale = _React$useState2[1];\n\n var _React$useState3 = React.useState(false),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n mounted = _React$useState4[0],\n setMounted = _React$useState4[1];\n\n var _React$useState5 = React.useState(true),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n isImgExist = _React$useState6[0],\n setIsImgExist = _React$useState6[1];\n\n var avatarNodeRef = React.useRef();\n var avatarChildrenRef = React.useRef();\n var avatarNodeMergeRef = composeRef(ref, avatarNodeRef);\n\n var _React$useContext = React.useContext(ConfigContext),\n getPrefixCls = _React$useContext.getPrefixCls;\n\n var setScaleParam = function setScaleParam() {\n if (!avatarChildrenRef.current || !avatarNodeRef.current) {\n return;\n }\n\n var childrenWidth = avatarChildrenRef.current.offsetWidth; // offsetWidth avoid affecting be transform scale\n\n var nodeWidth = avatarNodeRef.current.offsetWidth; // denominator is 0 is no meaning\n\n if (childrenWidth !== 0 && nodeWidth !== 0) {\n var _props$gap = props.gap,\n gap = _props$gap === void 0 ? 4 : _props$gap;\n\n if (gap * 2 < nodeWidth) {\n setScale(nodeWidth - gap * 2 < childrenWidth ? (nodeWidth - gap * 2) / childrenWidth : 1);\n }\n }\n };\n\n React.useEffect(function () {\n setMounted(true);\n }, []);\n React.useEffect(function () {\n setIsImgExist(true);\n setScale(1);\n }, [props.src]);\n React.useEffect(function () {\n setScaleParam();\n }, [props.gap]);\n\n var handleImgLoadError = function handleImgLoadError() {\n var onError = props.onError;\n var errorFlag = onError ? onError() : undefined;\n\n if (errorFlag !== false) {\n setIsImgExist(false);\n }\n };\n\n var customizePrefixCls = props.prefixCls,\n shape = props.shape,\n customSize = props.size,\n src = props.src,\n srcSet = props.srcSet,\n icon = props.icon,\n className = props.className,\n alt = props.alt,\n draggable = props.draggable,\n children = props.children,\n others = __rest(props, [\"prefixCls\", \"shape\", \"size\", \"src\", \"srcSet\", \"icon\", \"className\", \"alt\", \"draggable\", \"children\"]);\n\n var size = customSize === 'default' ? groupSize : customSize;\n var screens = useBreakpoint();\n var responsiveSizeStyle = React.useMemo(function () {\n if (_typeof(size) !== 'object') {\n return {};\n }\n\n var currentBreakpoint = responsiveArray.find(function (screen) {\n return screens[screen];\n });\n var currentSize = size[currentBreakpoint];\n return currentSize ? {\n width: currentSize,\n height: currentSize,\n lineHeight: \"\".concat(currentSize, \"px\"),\n fontSize: icon ? currentSize / 2 : 18\n } : {};\n }, [screens, size]);\n devWarning(!(typeof icon === 'string' && icon.length > 2), 'Avatar', \"`icon` is using ReactNode instead of string naming in v4. Please check `\".concat(icon, \"` at https://ant.design/components/icon\"));\n var prefixCls = getPrefixCls('avatar', customizePrefixCls);\n var sizeCls = classNames((_classNames = {}, _defineProperty(_classNames, \"\".concat(prefixCls, \"-lg\"), size === 'large'), _defineProperty(_classNames, \"\".concat(prefixCls, \"-sm\"), size === 'small'), _classNames));\n var hasImageElement = /*#__PURE__*/React.isValidElement(src);\n var classString = classNames(prefixCls, sizeCls, (_classNames2 = {}, _defineProperty(_classNames2, \"\".concat(prefixCls, \"-\").concat(shape), shape), _defineProperty(_classNames2, \"\".concat(prefixCls, \"-image\"), hasImageElement || src && isImgExist), _defineProperty(_classNames2, \"\".concat(prefixCls, \"-icon\"), icon), _classNames2), className);\n var sizeStyle = typeof size === 'number' ? {\n width: size,\n height: size,\n lineHeight: \"\".concat(size, \"px\"),\n fontSize: icon ? size / 2 : 18\n } : {};\n var childrenToRender;\n\n if (typeof src === 'string' && isImgExist) {\n childrenToRender = /*#__PURE__*/React.createElement(\"img\", {\n src: src,\n draggable: draggable,\n srcSet: srcSet,\n onError: handleImgLoadError,\n alt: alt\n });\n } else if (hasImageElement) {\n childrenToRender = src;\n } else if (icon) {\n childrenToRender = icon;\n } else if (mounted || scale !== 1) {\n var transformString = \"scale(\".concat(scale, \") translateX(-50%)\");\n var childrenStyle = {\n msTransform: transformString,\n WebkitTransform: transformString,\n transform: transformString\n };\n var sizeChildrenStyle = typeof size === 'number' ? {\n lineHeight: \"\".concat(size, \"px\")\n } : {};\n childrenToRender = /*#__PURE__*/React.createElement(ResizeObserver, {\n onResize: setScaleParam\n }, /*#__PURE__*/React.createElement(\"span\", {\n className: \"\".concat(prefixCls, \"-string\"),\n ref: function ref(node) {\n avatarChildrenRef.current = node;\n },\n style: _extends(_extends({}, sizeChildrenStyle), childrenStyle)\n }, children));\n } else {\n childrenToRender = /*#__PURE__*/React.createElement(\"span\", {\n className: \"\".concat(prefixCls, \"-string\"),\n style: {\n opacity: 0\n },\n ref: function ref(node) {\n avatarChildrenRef.current = node;\n }\n }, children);\n } // The event is triggered twice from bubbling up the DOM tree.\n // see https://codesandbox.io/s/kind-snow-9lidz\n\n\n delete others.onError;\n delete others.gap;\n return /*#__PURE__*/React.createElement(\"span\", _extends({}, others, {\n style: _extends(_extends(_extends({}, sizeStyle), responsiveSizeStyle), others.style),\n className: classString,\n ref: avatarNodeMergeRef\n }), childrenToRender);\n};\n\nvar Avatar = /*#__PURE__*/React.forwardRef(InternalAvatar);\nAvatar.displayName = 'Avatar';\nAvatar.defaultProps = {\n shape: 'circle',\n size: 'default'\n};\nexport default Avatar;"]},"metadata":{},"sourceType":"module"}