bd8fc2a22e5c50849a3533c819d7c7dd.json 8.99 KB
{"ast":null,"code":"function _slicedToArray(arr, i) {\n  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();\n}\n\nfunction _nonIterableRest() {\n  throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nfunction _unsupportedIterableToArray(o, minLen) {\n  if (!o) return;\n  if (typeof o === \"string\") return _arrayLikeToArray(o, minLen);\n  var n = Object.prototype.toString.call(o).slice(8, -1);\n  if (n === \"Object\" && o.constructor) n = o.constructor.name;\n  if (n === \"Map\" || n === \"Set\") return Array.from(o);\n  if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);\n}\n\nfunction _arrayLikeToArray(arr, len) {\n  if (len == null || len > arr.length) len = arr.length;\n\n  for (var i = 0, arr2 = new Array(len); i < len; i++) {\n    arr2[i] = arr[i];\n  }\n\n  return arr2;\n}\n\nfunction _iterableToArrayLimit(arr, i) {\n  if (typeof Symbol === \"undefined\" || !(Symbol.iterator in Object(arr))) return;\n  var _arr = [];\n  var _n = true;\n  var _d = false;\n  var _e = undefined;\n\n  try {\n    for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n      _arr.push(_s.value);\n\n      if (i && _arr.length === i) break;\n    }\n  } catch (err) {\n    _d = true;\n    _e = err;\n  } finally {\n    try {\n      if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n    } finally {\n      if (_d) throw _e;\n    }\n  }\n\n  return _arr;\n}\n\nfunction _arrayWithHoles(arr) {\n  if (Array.isArray(arr)) return arr;\n}\n\nimport * as React from 'react';\nimport { findListDiffIndex } from '../utils/algorithmUtil';\nexport default function useDiffItem(data, getKey, onDiff) {\n  var _React$useState = React.useState(data),\n      _React$useState2 = _slicedToArray(_React$useState, 2),\n      prevData = _React$useState2[0],\n      setPrevData = _React$useState2[1];\n\n  var _React$useState3 = React.useState(null),\n      _React$useState4 = _slicedToArray(_React$useState3, 2),\n      diffItem = _React$useState4[0],\n      setDiffItem = _React$useState4[1];\n\n  React.useEffect(function () {\n    var diff = findListDiffIndex(prevData || [], data || [], getKey);\n\n    if ((diff === null || diff === void 0 ? void 0 : diff.index) !== undefined) {\n      onDiff === null || onDiff === void 0 ? void 0 : onDiff(diff.index);\n      setDiffItem(data[diff.index]);\n    }\n\n    setPrevData(data);\n  }, [data]);\n  return [diffItem];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-virtual-list/es/hooks/useDiffItem.js"],"names":["_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","Symbol","iterator","_arr","_n","_d","_e","undefined","_i","_s","next","done","push","value","err","isArray","React","findListDiffIndex","useDiffItem","data","getKey","onDiff","_React$useState","useState","_React$useState2","prevData","setPrevData","_React$useState3","_React$useState4","diffItem","setDiffItem","useEffect","diff","index"],"mappings":"AAAA,SAASA,cAAT,CAAwBC,GAAxB,EAA6BC,CAA7B,EAAgC;AAAE,SAAOC,eAAe,CAACF,GAAD,CAAf,IAAwBG,qBAAqB,CAACH,GAAD,EAAMC,CAAN,CAA7C,IAAyDG,2BAA2B,CAACJ,GAAD,EAAMC,CAAN,CAApF,IAAgGI,gBAAgB,EAAvH;AAA4H;;AAE9J,SAASA,gBAAT,GAA4B;AAAE,QAAM,IAAIC,SAAJ,CAAc,2IAAd,CAAN;AAAmK;;AAEjM,SAASF,2BAAT,CAAqCG,CAArC,EAAwCC,MAAxC,EAAgD;AAAE,MAAI,CAACD,CAAL,EAAQ;AAAQ,MAAI,OAAOA,CAAP,KAAa,QAAjB,EAA2B,OAAOE,iBAAiB,CAACF,CAA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AC,CAAD,CAF/B;AAAA,MAGIE,WAAW,GAAGF,gBAAgB,CAAC,CAAD,CAHlC;;AAKA,MAAIG,gBAAgB,GAAGX,KAAK,CAACO,QAAN,CAAe,IAAf,CAAvB;AAAA,MACIK,gBAAgB,GAAGpD,cAAc,CAACmD,gBAAD,EAAmB,CAAnB,CADrC;AAAA,MAEIE,QAAQ,GAAGD,gBAAgB,CAAC,CAAD,CAF/B;AAAA,MAGIE,WAAW,GAAGF,gBAAgB,CAAC,CAAD,CAHlC;;AAKAZ,EAAAA,KAAK,CAACe,SAAN,CAAgB,YAAY;AAC1B,QAAIC,IAAI,GAAGf,iBAAiB,CAACQ,QAAQ,IAAI,EAAb,EAAiBN,IAAI,IAAI,EAAzB,EAA6BC,MAA7B,CAA5B;;AAEA,QAAI,CAACY,IAAI,KAAK,IAAT,IAAiBA,IAAI,KAAK,KAAK,CAA/B,GAAmC,KAAK,CAAxC,GAA4CA,IAAI,CAACC,KAAlD,MAA6D1B,SAAjE,EAA4E;AAC1Ec,MAAAA,MAAM,KAAK,IAAX,IAAmBA,MAAM,KAAK,KAAK,CAAnC,GAAuC,KAAK,CAA5C,GAAgDA,MAAM,CAACW,IAAI,CAACC,KAAN,CAAtD;AACAH,MAAAA,WAAW,CAACX,IAAI,CAACa,IAAI,CAACC,KAAN,CAAL,CAAX;AACD;;AAEDP,IAAAA,WAAW,CAACP,IAAD,CAAX;AACD,GATD,EASG,CAACA,IAAD,CATH;AAUA,SAAO,CAACU,QAAD,CAAP;AACD","sourcesContent":["function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _iterableToArrayLimit(arr, i) { if (typeof Symbol === \"undefined\" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nimport * as React from 'react';\nimport { findListDiffIndex } from '../utils/algorithmUtil';\nexport default function useDiffItem(data, getKey, onDiff) {\n  var _React$useState = React.useState(data),\n      _React$useState2 = _slicedToArray(_React$useState, 2),\n      prevData = _React$useState2[0],\n      setPrevData = _React$useState2[1];\n\n  var _React$useState3 = React.useState(null),\n      _React$useState4 = _slicedToArray(_React$useState3, 2),\n      diffItem = _React$useState4[0],\n      setDiffItem = _React$useState4[1];\n\n  React.useEffect(function () {\n    var diff = findListDiffIndex(prevData || [], data || [], getKey);\n\n    if ((diff === null || diff === void 0 ? void 0 : diff.index) !== undefined) {\n      onDiff === null || onDiff === void 0 ? void 0 : onDiff(diff.index);\n      setDiffItem(data[diff.index]);\n    }\n\n    setPrevData(data);\n  }, [data]);\n  return [diffItem];\n}"]},"metadata":{},"sourceType":"module"}