{"size": 1916, "ext": "js", "max_stars_repo_path": "dist/metaComponents/popOver/SimplePopOver.js", "max_stars_repo_name": "Simspace/monorail", "max_stars_repo_stars_event_min_datetime": "2018-11-03T00:45:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-25T02:23:54.000Z", "max_issues_repo_path": "dist/metaComponents/popOver/SimplePopOver.js", "max_issues_repo_name": "Simspace/monorail", "max_issues_repo_issues_event_min_datetime": "2019-03-04T21:35:23.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-31T16:45:18.000Z", "max_forks_repo_path": "dist/metaComponents/popOver/SimplePopOver.js", "max_forks_repo_name": "Simspace/monorail", "max_forks_repo_forks_event_min_datetime": "2019-06-12T21:42:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-18T17:07:25.000Z"}
{"max_stars_count": 16, "max_issues_count": 5, "max_forks_count": 6, "avg_line_length": 40.7659574468, "max_line_length": 743, "alphanum_fraction": 0.6675365344}
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SimplePopOver = void 0;

var _react = _interopRequireWildcard(require("react"));

var _PortalController = require("../portal/PortalController");

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

const SimplePopOver = props => {
  const {
    popOver,
    position,
    isOpen,
    onClose = () => {}
  } = props;
  const [state, setState] = (0, _react.useState)('closed');

  const onCloseEnd = _react.default.useCallback(() => {
    setState('closed');
  }, []);

  _react.default.useEffect(() => {
    if (isOpen && state === 'closed') {
      setState('opened');
    } else if (state === 'opened') {
      setState('closing');
    }
  }, [isOpen, state]);

  return /*#__PURE__*/_react.default.createElement(_PortalController.PortalController, {
    isRendered: state !== 'closed'
  }, popOver({
    isOpen,
    position,
    togglePopOver: onClose,
    closingAnimationCompleted: onCloseEnd
  }));
};

exports.SimplePopOver = SimplePopOver;