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AAI,CAAD,IAAc,SAAS,CAAC,CAAD,EAAoB,EAApB,EAAwB,OAAxB,CAAvC,CADuD,CAEvD;AACA;AACA;;;AACA,UAAM,GAAG,GAAG,QAAQ,CAAC,aAAT,CAAuB,YAAvB,KACV,QAAQ,CAAC,IADX,CALuD,CAMvC;;AAChB,IAAA,GAAG,CAAC,gBAAJ,CAAqB,OAArB,EAA8B,OAA9B,EAAuC,IAAvC;AACA,IAAA,EAAE,CAAC,aAAH,GAAmB,OAAnB;AACD,GAfyB;;AAiB1B,EAAA,MAAM,CAAE,EAAF,EAAiB;AACrB,QAAI,CAAC,EAAE,CAAC,aAAR,EAAuB;AAEvB,UAAM,GAAG,GAAG,QAAQ,CAAC,aAAT,CAAuB,YAAvB,KACV,QAAQ,CAAC,IADX,CAHqB,CAIL;;AAChB,IAAA,GAAG,IAAI,GAAG,CAAC,mBAAJ,CAAwB,OAAxB,EAAiC,EAAE,CAAC,aAApC,EAAmD,IAAnD,CAAP;AACA,WAAO,EAAE,CAAC,aAAV;AACD;;AAxByB,CAArB;AA2BP,eAAe,YAAf","sourcesContent":["import { VNodeDirective } from 'vue/types/vnode'\n\ninterface ClickOutsideBindingArgs {\n closeConditional?: (e: Event) => boolean\n include?: () => HTMLElement[]\n}\n\ninterface ClickOutsideDirective extends VNodeDirective {\n value?: (e: Event) => void\n args?: ClickOutsideBindingArgs\n}\n\nfunction closeConditional () {\n return false\n}\n\nfunction directive (e: PointerEvent, el: HTMLElement, binding: ClickOutsideDirective): void {\n // Args may not always be supplied\n binding.args = binding.args || {}\n\n // If no closeConditional was supplied assign a default\n const isActive = (binding.args.closeConditional || closeConditional)\n\n // The include element callbacks below can be expensive\n // so we should avoid calling them when we're not active.\n // Explicitly check for false to allow fallback compatibility\n // with non-toggleable components\n if (!e || isActive(e) === false) return\n\n // If click was triggered programmaticaly (domEl.click()) then\n // it shouldn't be treated as click-outside\n // Chrome/Firefox support isTrusted property\n // IE/Edge support pointerType property (empty if not triggered\n // by pointing device)\n if (('isTrusted' in e && !e.isTrusted) ||\n ('pointerType' in e && !e.pointerType)\n ) return\n\n // Check if additional elements were passed to be included in check\n // (click must be outside all included elements, if any)\n const elements = (binding.args.include || (() => []))()\n // Add the root element for the component this directive was defined on\n elements.push(el)\n\n // Check if it's a click outside our elements, and then if our callback returns true.\n // Non-toggleable components should take action in their callback and return falsy.\n // Toggleable can return true if it wants to deactivate.\n // Note that, because we're in the capture phase, this callback will occur before\n // the bubbling click event on any outside elements.\n !elements.some(el => el.contains(e.target as Node)) && setTimeout(() => {\n isActive(e) && binding.value && binding.value(e)\n }, 0)\n}\n\nexport const ClickOutside = {\n // [data-app] may not be found\n // if using bind, inserted makes\n // sure that the root element is\n // available, iOS does not support\n // clicks on body\n inserted (el: HTMLElement, binding: ClickOutsideDirective) {\n const onClick = (e: Event) => directive(e as PointerEvent, el, bindi
|