graphdb-workbench
Version:
The web application for GraphDB APIs
1 lines • 4.17 kB
JavaScript
"use strict";var index=require("./index-L_ZmIeD5.js"),workbenchApi=require("@ontotext/workbench-api"),translation_service=require("./translation.service-CC6jY4U-.js");const ontoToastrCss=()=>".onto-toastr-container{position:fixed;z-index:9999999;pointer-events:auto;flex-direction:column}.onto-toastr-container.bottom-right{bottom:12px;right:12px}.onto-toastr-container.bottom-left{bottom:12px;left:12px}.onto-toastr-container .onto-toast{display:flex;align-items:center;border-radius:0;box-shadow:0 0 12px rgba(0, 0, 0, 0.3);position:relative;width:400px;padding:25px 0;color:white;margin-bottom:5px;overflow-wrap:break-word}.onto-toastr-container .onto-toast:hover{box-shadow:0 0 12px #000;opacity:1;cursor:pointer}.onto-toastr-container .onto-toast.warning{color:var(--gw-toast-warn-color);background-color:var(--gw-toast-warn-background);border-color:var(--gw-toast-warn-border-color)}.onto-toastr-container .onto-toast.success{background-color:var(--gw-toast-success-background);border-color:var(--gw-toast-success-border-color);color:var(--gw-toast-success-color)}.onto-toastr-container .onto-toast.error{background-color:var(--gw-toast-error-background);border-color:var(--gw-toast-error-border-color);color:var(--gw-toast-error-color)}.onto-toastr-container .onto-toast.info{background-color:var(--gw-toast-info-background);border-color:var(--gw-toast-info-border-color);color:var(--gw-toast-info-color)}.onto-toastr-container .onto-toast i{font-size:1.8rem;padding:0 20px;color:inherit}.onto-toastr-container .onto-toast i:hover{transform:none}.onto-toastr-container .onto-toast .toast-message{font-size:1.2rem;opacity:1;max-width:370px}",toastTypeToIconMap={[workbenchApi.ToastType.INFO]:"ri-information-2-fill",[workbenchApi.ToastType.SUCCESS]:"ri-checkbox-circle-line",[workbenchApi.ToastType.WARNING]:"ri-message-line",[workbenchApi.ToastType.ERROR]:"ri-alert-line"},OntoToastr=class{constructor(o){index.registerInstance(this,o),this.toasts=new workbenchApi.ToastMessageList([]),this.toastToTimeout=new Map,this.config=workbenchApi.ToastrConfig.getDefaultConfig(),this.onToastMouseEnter=o=>()=>{this.clearToastTimeout(o)},this.onToastMouseLeave=o=>()=>{this.setTimeoutForToast(o)}}handleToastCreate(o){this.addToast(o.detail)}render(){var o;return index.h("section",{key:"2d8a4bf8daa44b240995ecc4a22e3551a4287054",style:{display:this.toasts.isEmpty()?"none":"flex"},class:`onto-toastr-container ${this.config.position}`},null===(o=this.toasts)||void 0===o?void 0:o.getItems().map(o=>{var t,e,s;return index.h("div",{class:`onto-toast toast ${o.type}`,key:o.id,onMouseEnter:this.onToastMouseEnter(o),onMouseLeave:this.onToastMouseLeave(o),onClick:this.handleToastClick(o),onKeyUp:this.handleKeyUp(o)},index.h("i",{class:`${toastTypeToIconMap[o.type]}`}),index.h("span",null,(null===(t=o.config)||void 0===t?void 0:t.title)?index.h("div",{class:"toast-title",innerHTML:translation_service.sanitizeHTML(translation_service.TranslationService.translate(o.config.title,null===(e=o.config)||void 0===e?void 0:e.translationParams))}):"",index.h("div",{class:"toast-message",innerHTML:translation_service.sanitizeHTML(translation_service.TranslationService.translate(o.message,null===(s=o.config)||void 0===s?void 0:s.translationParams))})))}))}addToast(o){this.toasts.addToStart(o),this.setTimeoutForToast(o),this.updateToastrReference()}setTimeoutForToast(o){var t;const e=workbenchApi.WindowService.getWindow().setTimeout(()=>{this.toasts.remove(o),this.clearToastTimeout(o)},(null===(t=o.config)||void 0===t?void 0:t.timeout)||this.config.timeout);this.toastToTimeout.set(o,e)}updateToastrReference(){this.toasts=new workbenchApi.ToastMessageList(this.toasts.getItems())}clearToastTimeout(o){const t=this.toastToTimeout.get(o);clearTimeout(t),this.toastToTimeout.delete(o),this.updateToastrReference()}handleToastClick(o){return t=>{var e,s;(null===(e=o.config)||void 0===e?void 0:e.onClick)&&o.config.onClick(t),(null===(s=o.config)||void 0===s?void 0:s.removeOnClick)&&(this.toasts.remove(o),this.clearToastTimeout(o))}}handleKeyUp(o){return t=>{"Enter"===t.key&&this.handleToastClick(o)}}};OntoToastr.style=ontoToastrCss(),exports.onto_toastr=OntoToastr;