Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

const exotic_1 = require("exotic");

exports.IS_BROWSER = typeof window === 'object';

function isClickOutsideElement(event, dom) {
  // get direct click event target
  const {
    target
  } = event; // get container that we'll wait to be clicked outside

  const container = dom; // if target is container - container was not clicked outside
  // if container contains clicked target - click was not outside of it

  if (target !== container && exotic_1.isObj(container) && exotic_1.isFunction(container.contains) && !container.contains(target)) {
    // clicked outside - fire callback
    return true;
  } else {
    return false;
  }
}

exports.isClickOutsideElement = isClickOutsideElement; // toBoolean

function isClickInsideElement(event, dom) {
  if (exotic_1.isNil(dom) === true) {
    return false;
  } else {
    return isClickOutsideElement(event, dom) === false;
  }
}

exports.isClickInsideElement = isClickInsideElement;

function toChildren(props, ref) {
  return exotic_1.isFunction(props.children) ? props.children(props, ref) : props.children;
}

exports.toChildren = toChildren;

function onClick(event, props, dom) {
  // if there is no proper callback - no point of checking
  if (exotic_1.isFunction(props.onClickOutside) === false) {
    console.warn('why are you using ClickBoundary without props.onClickOutside');
    return;
  }
  /**
   * @todo @deprecated do not pass all 3
   */


  if (isClickOutsideElement(event, dom) === true) {
    props.onClickOutside(event, props, dom);
  }
}

exports.onClick = onClick; //# sourceMappingURL=_deps.js.map