meraproject/lib/js/bws/react/ui/modal.min.js
keboss-m 5c21d25d45 Initial commit: Merakomis portal, Docker stack and user-reader API.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 11:04:05 +03:00

3 lines
2.1 KiB
JavaScript

var Modal,ModalWrap,createModals;window.Modal=Modal=class extends React.Component{constructor(e){var t,a,o,n;super(e),console.log("modal",e),t=null!=(a=e.data)?a:{},this.state={closed:!1,content:null!=(o=t.content)?o:null,scrollable:!0===t.scrollable,width:null!=(n=t.width)?n:null},this.close=this.close.bind(this),this.wrap=null}componentDidMount(){if(this.state.scrollable)return $(this.wrap).perfectScrollbar()}close(){var e;return this.setState({closed:!0}),"function"==typeof(e=this.props).onClose?e.onClose():void 0}render(){var e,t,a,o,n=this;return({closed:e,content:t,width:o}=this.state),e?null:(a={},null!=o&&(a.width=o+"px"),React.createElement("div",{className:"background"},React.createElement("div",{className:"background_click",onClick:this.close}),React.createElement("div",{className:"modal",ref:function(e){return n.wrap=e},style:a},React.createElement("div",{className:"modal_content"},t))))}};export default window.ModalWrap=ModalWrap=class extends React.Component{constructor(e){super(e),this.state={index:0},this.modals={},this.rModals={},this.create=this.create.bind(this),this.onClose=this.onClose.bind(this)}getBodyWrap(){var e;return null===(e=document.getElementById("background"))&&(e=document.body),e}onClose(e){if(delete this.modals[e],0===Object.keys(this.modals).length)return this.getBodyWrap().classList.remove("modaled")}create(e){var t,a=this;return({index:t}=this.state),t++,this.modals[t]=React.createElement(Modal,{data:e,key:t,ref:function(e){return a.rModals[t]=e},onClose:this.onClose.bind(this,t)}),this.setState({index:t}),this.getBodyWrap().classList.add("modaled"),t}openCard(e,t,a={}){var o,n,l;return n=null,l=this,o=function(){return l.rModals[n].close()},n=Modals.create({content:React.createElement(Card,{ajax:!0,controller:e,id:t,in_modal:!0,onClose:o,options:a}),scrollable:!0})}render(){var e,t;for(e in t=[],this.modals)t.push(this.modals[e]);return t}};createModals=function(){var e;return e=document.createElement("div"),document.body.appendChild(e),ReactDOM.render(React.createElement(ModalWrap,{ref:function(e){return window.Modals=e}}),e)},document.addEventListener("DOMContentLoaded",createModals);
//# sourceMappingURL=modal.min.js.map