0ef62ceb521f42776478e2c62e529964.json
3.19 KB
{"ast":null,"code":"import * as React from 'react';\n/**\n * Locker return cached mark.\n * If set to `true`, will return `true` in a short time even if set `false`.\n * If set to `false` and then set to `true`, will change to `true`.\n * And after time duration, it will back to `null` automatically.\n */\n\nexport default function useLock() {\n var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 250;\n var lockRef = React.useRef(null);\n var timeoutRef = React.useRef(null); // Clean up\n\n React.useEffect(function () {\n return function () {\n window.clearTimeout(timeoutRef.current);\n };\n }, []);\n\n function doLock(locked) {\n if (locked || lockRef.current === null) {\n lockRef.current = locked;\n }\n\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = window.setTimeout(function () {\n lockRef.current = null;\n }, duration);\n }\n\n return [function () {\n return lockRef.current;\n }, doLock];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-select/es/hooks/useLock.js"],"names":["React","useLock","duration","arguments","length","undefined","lockRef","useRef","timeoutRef","useEffect","window","clearTimeout","current","doLock","locked","setTimeout"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASC,OAAT,GAAmB;AAChC,MAAIC,QAAQ,GAAGC,SAAS,CAACC,MAAV,GAAmB,CAAnB,IAAwBD,SAAS,CAAC,CAAD,CAAT,KAAiBE,SAAzC,GAAqDF,SAAS,CAAC,CAAD,CAA9D,GAAoE,GAAnF;AACA,MAAIG,OAAO,GAAGN,KAAK,CAACO,MAAN,CAAa,IAAb,CAAd;AACA,MAAIC,UAAU,GAAGR,KAAK,CAACO,MAAN,CAAa,IAAb,CAAjB,CAHgC,CAGK;;AAErCP,EAAAA,KAAK,CAACS,SAAN,CAAgB,YAAY;AAC1B,WAAO,YAAY;AACjBC,MAAAA,MAAM,CAACC,YAAP,CAAoBH,UAAU,CAACI,OAA/B;AACD,KAFD;AAGD,GAJD,EAIG,EAJH;;AAMA,WAASC,MAAT,CAAgBC,MAAhB,EAAwB;AACtB,QAAIA,MAAM,IAAIR,OAAO,CAACM,OAAR,KAAoB,IAAlC,EAAwC;AACtCN,MAAAA,OAAO,CAACM,OAAR,GAAkBE,MAAlB;AACD;;AAEDJ,IAAAA,MAAM,CAACC,YAAP,CAAoBH,UAAU,CAACI,OAA/B;AACAJ,IAAAA,UAAU,CAACI,OAAX,GAAqBF,MAAM,CAACK,UAAP,CAAkB,YAAY;AACjDT,MAAAA,OAAO,CAACM,OAAR,GAAkB,IAAlB;AACD,KAFoB,EAElBV,QAFkB,CAArB;AAGD;;AAED,SAAO,CAAC,YAAY;AAClB,WAAOI,OAAO,CAACM,OAAf;AACD,GAFM,EAEJC,MAFI,CAAP;AAGD","sourcesContent":["import * as React from 'react';\n/**\n * Locker return cached mark.\n * If set to `true`, will return `true` in a short time even if set `false`.\n * If set to `false` and then set to `true`, will change to `true`.\n * And after time duration, it will back to `null` automatically.\n */\n\nexport default function useLock() {\n var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 250;\n var lockRef = React.useRef(null);\n var timeoutRef = React.useRef(null); // Clean up\n\n React.useEffect(function () {\n return function () {\n window.clearTimeout(timeoutRef.current);\n };\n }, []);\n\n function doLock(locked) {\n if (locked || lockRef.current === null) {\n lockRef.current = locked;\n }\n\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = window.setTimeout(function () {\n lockRef.current = null;\n }, duration);\n }\n\n return [function () {\n return lockRef.current;\n }, doLock];\n}"]},"metadata":{},"sourceType":"module"}