b0f736ee9850518d988a9096f6ed07fe.json 3.03 KB
{"ast":null,"code":"import * as React from 'react';\nexport default function useSelectTriggerControl(elements, open, triggerOpen) {\n  var propsRef = React.useRef(null);\n  propsRef.current = {\n    elements: elements.filter(function (e) {\n      return e;\n    }),\n    open: open,\n    triggerOpen: triggerOpen\n  };\n  React.useEffect(function () {\n    function onGlobalMouseDown(event) {\n      var target = event.target;\n\n      if (propsRef.current.open && propsRef.current.elements.every(function (element) {\n        return !element.contains(target) && element !== target;\n      })) {\n        // Should trigger close\n        propsRef.current.triggerOpen(false);\n      }\n    }\n\n    window.addEventListener('mousedown', onGlobalMouseDown);\n    return function () {\n      return window.removeEventListener('mousedown', onGlobalMouseDown);\n    };\n  }, []);\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-select/es/hooks/useSelectTriggerControl.js"],"names":["React","useSelectTriggerControl","elements","open","triggerOpen","propsRef","useRef","current","filter","e","useEffect","onGlobalMouseDown","event","target","every","element","contains","window","addEventListener","removeEventListener"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,eAAe,SAASC,uBAAT,CAAiCC,QAAjC,EAA2CC,IAA3C,EAAiDC,WAAjD,EAA8D;AAC3E,MAAIC,QAAQ,GAAGL,KAAK,CAACM,MAAN,CAAa,IAAb,CAAf;AACAD,EAAAA,QAAQ,CAACE,OAAT,GAAmB;AACjBL,IAAAA,QAAQ,EAAEA,QAAQ,CAACM,MAAT,CAAgB,UAAUC,CAAV,EAAa;AACrC,aAAOA,CAAP;AACD,KAFS,CADO;AAIjBN,IAAAA,IAAI,EAAEA,IAJW;AAKjBC,IAAAA,WAAW,EAAEA;AALI,GAAnB;AAOAJ,EAAAA,KAAK,CAACU,SAAN,CAAgB,YAAY;AAC1B,aAASC,iBAAT,CAA2BC,KAA3B,EAAkC;AAChC,UAAIC,MAAM,GAAGD,KAAK,CAACC,MAAnB;;AAEA,UAAIR,QAAQ,CAACE,OAAT,CAAiBJ,IAAjB,IAAyBE,QAAQ,CAACE,OAAT,CAAiBL,QAAjB,CAA0BY,KAA1B,CAAgC,UAAUC,OAAV,EAAmB;AAC9E,eAAO,CAACA,OAAO,CAACC,QAAR,CAAiBH,MAAjB,CAAD,IAA6BE,OAAO,KAAKF,MAAhD;AACD,OAF4B,CAA7B,EAEI;AACF;AACAR,QAAAA,QAAQ,CAACE,OAAT,CAAiBH,WAAjB,CAA6B,KAA7B;AACD;AACF;;AAEDa,IAAAA,MAAM,CAACC,gBAAP,CAAwB,WAAxB,EAAqCP,iBAArC;AACA,WAAO,YAAY;AACjB,aAAOM,MAAM,CAACE,mBAAP,CAA2B,WAA3B,EAAwCR,iBAAxC,CAAP;AACD,KAFD;AAGD,GAhBD,EAgBG,EAhBH;AAiBD","sourcesContent":["import * as React from 'react';\nexport default function useSelectTriggerControl(elements, open, triggerOpen) {\n  var propsRef = React.useRef(null);\n  propsRef.current = {\n    elements: elements.filter(function (e) {\n      return e;\n    }),\n    open: open,\n    triggerOpen: triggerOpen\n  };\n  React.useEffect(function () {\n    function onGlobalMouseDown(event) {\n      var target = event.target;\n\n      if (propsRef.current.open && propsRef.current.elements.every(function (element) {\n        return !element.contains(target) && element !== target;\n      })) {\n        // Should trigger close\n        propsRef.current.triggerOpen(false);\n      }\n    }\n\n    window.addEventListener('mousedown', onGlobalMouseDown);\n    return function () {\n      return window.removeEventListener('mousedown', onGlobalMouseDown);\n    };\n  }, []);\n}"]},"metadata":{},"sourceType":"module"}