829178e1fc50e4a18a0c4104c9b7200b.json
4.17 KB
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { useMemo } from 'react';\nvar DEFAULT_SIZE = {\n width: 0,\n height: 0,\n left: 0,\n top: 0\n};\nexport default function useOffsets(tabs, tabSizes, holderScrollWidth) {\n return useMemo(function () {\n var _tabs$;\n\n var map = new Map();\n var lastOffset = tabSizes.get((_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : _tabs$.key) || DEFAULT_SIZE;\n var rightOffset = lastOffset.left + lastOffset.width;\n\n for (var i = 0; i < tabs.length; i += 1) {\n var key = tabs[i].key;\n var data = tabSizes.get(key); // Reuse last one when not exist yet\n\n if (!data) {\n var _tabs;\n\n data = tabSizes.get((_tabs = tabs[i - 1]) === null || _tabs === void 0 ? void 0 : _tabs.key) || DEFAULT_SIZE;\n }\n\n var entity = map.get(key) || _objectSpread({}, data); // Right\n\n\n entity.right = rightOffset - entity.left - entity.width; // Update entity\n\n map.set(key, entity);\n }\n\n return map;\n }, [tabs.map(function (tab) {\n return tab.key;\n }).join('_'), tabSizes, holderScrollWidth]);\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-tabs/es/hooks/useOffsets.js"],"names":["_objectSpread","useMemo","DEFAULT_SIZE","width","height","left","top","useOffsets","tabs","tabSizes","holderScrollWidth","_tabs$","map","Map","lastOffset","get","key","rightOffset","i","length","data","_tabs","entity","right","set","tab","join"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,0CAA1B;AACA,SAASC,OAAT,QAAwB,OAAxB;AACA,IAAIC,YAAY,GAAG;AACjBC,EAAAA,KAAK,EAAE,CADU;AAEjBC,EAAAA,MAAM,EAAE,CAFS;AAGjBC,EAAAA,IAAI,EAAE,CAHW;AAIjBC,EAAAA,GAAG,EAAE;AAJY,CAAnB;AAMA,eAAe,SAASC,UAAT,CAAoBC,IAApB,EAA0BC,QAA1B,EAAoCC,i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;AAED,WAAOV,GAAP;AACD,GA1Ba,EA0BX,CAACJ,IAAI,CAACI,GAAL,CAAS,UAAUa,GAAV,EAAe;AAC1B,WAAOA,GAAG,CAACT,GAAX;AACD,GAFG,EAEDU,IAFC,CAEI,GAFJ,CAAD,EAEWjB,QAFX,EAEqBC,iBAFrB,CA1BW,CAAd;AA6BD","sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { useMemo } from 'react';\nvar DEFAULT_SIZE = {\n width: 0,\n height: 0,\n left: 0,\n top: 0\n};\nexport default function useOffsets(tabs, tabSizes, holderScrollWidth) {\n return useMemo(function () {\n var _tabs$;\n\n var map = new Map();\n var lastOffset = tabSizes.get((_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : _tabs$.key) || DEFAULT_SIZE;\n var rightOffset = lastOffset.left + lastOffset.width;\n\n for (var i = 0; i < tabs.length; i += 1) {\n var key = tabs[i].key;\n var data = tabSizes.get(key); // Reuse last one when not exist yet\n\n if (!data) {\n var _tabs;\n\n data = tabSizes.get((_tabs = tabs[i - 1]) === null || _tabs === void 0 ? void 0 : _tabs.key) || DEFAULT_SIZE;\n }\n\n var entity = map.get(key) || _objectSpread({}, data); // Right\n\n\n entity.right = rightOffset - entity.left - entity.width; // Update entity\n\n map.set(key, entity);\n }\n\n return map;\n }, [tabs.map(function (tab) {\n return tab.key;\n }).join('_'), tabSizes, holderScrollWidth]);\n}"]},"metadata":{},"sourceType":"module"}