9b0506d4e1565b0615ecc9ca583b2e51.json 3.85 KB
{"ast":null,"code":"import _typeof from \"@babel/runtime/helpers/typeof\";\nimport * as React from 'react';\nexport default function useLazyKVMap(data, childrenColumnName, getRowKey) {\n  var mapCacheRef = React.useRef({});\n\n  function getRecordByKey(key) {\n    if (!mapCacheRef.current || mapCacheRef.current.data !== data || mapCacheRef.current.childrenColumnName !== childrenColumnName || mapCacheRef.current.getRowKey !== getRowKey) {\n      /* eslint-disable no-inner-declarations */\n      var dig = function dig(records) {\n        records.forEach(function (record, index) {\n          var rowKey = getRowKey(record, index);\n          kvMap.set(rowKey, record);\n\n          if (record && _typeof(record) === 'object' && childrenColumnName in record) {\n            dig(record[childrenColumnName] || []);\n          }\n        });\n      };\n      /* eslint-enable */\n\n\n      var kvMap = new Map();\n      dig(data);\n      mapCacheRef.current = {\n        data: data,\n        childrenColumnName: childrenColumnName,\n        kvMap: kvMap,\n        getRowKey: getRowKey\n      };\n    }\n\n    return mapCacheRef.current.kvMap.get(key);\n  }\n\n  return [getRecordByKey];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/table/hooks/useLazyKVMap.js"],"names":["_typeof","React","useLazyKVMap","data","childrenColumnName","getRowKey","mapCacheRef","useRef","getRecordByKey","key","current","dig","records","forEach","record","index","rowKey","kvMap","set","Map","get"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,+BAApB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,eAAe,SAASC,YAAT,CAAsBC,IAAtB,EAA4BC,kBAA5B,EAAgDC,SAAhD,EAA2D;AACxE,MAAIC,WAAW,GAAGL,KAAK,CAACM,MAAN,CAAa,EAAb,CAAlB;;AAEA,WAASC,cAAT,CAAwBC,GAAxB,EAA6B;AAC3B,QAAI,CAACH,WAAW,CAACI,OAAb,IAAwBJ,WAAW,CAACI,OAAZ,CAAoBP,IAApB,KAA6BA,IAArD,IAA6DG,WAAW,CAACI,OAAZ,CAAoBN,kBAApB,KAA2CA,kBAAxG,IAA8HE,WAAW,CAACI,OAAZ,CAAoBL,SAApB,KAAkCA,SAApK,EAA+K;AAC7K;AACA,UAAIM,GAAG,GAAG,SAASA,GAAT,CAAaC,OAAb,EAAsB;AAC9BA,QAAAA,OAAO,CAACC,OAAR,CAAgB,UAAUC,MAAV,EAAkBC,KAAlB,EAAyB;AACvC,cAAIC,MAAM,GAAGX,SAAS,CAACS,MAAD,EAASC,KAAT,CAAtB;AACAE,UAAAA,KAAK,CAACC,GAAN,CAAUF,MAAV,EAAkBF,MAAlB;;AAEA,cAAIA,MAAM,IAAId,OAAO,CAACc,MAAD,CAAP,KAAoB,QAA9B,IAA0CV,kBAAkB,IAAIU,MAApE,EAA4E;AAC1EH,YAAAA,GAAG,CAACG,MAAM,CAACV,kBAAD,CAAN,IAA8B,EAA/B,CAAH;AACD;AACF,SAPD;AAQD,OATD;AAUA;;;AAGA,UAAIa,KAAK,GAAG,IAAIE,GAAJ,EAAZ;AACAR,MAAAA,GAAG,CAACR,IAAD,CAAH;AACAG,MAAAA,WAAW,CAACI,OAAZ,GAAsB;AACpBP,QAAAA,IAAI,EAAEA,IADc;AAEpBC,QAAAA,kBAAkB,EAAEA,kBAFA;AAGpBa,QAAAA,KAAK,EAAEA,KAHa;AAIpBZ,QAAAA,SAAS,EAAEA;AAJS,OAAtB;AAMD;;AAED,WAAOC,WAAW,CAACI,OAAZ,CAAoBO,KAApB,CAA0BG,GAA1B,CAA8BX,GAA9B,CAAP;AACD;;AAED,SAAO,CAACD,cAAD,CAAP;AACD","sourcesContent":["import _typeof from \"@babel/runtime/helpers/typeof\";\nimport * as React from 'react';\nexport default function useLazyKVMap(data, childrenColumnName, getRowKey) {\n  var mapCacheRef = React.useRef({});\n\n  function getRecordByKey(key) {\n    if (!mapCacheRef.current || mapCacheRef.current.data !== data || mapCacheRef.current.childrenColumnName !== childrenColumnName || mapCacheRef.current.getRowKey !== getRowKey) {\n      /* eslint-disable no-inner-declarations */\n      var dig = function dig(records) {\n        records.forEach(function (record, index) {\n          var rowKey = getRowKey(record, index);\n          kvMap.set(rowKey, record);\n\n          if (record && _typeof(record) === 'object' && childrenColumnName in record) {\n            dig(record[childrenColumnName] || []);\n          }\n        });\n      };\n      /* eslint-enable */\n\n\n      var kvMap = new Map();\n      dig(data);\n      mapCacheRef.current = {\n        data: data,\n        childrenColumnName: childrenColumnName,\n        kvMap: kvMap,\n        getRowKey: getRowKey\n      };\n    }\n\n    return mapCacheRef.current.kvMap.get(key);\n  }\n\n  return [getRecordByKey];\n}"]},"metadata":{},"sourceType":"module"}