UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

73 lines (72 loc) 1.89 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 _componentHelper = require("../../shared/component-helper"); 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 { if (!Array.isArray(window.__modalStack)) { window.__modalStack = []; } window.__modalStack.push(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