UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

76 lines (75 loc) 2.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addToIndex = addToIndex; exports.getContent = getContent; exports.getListOfModalRoots = getListOfModalRoots; exports.getModalRoot = getModalRoot; exports.removeFromIndex = removeFromIndex; var _push = _interopRequireDefault(require("core-js-pure/stable/instance/push.js")); var _componentHelper = require("../../shared/component-helper.js"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function getListOfModalRoots() { if (typeof window !== 'undefined') { try { const stack = window.__modalStack || []; return stack; } catch (e) { (0, _componentHelper.warn)(e); } } return []; } function getModalRoot(index) { if (typeof window !== 'undefined') { try { const stack = window.__modalStack || []; if (index !== null) { if (index === -1 && stack.length) { return stack[stack.length - 1]; } else if (index > -1) { return stack[index]; } } return null; } catch (e) { (0, _componentHelper.warn)(e); } } return null; } function addToIndex(elem) { if (typeof window !== 'undefined') { try { var _context; if (!Array.isArray(window.__modalStack)) { window.__modalStack = []; } (0, _push.default)(_context = window.__modalStack).call(_context, elem); } catch (e) { (0, _componentHelper.warn)(e); } } } function removeFromIndex(elem) { if (typeof window !== 'undefined') { try { if (!Array.isArray(window.__modalStack)) { window.__modalStack = []; } window.__modalStack = window.__modalStack.filter(cur => cur !== elem); } catch (e) { (0, _componentHelper.warn)(e); } } } function getContent(props) { if (typeof props.modal_content === 'string') { return props.modal_content; } else if (typeof props.modal_content === 'function') { return props.modal_content(props); } return (0, _componentHelper.processChildren)(props); } //# sourceMappingURL=helpers.js.map