PromoCursed/node_modules/.cache/babel-loader/b4f3b4e24bb899f717275259f981d9367d5c334508801a579fe5a3470e7c6cc3.json

1 line
5.5 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useEffect, useRef, useState } from 'react';\nimport { isImageValid } from \"../util\";\nexport default function useStatus(_ref) {\n var src = _ref.src,\n isCustomPlaceholder = _ref.isCustomPlaceholder,\n fallback = _ref.fallback;\n var _useState = useState(isCustomPlaceholder ? 'loading' : 'normal'),\n _useState2 = _slicedToArray(_useState, 2),\n status = _useState2[0],\n setStatus = _useState2[1];\n var isLoaded = useRef(false);\n var isError = status === 'error';\n\n // https://github.com/react-component/image/pull/187\n useEffect(function () {\n var isCurrentSrc = true;\n isImageValid(src).then(function (isValid) {\n // https://github.com/ant-design/ant-design/issues/44948\n // If src changes, the previous setStatus should not be triggered\n if (!isValid && isCurrentSrc) {\n setStatus('error');\n }\n });\n return function () {\n isCurrentSrc = false;\n };\n }, [src]);\n useEffect(function () {\n if (isCustomPlaceholder && !isLoaded.current) {\n setStatus('loading');\n } else if (isError) {\n setStatus('normal');\n }\n }, [src]);\n var onLoad = function onLoad() {\n setStatus('normal');\n };\n var getImgRef = function getImgRef(img) {\n isLoaded.current = false;\n if (status === 'loading' && img !== null && img !== void 0 && img.complete && (img.naturalWidth || img.naturalHeight)) {\n isLoaded.current = true;\n onLoad();\n }\n };\n var srcAndOnload = isError && fallback ? {\n src: fallback\n } : {\n onLoad: onLoad,\n src: src\n };\n return [getImgRef, srcAndOnload, status];\n}","map":{"version":3,"names":["_slicedToArray","useEffect","useRef","useState","isImageValid","useStatus","_ref","src","isCustomPlaceholder","fallback","_useState","_useState2","status","setStatus","isLoaded","isError","isCurrentSrc","then","isValid","current","onLoad","getImgRef","img","complete","naturalWidth","naturalHeight","srcAndOnload"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/rc-image/es/hooks/useStatus.js"],"sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useEffect, useRef, useState } from 'react';\nimport { isImageValid } from \"../util\";\nexport default function useStatus(_ref) {\n var src = _ref.src,\n isCustomPlaceholder = _ref.isCustomPlaceholder,\n fallback = _ref.fallback;\n var _useState = useState(isCustomPlaceholder ? 'loading' : 'normal'),\n _useState2 = _slicedToArray(_useState, 2),\n status = _useState2[0],\n setStatus = _useState2[1];\n var isLoaded = useRef(false);\n var isError = status === 'error';\n\n // https://github.com/react-component/image/pull/187\n useEffect(function () {\n var isCurrentSrc = true;\n isImageValid(src).then(function (isValid) {\n // https://github.com/ant-design/ant-design/issues/44948\n // If src changes, the previous setStatus should not be triggered\n if (!isValid && isCurrentSrc) {\n setStatus('error');\n }\n });\n return function () {\n isCurrentSrc = false;\n };\n }, [src]);\n useEffect(function () {\n if (isCustomPlaceholder && !isLoaded.current) {\n setStatus('loading');\n } else if (isError) {\n setStatus('normal');\n }\n }, [src]);\n var onLoad = function onLoad() {\n setStatus('normal');\n };\n var getImgRef = function getImgRef(img) {\n isLoaded.current = false;\n if (status === 'loading' && img !== null && img !== void 0 && img.complete && (img.naturalWidth || img.naturalHeight)) {\n isLoaded.current = true;\n onLoad();\n }\n };\n var srcAndOnload = isError && fallback ? {\n src: fallback\n } : {\n onLoad: onLoad,\n src: src\n };\n return [getImgRef, srcAndOnload, status];\n}"],"mappings":"AAAA,OAAOA,cAAc,MAAM,0CAA0C;AACrE,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnD,SAASC,YAAY,QAAQ,SAAS;AACtC,eAAe,SAASC,SAASA,CAACC,IAAI,EAAE;EACtC,IAAIC,GAAG,GAAGD,IA