reactjs-popup.cjs.development.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var React = require('react');
  5. var React__default = _interopDefault(React);
  6. var ReactDOM = _interopDefault(require('react-dom'));
  7. function _extends() {
  8. _extends = Object.assign || function (target) {
  9. for (var i = 1; i < arguments.length; i++) {
  10. var source = arguments[i];
  11. for (var key in source) {
  12. if (Object.prototype.hasOwnProperty.call(source, key)) {
  13. target[key] = source[key];
  14. }
  15. }
  16. }
  17. return target;
  18. };
  19. return _extends.apply(this, arguments);
  20. }
  21. var useOnEscape = function useOnEscape(handler, active) {
  22. if (active === void 0) {
  23. active = true;
  24. }
  25. React.useEffect(function () {
  26. if (!active) return;
  27. var listener = function listener(event) {
  28. // check if key is an Escape
  29. if (event.key === 'Escape') handler(event);
  30. };
  31. document.addEventListener('keyup', listener);
  32. return function () {
  33. if (!active) return;
  34. document.removeEventListener('keyup', listener);
  35. };
  36. }, [handler, active]);
  37. };
  38. var useRepositionOnResize = function useRepositionOnResize(handler, active) {
  39. if (active === void 0) {
  40. active = true;
  41. }
  42. React.useEffect(function () {
  43. if (!active) return;
  44. var listener = function listener() {
  45. handler();
  46. };
  47. window.addEventListener('resize', listener);
  48. return function () {
  49. if (!active) return;
  50. window.removeEventListener('resize', listener);
  51. };
  52. }, [handler, active]);
  53. };
  54. var useOnClickOutside = function useOnClickOutside(ref, handler, active) {
  55. if (active === void 0) {
  56. active = true;
  57. }
  58. React.useEffect(function () {
  59. if (!active) return;
  60. var listener = function listener(event) {
  61. // Do nothing if clicking ref's element or descendent elements
  62. var refs = Array.isArray(ref) ? ref : [ref];
  63. var contains = false;
  64. refs.forEach(function (r) {
  65. if (!r.current || r.current.contains(event.target)) {
  66. contains = true;
  67. return;
  68. }
  69. });
  70. event.stopPropagation();
  71. if (!contains) handler(event);
  72. };
  73. document.addEventListener('mousedown', listener);
  74. document.addEventListener('touchstart', listener);
  75. return function () {
  76. if (!active) return;
  77. document.removeEventListener('mousedown', listener);
  78. document.removeEventListener('touchstart', listener);
  79. };
  80. }, [ref, handler, active]);
  81. }; // Make sure that user is not able TAB out of the Modal content on Open
  82. var useTabbing = function useTabbing(contentRef, active) {
  83. if (active === void 0) {
  84. active = true;
  85. }
  86. React.useEffect(function () {
  87. if (!active) return;
  88. var listener = function listener(event) {
  89. // check if key is an Tab
  90. if (event.keyCode === 9) {
  91. var _contentRef$current;
  92. var els = contentRef === null || contentRef === void 0 ? void 0 : (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]');
  93. var focusableEls = Array.prototype.slice.call(els);
  94. if (focusableEls.length === 1) {
  95. event.preventDefault();
  96. return;
  97. }
  98. var firstFocusableEl = focusableEls[0];
  99. var lastFocusableEl = focusableEls[focusableEls.length - 1];
  100. if (event.shiftKey && document.activeElement === firstFocusableEl) {
  101. event.preventDefault();
  102. lastFocusableEl.focus();
  103. } else if (document.activeElement === lastFocusableEl) {
  104. event.preventDefault();
  105. firstFocusableEl.focus();
  106. }
  107. }
  108. };
  109. document.addEventListener('keydown', listener);
  110. return function () {
  111. if (!active) return;
  112. document.removeEventListener('keydown', listener);
  113. };
  114. }, [contentRef, active]);
  115. };
  116. var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
  117. var Style = {
  118. popupContent: {
  119. tooltip: {
  120. position: 'absolute',
  121. zIndex: 999
  122. },
  123. modal: {
  124. position: 'relative',
  125. margin: 'auto'
  126. }
  127. },
  128. popupArrow: {
  129. height: '8px',
  130. width: '16px',
  131. position: 'absolute',
  132. background: 'transparent',
  133. color: '#FFF',
  134. zIndex: -1
  135. },
  136. overlay: {
  137. tooltip: {
  138. position: 'fixed',
  139. top: '0',
  140. bottom: '0',
  141. left: '0',
  142. right: '0',
  143. zIndex: 999
  144. },
  145. modal: {
  146. position: 'fixed',
  147. top: '0',
  148. bottom: '0',
  149. left: '0',
  150. right: '0',
  151. display: 'flex',
  152. zIndex: 999
  153. }
  154. }
  155. };
  156. var POSITION_TYPES = ['top left', 'top center', 'top right', 'right top', 'right center', 'right bottom', 'bottom left', 'bottom center', 'bottom right', 'left top', 'left center', 'left bottom'];
  157. var getCoordinatesForPosition = function getCoordinatesForPosition(triggerBounding, ContentBounding, position, //PopupPosition | PopupPosition[],
  158. arrow, _ref) {
  159. var offsetX = _ref.offsetX,
  160. offsetY = _ref.offsetY;
  161. var margin = arrow ? 8 : 0;
  162. var args = position.split(' '); // the step N 1 : center the popup content => ok
  163. var CenterTop = triggerBounding.top + triggerBounding.height / 2;
  164. var CenterLeft = triggerBounding.left + triggerBounding.width / 2;
  165. var height = ContentBounding.height,
  166. width = ContentBounding.width;
  167. var top = CenterTop - height / 2;
  168. var left = CenterLeft - width / 2;
  169. var transform = '';
  170. var arrowTop = '0%';
  171. var arrowLeft = '0%'; // the step N 2 : => ok
  172. switch (args[0]) {
  173. case 'top':
  174. top -= height / 2 + triggerBounding.height / 2 + margin;
  175. transform = "rotate(180deg) translateX(50%)";
  176. arrowTop = '100%';
  177. arrowLeft = '50%';
  178. break;
  179. case 'bottom':
  180. top += height / 2 + triggerBounding.height / 2 + margin;
  181. transform = "rotate(0deg) translateY(-100%) translateX(-50%)";
  182. arrowLeft = '50%';
  183. break;
  184. case 'left':
  185. left -= width / 2 + triggerBounding.width / 2 + margin;
  186. transform = " rotate(90deg) translateY(50%) translateX(-25%)";
  187. arrowLeft = '100%';
  188. arrowTop = '50%';
  189. break;
  190. case 'right':
  191. left += width / 2 + triggerBounding.width / 2 + margin;
  192. transform = "rotate(-90deg) translateY(-150%) translateX(25%)";
  193. arrowTop = '50%';
  194. break;
  195. }
  196. switch (args[1]) {
  197. case 'top':
  198. top = triggerBounding.top;
  199. arrowTop = triggerBounding.height / 2 + "px";
  200. break;
  201. case 'bottom':
  202. top = triggerBounding.top - height + triggerBounding.height;
  203. arrowTop = height - triggerBounding.height / 2 + "px";
  204. break;
  205. case 'left':
  206. left = triggerBounding.left;
  207. arrowLeft = triggerBounding.width / 2 + "px";
  208. break;
  209. case 'right':
  210. left = triggerBounding.left - width + triggerBounding.width;
  211. arrowLeft = width - triggerBounding.width / 2 + "px";
  212. break;
  213. }
  214. top = args[0] === 'top' ? top - offsetY : top + offsetY;
  215. left = args[0] === 'left' ? left - offsetX : left + offsetX;
  216. return {
  217. top: top,
  218. left: left,
  219. transform: transform,
  220. arrowLeft: arrowLeft,
  221. arrowTop: arrowTop
  222. };
  223. };
  224. var getTooltipBoundary = function getTooltipBoundary(keepTooltipInside) {
  225. // add viewport
  226. var boundingBox = {
  227. top: 0,
  228. left: 0,
  229. /* eslint-disable-next-line no-undef */
  230. width: window.innerWidth,
  231. /* eslint-disable-next-line no-undef */
  232. height: window.innerHeight
  233. };
  234. if (typeof keepTooltipInside === 'string') {
  235. /* eslint-disable-next-line no-undef */
  236. var selector = document.querySelector(keepTooltipInside);
  237. {
  238. if (selector === null) throw new Error(keepTooltipInside + " selector does not exist : keepTooltipInside must be a valid html selector 'class' or 'Id' or a boolean value");
  239. }
  240. if (selector !== null) boundingBox = selector.getBoundingClientRect();
  241. }
  242. return boundingBox;
  243. };
  244. var calculatePosition = function calculatePosition(triggerBounding, ContentBounding, position, arrow, _ref2, keepTooltipInside) {
  245. var offsetX = _ref2.offsetX,
  246. offsetY = _ref2.offsetY;
  247. var bestCoords = {
  248. arrowLeft: '0%',
  249. arrowTop: '0%',
  250. left: 0,
  251. top: 0,
  252. transform: 'rotate(135deg)'
  253. };
  254. var i = 0;
  255. var wrapperBox = getTooltipBoundary(keepTooltipInside);
  256. var positions = Array.isArray(position) ? position : [position]; // keepTooltipInside would be activated if the keepTooltipInside exist or the position is Array
  257. if (keepTooltipInside || Array.isArray(position)) positions = [].concat(positions, POSITION_TYPES); // add viewPort for WarpperBox
  258. // wrapperBox.top = wrapperBox.top + window.scrollY;
  259. // wrapperBox.left = wrapperBox.left + window.scrollX;
  260. while (i < positions.length) {
  261. bestCoords = getCoordinatesForPosition(triggerBounding, ContentBounding, positions[i], arrow, {
  262. offsetX: offsetX,
  263. offsetY: offsetY
  264. });
  265. var contentBox = {
  266. top: bestCoords.top,
  267. left: bestCoords.left,
  268. width: ContentBounding.width,
  269. height: ContentBounding.height
  270. };
  271. if (contentBox.top <= wrapperBox.top || contentBox.left <= wrapperBox.left || contentBox.top + contentBox.height >= wrapperBox.top + wrapperBox.height || contentBox.left + contentBox.width >= wrapperBox.left + wrapperBox.width) {
  272. i++;
  273. } else {
  274. break;
  275. }
  276. }
  277. return bestCoords;
  278. };
  279. var popupIdCounter = 0;
  280. var getRootPopup = function getRootPopup() {
  281. var PopupRoot = document.getElementById('popup-root');
  282. if (PopupRoot === null) {
  283. PopupRoot = document.createElement('div');
  284. PopupRoot.setAttribute('id', 'popup-root');
  285. document.body.appendChild(PopupRoot);
  286. }
  287. return PopupRoot;
  288. };
  289. var Popup = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
  290. var _ref$trigger = _ref.trigger,
  291. trigger = _ref$trigger === void 0 ? null : _ref$trigger,
  292. _ref$onOpen = _ref.onOpen,
  293. onOpen = _ref$onOpen === void 0 ? function () {} : _ref$onOpen,
  294. _ref$onClose = _ref.onClose,
  295. onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
  296. _ref$defaultOpen = _ref.defaultOpen,
  297. defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
  298. _ref$open = _ref.open,
  299. open = _ref$open === void 0 ? undefined : _ref$open,
  300. _ref$disabled = _ref.disabled,
  301. disabled = _ref$disabled === void 0 ? false : _ref$disabled,
  302. _ref$nested = _ref.nested,
  303. nested = _ref$nested === void 0 ? false : _ref$nested,
  304. _ref$closeOnDocumentC = _ref.closeOnDocumentClick,
  305. closeOnDocumentClick = _ref$closeOnDocumentC === void 0 ? true : _ref$closeOnDocumentC,
  306. _ref$repositionOnResi = _ref.repositionOnResize,
  307. repositionOnResize = _ref$repositionOnResi === void 0 ? true : _ref$repositionOnResi,
  308. _ref$closeOnEscape = _ref.closeOnEscape,
  309. closeOnEscape = _ref$closeOnEscape === void 0 ? true : _ref$closeOnEscape,
  310. _ref$on = _ref.on,
  311. on = _ref$on === void 0 ? ['click'] : _ref$on,
  312. _ref$contentStyle = _ref.contentStyle,
  313. contentStyle = _ref$contentStyle === void 0 ? {} : _ref$contentStyle,
  314. _ref$arrowStyle = _ref.arrowStyle,
  315. arrowStyle = _ref$arrowStyle === void 0 ? {} : _ref$arrowStyle,
  316. _ref$overlayStyle = _ref.overlayStyle,
  317. overlayStyle = _ref$overlayStyle === void 0 ? {} : _ref$overlayStyle,
  318. _ref$className = _ref.className,
  319. className = _ref$className === void 0 ? '' : _ref$className,
  320. _ref$position = _ref.position,
  321. position = _ref$position === void 0 ? 'bottom center' : _ref$position,
  322. _ref$modal = _ref.modal,
  323. modal = _ref$modal === void 0 ? false : _ref$modal,
  324. _ref$lockScroll = _ref.lockScroll,
  325. lockScroll = _ref$lockScroll === void 0 ? false : _ref$lockScroll,
  326. _ref$arrow = _ref.arrow,
  327. arrow = _ref$arrow === void 0 ? true : _ref$arrow,
  328. _ref$offsetX = _ref.offsetX,
  329. offsetX = _ref$offsetX === void 0 ? 0 : _ref$offsetX,
  330. _ref$offsetY = _ref.offsetY,
  331. offsetY = _ref$offsetY === void 0 ? 0 : _ref$offsetY,
  332. _ref$mouseEnterDelay = _ref.mouseEnterDelay,
  333. mouseEnterDelay = _ref$mouseEnterDelay === void 0 ? 100 : _ref$mouseEnterDelay,
  334. _ref$mouseLeaveDelay = _ref.mouseLeaveDelay,
  335. mouseLeaveDelay = _ref$mouseLeaveDelay === void 0 ? 100 : _ref$mouseLeaveDelay,
  336. _ref$keepTooltipInsid = _ref.keepTooltipInside,
  337. keepTooltipInside = _ref$keepTooltipInsid === void 0 ? false : _ref$keepTooltipInsid,
  338. children = _ref.children;
  339. var _useState = React.useState(open || defaultOpen),
  340. isOpen = _useState[0],
  341. setIsOpen = _useState[1];
  342. var triggerRef = React.useRef(null);
  343. var contentRef = React.useRef(null);
  344. var arrowRef = React.useRef(null);
  345. var focusedElBeforeOpen = React.useRef(null);
  346. var popupId = React.useRef("popup-" + ++popupIdCounter);
  347. var isModal = modal ? true : !trigger;
  348. var timeOut = React.useRef(0);
  349. useIsomorphicLayoutEffect(function () {
  350. if (isOpen) {
  351. focusedElBeforeOpen.current = document.activeElement;
  352. setPosition();
  353. focusContentOnOpen(); // for accessibility
  354. lockScrolll();
  355. } else {
  356. resetScroll();
  357. }
  358. return function () {
  359. clearTimeout(timeOut.current);
  360. };
  361. }, [isOpen]); // for uncontrolled popup we need to sync isOpen with open prop
  362. React.useEffect(function () {
  363. if (typeof open === 'boolean') {
  364. if (open) openPopup();else closePopup();
  365. }
  366. }, [open, disabled]);
  367. var openPopup = function openPopup(event) {
  368. if (isOpen || disabled) return;
  369. setIsOpen(true);
  370. setTimeout(function () {
  371. return onOpen(event);
  372. }, 0);
  373. };
  374. var closePopup = function closePopup(event) {
  375. var _focusedElBeforeOpen$;
  376. if (!isOpen || disabled) return;
  377. setIsOpen(false);
  378. if (isModal) (_focusedElBeforeOpen$ = focusedElBeforeOpen.current) === null || _focusedElBeforeOpen$ === void 0 ? void 0 : _focusedElBeforeOpen$.focus();
  379. setTimeout(function () {
  380. return onClose(event);
  381. }, 0);
  382. };
  383. var togglePopup = function togglePopup(event) {
  384. event === null || event === void 0 ? void 0 : event.stopPropagation();
  385. if (!isOpen) openPopup(event);else closePopup(event);
  386. };
  387. var onMouseEnter = function onMouseEnter(event) {
  388. clearTimeout(timeOut.current);
  389. timeOut.current = setTimeout(function () {
  390. return openPopup(event);
  391. }, mouseEnterDelay);
  392. };
  393. var onContextMenu = function onContextMenu(event) {
  394. event === null || event === void 0 ? void 0 : event.preventDefault();
  395. togglePopup();
  396. };
  397. var onMouseLeave = function onMouseLeave(event) {
  398. clearTimeout(timeOut.current);
  399. timeOut.current = setTimeout(function () {
  400. return closePopup(event);
  401. }, mouseLeaveDelay);
  402. };
  403. var lockScrolll = function lockScrolll() {
  404. if (isModal && lockScroll) document.getElementsByTagName('body')[0].style.overflow = 'hidden'; // migrate to document.body
  405. };
  406. var resetScroll = function resetScroll() {
  407. if (isModal && lockScroll) document.getElementsByTagName('body')[0].style.overflow = 'auto';
  408. };
  409. var focusContentOnOpen = function focusContentOnOpen() {
  410. var _contentRef$current;
  411. var focusableEls = contentRef === null || contentRef === void 0 ? void 0 : (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]');
  412. var firstEl = Array.prototype.slice.call(focusableEls)[0];
  413. firstEl === null || firstEl === void 0 ? void 0 : firstEl.focus();
  414. };
  415. React.useImperativeHandle(ref, function () {
  416. return {
  417. open: function open() {
  418. openPopup();
  419. },
  420. close: function close() {
  421. closePopup();
  422. },
  423. toggle: function toggle() {
  424. togglePopup();
  425. }
  426. };
  427. }); // set Position
  428. var setPosition = function setPosition() {
  429. if (isModal || !isOpen) return;
  430. if (!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) || !(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) || !(contentRef === null || contentRef === void 0 ? void 0 : contentRef.current)) return; /// show error as one of ref is undefined
  431. var trigger = triggerRef.current.getBoundingClientRect();
  432. var content = contentRef.current.getBoundingClientRect();
  433. var cords = calculatePosition(trigger, content, position, arrow, {
  434. offsetX: offsetX,
  435. offsetY: offsetY
  436. }, keepTooltipInside);
  437. contentRef.current.style.top = cords.top + window.scrollY + "px";
  438. contentRef.current.style.left = cords.left + window.scrollX + "px";
  439. if (arrow && !!arrowRef.current) {
  440. var _arrowStyle$top, _arrowStyle$left;
  441. arrowRef.current.style.transform = cords.transform;
  442. arrowRef.current.style.setProperty('-ms-transform', cords.transform);
  443. arrowRef.current.style.setProperty('-webkit-transform', cords.transform);
  444. arrowRef.current.style.top = ((_arrowStyle$top = arrowStyle.top) === null || _arrowStyle$top === void 0 ? void 0 : _arrowStyle$top.toString()) || cords.arrowTop;
  445. arrowRef.current.style.left = ((_arrowStyle$left = arrowStyle.left) === null || _arrowStyle$left === void 0 ? void 0 : _arrowStyle$left.toString()) || cords.arrowLeft;
  446. }
  447. }; // hooks
  448. useOnEscape(closePopup, closeOnEscape); // can be optimized if we disabled for hover
  449. useTabbing(contentRef, isOpen && isModal);
  450. useRepositionOnResize(setPosition, repositionOnResize);
  451. useOnClickOutside(!!trigger ? [contentRef, triggerRef] : [contentRef], closePopup, closeOnDocumentClick && !nested); // we need to add a ne
  452. // render the trigger element and add events
  453. var renderTrigger = function renderTrigger() {
  454. var triggerProps = {
  455. key: 'T',
  456. ref: triggerRef,
  457. 'aria-describedby': popupId.current
  458. };
  459. var onAsArray = Array.isArray(on) ? on : [on];
  460. for (var i = 0, len = onAsArray.length; i < len; i++) {
  461. switch (onAsArray[i]) {
  462. case 'click':
  463. triggerProps.onClick = togglePopup;
  464. break;
  465. case 'right-click':
  466. triggerProps.onContextMenu = onContextMenu;
  467. break;
  468. case 'hover':
  469. triggerProps.onMouseEnter = onMouseEnter;
  470. triggerProps.onMouseLeave = onMouseLeave;
  471. break;
  472. case 'focus':
  473. triggerProps.onFocus = onMouseEnter;
  474. triggerProps.onBlur = onMouseLeave;
  475. break;
  476. }
  477. }
  478. if (typeof trigger === 'function') {
  479. var comp = trigger(isOpen);
  480. return !!trigger && React__default.cloneElement(comp, triggerProps);
  481. }
  482. return !!trigger && React__default.cloneElement(trigger, triggerProps);
  483. };
  484. var addWarperAction = function addWarperAction() {
  485. var popupContentStyle = isModal ? Style.popupContent.modal : Style.popupContent.tooltip;
  486. var childrenElementProps = {
  487. className: "popup-content " + (className !== '' ? className.split(' ').map(function (c) {
  488. return c + "-content";
  489. }).join(' ') : ''),
  490. style: _extends({}, popupContentStyle, contentStyle, {
  491. pointerEvents: 'auto'
  492. }),
  493. ref: contentRef,
  494. onClick: function onClick(e) {
  495. e.stopPropagation();
  496. }
  497. };
  498. if (!modal && on.indexOf('hover') >= 0) {
  499. childrenElementProps.onMouseEnter = onMouseEnter;
  500. childrenElementProps.onMouseLeave = onMouseLeave;
  501. }
  502. return childrenElementProps;
  503. };
  504. var renderContent = function renderContent() {
  505. return React__default.createElement("div", Object.assign({}, addWarperAction(), {
  506. key: "C",
  507. role: isModal ? 'dialog' : 'tooltip',
  508. id: popupId.current
  509. }), arrow && !isModal && React__default.createElement("div", {
  510. ref: arrowRef,
  511. style: Style.popupArrow
  512. }, React__default.createElement("svg", {
  513. "data-testid": "arrow",
  514. className: "popup-arrow " + (className !== '' ? className.split(' ').map(function (c) {
  515. return c + "-arrow";
  516. }).join(' ') : ''),
  517. viewBox: "0 0 32 16",
  518. style: _extends({
  519. position: 'absolute'
  520. }, arrowStyle)
  521. }, React__default.createElement("path", {
  522. d: "M16 0l16 16H0z",
  523. fill: "currentcolor"
  524. }))), children && typeof children === 'function' ? children(closePopup, isOpen) : children);
  525. };
  526. var overlay = !(on.indexOf('hover') >= 0);
  527. var ovStyle = isModal ? Style.overlay.modal : Style.overlay.tooltip;
  528. var content = [overlay && React__default.createElement("div", {
  529. key: "O",
  530. "data-testid": "overlay",
  531. "data-popup": isModal ? 'modal' : 'tooltip',
  532. className: "popup-overlay " + (className !== '' ? className.split(' ').map(function (c) {
  533. return c + "-overlay";
  534. }).join(' ') : ''),
  535. style: _extends({}, ovStyle, overlayStyle, {
  536. pointerEvents: closeOnDocumentClick && nested || isModal ? 'auto' : 'none'
  537. }),
  538. onClick: closeOnDocumentClick && nested ? closePopup : undefined,
  539. tabIndex: -1
  540. }, isModal && renderContent()), !isModal && renderContent()];
  541. return React__default.createElement(React__default.Fragment, null, renderTrigger(), isOpen && ReactDOM.createPortal(content, getRootPopup()));
  542. });
  543. exports.Popup = Popup;
  544. exports.default = Popup;
  545. //# sourceMappingURL=reactjs-popup.cjs.development.js.map