{"version":3,"sources":["webpack:///./src/main/web/components/ui/template/TemplateItemComponent.ts","webpack:///./src/main/web/components/ui/template/index.ts"],"names":["connectedCallback","shadow","this","attachShadow","mode","root","document","createElement","appendChild","Object","defineProperty","value","args","createElementNS","createTextNode","ModuleRegistry","parseHtmlToReact","innerHTML","then","res","render","Fragment","disconnectedCallback","unmountComponentAtNode","HTMLElement","TemplateItemComponent"],"mappings":"2IAmBA,OACA,QAEA,SAYA,+C,+CA6BA,OA7B2C,qCAIzC,gCAAAA,kBAAA,sBAIQC,EAASC,KAAKC,aAAa,CAAEC,KAAM,SACzCF,KAAKG,KAAOC,SAASC,cAAc,OACnCN,EAAOO,YAAYN,KAAKG,MAExBI,OAAOC,eAAeR,KAAKG,KAAM,gBAAiB,CAAEM,MAAOV,IAC3DA,EAAOM,cAAgB,W,UAAC,kDAAiB,SAACD,UAAiBC,cAAa,QAAIK,IAC5EX,EAAOY,gBAAkB,W,UAAC,kDAAiB,SAACP,UAAiBO,gBAAe,QAAID,IAChFX,EAAOa,eAAiB,W,UAAC,kDAAiB,SAACR,UAAiBQ,eAAc,QAAIF,IAE9E,EAAAG,eAAeC,iBAAiBd,KAAKe,WAAWC,MAC9C,SAAAC,GAGE,EAAAC,OAAO,EAAAb,cAAc,EAAAc,SAAU,GAAIF,GAAM,EAAKd,UAKpD,gCAAAiB,qBAAA,WACE,EAAAC,uBAAuBrB,KAAKG,OAEhC,sBA7BA,CAA2CmB,aAA9B,EAAAC,yB,iFCfb,yBACA","file":"default~app~diagram-search-result~field-editor~mp-account-manager~mp-admin-config-manager~mp-admin-n~fcbf513a-8a01f9ad75249533ab5c.js","sourcesContent":["/**\n * ResearchSpace\n * Copyright (C) 2020, © Trustees of the British Museum\n * Copyright (C) 2015-2019, metaphacts GmbH\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport { createElement, Fragment } from 'react';\nimport { render, unmountComponentAtNode } from 'react-dom';\n\nimport { ModuleRegistry } from 'platform/api/module-loader';\n\n/**\n * This component render custom html elements.\n * It takes inner html, parses it into the react element and then renders the result inside.\n *\n * It is useful when one wants to render platform template with some 3-rd party component\n * that expects plain HTML as an input,\n * like annotation popover in Mirador, or feature popover in openlayers.\n *\n * This component is registered as `mp-template-item` web component in the `app.ts` file.\n */\nexport class TemplateItemComponent extends HTMLElement {\n\n private root: HTMLElement;\n\n connectedCallback() {\n // this is ugly hack to workaround issue with event propagation when react root\n // is inside custom web component,\n // see https://github.com/facebook/react/issues/9242\n const shadow = this.attachShadow({ mode: 'open' }) as any;\n this.root = document.createElement('div');\n shadow.appendChild(this.root);\n\n Object.defineProperty(this.root, 'ownerDocument', { value: shadow });\n shadow.createElement = (...args: any) => (document as any).createElement(...args);\n shadow.createElementNS = (...args: any) => (document as any).createElementNS(...args);\n shadow.createTextNode = (...args: any) => (document as any).createTextNode(...args);\n\n ModuleRegistry.parseHtmlToReact(this.innerHTML).then(\n res => {\n // we need to use Fragment here because res can be a single element or array of elements\n // see https://reactjs.org/docs/fragments.html\n render(createElement(Fragment, {}, res), this.root);\n }\n );\n }\n\n disconnectedCallback() {\n unmountComponentAtNode(this.root);\n }\n}\n","/**\n * ResearchSpace\n * Copyright (C) 2020, © Trustees of the British Museum\n * Copyright (C) 2015-2019, metaphacts GmbH\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nexport * from './TemplateItem';\nexport * from './TemplateItemComponent';\n"],"sourceRoot":""}