PromoCursed/node_modules/.cache/babel-loader/5ab2b3c16ed421d2fb5a91700a36172b67fdf4e95cb4fac90117585e97874cbd.json
2024-08-20 23:25:37 +04:00

1 line
6.7 KiB
JSON

{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport { COMMON_PROPS } from \"../common\";\n/**\n * Merge props provided `items` or context collected images\n */\nexport default function usePreviewItems(items) {\n // Context collection image data\n var _React$useState = React.useState({}),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n images = _React$useState2[0],\n setImages = _React$useState2[1];\n var registerImage = React.useCallback(function (id, data) {\n setImages(function (imgs) {\n return _objectSpread(_objectSpread({}, imgs), {}, _defineProperty({}, id, data));\n });\n return function () {\n setImages(function (imgs) {\n var cloneImgs = _objectSpread({}, imgs);\n delete cloneImgs[id];\n return cloneImgs;\n });\n };\n }, []);\n\n // items\n var mergedItems = React.useMemo(function () {\n // use `items` first\n if (items) {\n return items.map(function (item) {\n if (typeof item === 'string') {\n return {\n data: {\n src: item\n }\n };\n }\n var data = {};\n Object.keys(item).forEach(function (key) {\n if (['src'].concat(_toConsumableArray(COMMON_PROPS)).includes(key)) {\n data[key] = item[key];\n }\n });\n return {\n data: data\n };\n });\n }\n\n // use registered images secondly\n return Object.keys(images).reduce(function (total, id) {\n var _images$id = images[id],\n canPreview = _images$id.canPreview,\n data = _images$id.data;\n if (canPreview) {\n total.push({\n data: data,\n id: id\n });\n }\n return total;\n }, []);\n }, [items, images]);\n return [mergedItems, registerImage, !!items];\n}","map":{"version":3,"names":["_toConsumableArray","_defineProperty","_objectSpread","_slicedToArray","React","COMMON_PROPS","usePreviewItems","items","_React$useState","useState","_React$useState2","images","setImages","registerImage","useCallback","id","data","imgs","cloneImgs","mergedItems","useMemo","map","item","src","Object","keys","forEach","key","concat","includes","reduce","total","_images$id","canPreview","push"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/rc-image/es/hooks/usePreviewItems.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport { COMMON_PROPS } from \"../common\";\n/**\n * Merge props provided `items` or context collected images\n */\nexport default function usePreviewItems(items) {\n // Context collection image data\n var _React$useState = React.useState({}),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n images = _React$useState2[0],\n setImages = _React$useState2[1];\n var registerImage = React.useCallback(function (id, data) {\n setImages(function (imgs) {\n return _objectSpread(_objectSpread({}, imgs), {}, _defineProperty({}, id, data));\n });\n return function () {\n setImages(function (imgs) {\n var cloneImgs = _objectSpread({}, imgs);\n delete cloneImgs[id];\n return cloneImgs;\n });\n };\n }, []);\n\n // items\n var mergedItems = React.useMemo(function () {\n // use `items` first\n if (items) {\n return items.map(function (item) {\n if (typeof item === 'string') {\n return {\n data: {\n src: item\n }\n };\n }\n var data = {};\n Object.keys(item).forEach(function (key) {\n if (['src'].concat(_toConsumableArray(COMMON_PROPS)).includes(key)) {\n data[key] = item[key];\n }\n });\n return {\n data: data\n };\n });\n }\n\n // use registered images secondly\n return Object.keys(images).reduce(function (total, id) {\n var _images$id = images[id],\n canPreview = _images$id.canPreview,\n data = _images$id.data;\n if (canPreview) {\n total.push({\n data: data,\n id: id\n });\n }\n return total;\n }, []);\n }, [items, images]);\n return [mergedItems, registerImage, !!items];\n}"],"mappings":"AAAA,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,OAAOC,eAAe,MAAM,2CAA2C;AACvE,OAAOC,aAAa,MAAM,0CAA0C;AACpE,OAAOC,cAAc,MAAM,0CAA0C;A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